Skip to content

Commit

Permalink
Merge branch 'main' into remember-f5
Browse files Browse the repository at this point in the history
  • Loading branch information
hashalite authored Jun 16, 2023
2 parents 8c220e3 + 51f2d32 commit ed886af
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 91 deletions.
48 changes: 29 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,42 @@ This mod works in multiplayer, but may be considered cheating on some servers, s

## Keybinds

|Name|Description|Default Bind|
|-|-|-|
|Toggle Freecam|Enables/disables Freecam|`F4`|
|Control Player|Transfers control back to your player, but retains your current perspective (Can only be used while Freecam is active.)|`Unbound`|
|Reset Tripod|Resets a tripod\* camera when pressed in combination with any of the hotbar keys|`Unbound`|
| Name | Description | Default Bind |
|----------------|-------------------------------------------------------------------------------------------------------------------------|--------------|
| Toggle Freecam | Enables/disables Freecam | `F4` |
| Control Player | Transfers control back to your player, but retains your current perspective (Can only be used while Freecam is active.) | `Unbound` |
| Reset Tripod | Resets a tripod\* camera when pressed in combination with any of the hotbar keys | `Unbound` |

\*The freecam bind can also be used in conjunction with any of the hotbar keys (`F4` + `1`...`9`) to enter "tripod" mode. This enables you to set up multiple cameras with differing perspectives, and switch between them at will.

## Settings

(Configurable via [Mod Menu](https://www.curseforge.com/minecraft/mc-mods/modmenu) or the config file)

|Name|Description|Default Value|
|-|-|-|
|Flight Mode|The type of flight used by freecam.<br /><br />**Options:**<br />- `DEFAULT` Static velocity with no drifting<br />- `CREATIVE` Vanilla creative flight|`DEFAULT`|
|Interaction Mode|The source of block/entity interactions.<br /><br />**Options:**<br />- `CAMERA` Interactions come from the camera<br />- `PLAYER` Interactions come from the player|`CAMERA`|
|Horizontal Speed|The horizontal speed of freecam.|`1.0`|
|Vertical Speed|The vertical speed of freecam.|`1.0`|
|No Clip|Whether you can travel through blocks in freecam.|`true`|
|Freeze Player|Prevents player movement while freecam is active.<br />**WARNING: Multiplayer usage not advised.**|`false`|
|Allow Interaction|Whether you can interact with blocks/entities in freecam.<br />**WARNING: Multiplayer usage not advised.**|`false`|
|Disable on Damage|Disables freecam when damage is received.|`true`|
|Show Player|Shows your player in its original position.|`true`|
|Show Hand|Whether you can see your hand in freecam.|`false`|
|Freecam Notifications|Notifies you when entering/exiting freecam.|`true`|
|Tripod Notifications|Notifies you when entering/exiting tripod cameras.|`true`|
| Name | Description | Default Value |
|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| Flight Mode | The type of flight used by freecam.<br /><br />**Options:**<br />- `DEFAULT` : Static velocity with no drifting<br />- `CREATIVE` : Vanilla creative flight | `DEFAULT` |
| Initial Perspective | The initial perspective of the camera.<br /><br />**Options:**<br />- `FIRST_PERSON` : The player's perspective<br />- `THIRD_PERSON` : Behind the player<br />- `THIRD_PERSON_MIRROR` : In front of the player<br />- `INSIDE` : Inside the player | `INSIDE` |
| Interaction Mode | The source of block/entity interactions.<br /><br />**Options:**<br />- `CAMERA` : Interactions come from the camera<br />- `PLAYER` : Interactions come from the player | `CAMERA` |
| Horizontal Speed | The horizontal speed of freecam. | `1.0` |
| Vertical Speed | The vertical speed of freecam. | `1.0` |
| Freeze Player | Prevents player movement while freecam is active.<br />**WARNING: Multiplayer usage not advised.** | `false` |
| Allow Interaction | Whether you can interact with blocks/entities in freecam.<br />**WARNING: Multiplayer usage not advised.** | `false` |
| Disable on Damage | Disables freecam when damage is received. | `true` |
| Show Player | Shows your player in its original position. | `true` |
| Show Hand | Whether you can see your hand in freecam. | `false` |
| Show Submersion Fog | Whether you see a fog overlay underwater, in lava, or powdered snow. | `false` |
| Freecam Notifications | Notifies you when entering/exiting freecam. | `true` |
| Tripod Notifications | Notifies you when entering/exiting tripod cameras. | `true` |

## Collision Options

| Name | Description | Default Value |
|--------------------------------|------------------------------------------------------------------------------------------------------|---------------|
| Ignore Transparent Blocks | Allows travelling through transparent blocks in freecam. | `true` |
| Ignore Openable Blocks | Allows travelling through doors/trapdoors/gates in freecam. | `true` |
| Ignore All Collision | Allows travelling through all blocks in freecam. | `true` |
| Always Check Initial Collision | Whether **Initial Perspective** should check for collision, even when using **Ignore All Collision** | `false` |

## Requirements

Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
mc_version=1.19.4
mc_major_version=1.19
yarn_mappings=1.19.4+build.1
loader_version=0.14.17
mc_version=1.20.1
mc_major_version=1.20
yarn_mappings=1.20.1+build.2
loader_version=0.14.21
# Mod Properties
mod_version=1.1.9
mod_version=1.1.10
maven_group=net.xolt
archives_base_name=freecam-fabric
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.76.0+1.19.4
modmenu_version=6.1.0-rc.4
cloth_version=10.0.96
fabric_version=0.83.1+1.20.1
modmenu_version=7.0.1
cloth_version=11.0.99
8 changes: 8 additions & 0 deletions src/main/java/net/xolt/freecam/Freecam.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.xolt.freecam;

import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
Expand All @@ -25,6 +26,7 @@ public class Freecam implements ClientModInitializer {
private static KeyBinding freecamBind;
private static KeyBinding playerControlBind;
private static KeyBinding tripodResetBind;
private static KeyBinding configGuiBind;
private static boolean freecamEnabled = false;
private static boolean tripodEnabled = false;
private static boolean playerControlEnabled = false;
Expand All @@ -45,6 +47,8 @@ public void onInitializeClient() {
"key.freecam.playerControl", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_UNKNOWN, "category.freecam.freecam"));
tripodResetBind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.freecam.tripodReset", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_UNKNOWN, "category.freecam.freecam"));
configGuiBind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.freecam.configGui", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_UNKNOWN, "category.freecam.freecam"));

ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (tripodResetBind.isPressed()) {
Expand All @@ -71,6 +75,10 @@ public void onInitializeClient() {
while (playerControlBind.wasPressed()) {
switchControls();
}

while (configGuiBind.wasPressed()) {
MC.setScreen(AutoConfig.getConfigScreen(ModConfig.class, MC.currentScreen).get());
}
});
}

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/net/xolt/freecam/mixins/AbstractBlockMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package net.xolt.freecam.mixins;

import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.EntityShapeContext;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.xolt.freecam.Freecam;
import net.xolt.freecam.config.CollisionWhitelist;
import net.xolt.freecam.config.ModConfig;
import net.xolt.freecam.util.FreeCamera;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(AbstractBlock.class)
public class AbstractBlockMixin {

@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
private void onGetCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (context instanceof EntityShapeContext && ((EntityShapeContext)context).getEntity() instanceof FreeCamera) {
// Unless "Always Check Initial Collision" is on and Freecam isn't enabled yet
if (!ModConfig.INSTANCE.collision.alwaysCheck || Freecam.isEnabled()) {
// Ignore all collisions
if (ModConfig.INSTANCE.collision.ignoreAll) {
cir.setReturnValue(VoxelShapes.empty());
}
}
// Ignore transparent block collisions
if (ModConfig.INSTANCE.collision.ignoreTransparent && CollisionWhitelist.isTransparent(state.getBlock())) {
cir.setReturnValue(VoxelShapes.empty());
}
// Ignore transparent block collisions
if (ModConfig.INSTANCE.collision.ignoreOpenable && CollisionWhitelist.isOpenable(state.getBlock())) {
cir.setReturnValue(VoxelShapes.empty());
}
}
}
}

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/net/xolt/freecam/util/FreeCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class FreeCamera extends ClientPlayerEntity {

private static final ClientPlayNetworkHandler NETWORK_HANDLER = new ClientPlayNetworkHandler(MC, MC.currentScreen, MC.getNetworkHandler().getConnection(), MC.getCurrentServerEntry(), new GameProfile(UUID.randomUUID(), "FreeCamera"), MC.getTelemetryManager().createWorldSession(false, null)) {
private static final ClientPlayNetworkHandler NETWORK_HANDLER = new ClientPlayNetworkHandler(MC, MC.currentScreen, MC.getNetworkHandler().getConnection(), MC.getCurrentServerEntry(), new GameProfile(UUID.randomUUID(), "FreeCamera"), MC.getTelemetryManager().createWorldSession(false, null, null)) {
@Override
public void sendPacket(Packet<?> packet) {
}
Expand Down Expand Up @@ -198,6 +198,6 @@ public void tickMovement() {
}
super.tickMovement();
getAbilities().flying = true;
onGround = false;
setOnGround(false);
}
}
7 changes: 4 additions & 3 deletions src/main/resources/assets/freecam/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"key.freecam.toggle": "Toggle Freecam",
"key.freecam.playerControl": "Control Player",
"key.freecam.tripodReset": "Reset Tripod",
"key.freecam.configGui": "Config GUI",
"msg.freecam.enable": "Freecam has been enabled.",
"msg.freecam.disable": "Freecam has been disabled.",
"msg.freecam.openTripod": "Opening camera #",
Expand Down Expand Up @@ -40,11 +41,11 @@
"text.autoconfig.freecam.option.collision": "Collision Options",
"text.autoconfig.freecam.option.collision.@Tooltip": "Which blocks you can travel through in freecam.",
"text.autoconfig.freecam.option.collision.ignoreTransparent": "Ignore Transparent Blocks",
"text.autoconfig.freecam.option.collision.ignoreTransparent.@Tooltip": "You can travel through glass blocks in freecam.",
"text.autoconfig.freecam.option.collision.ignoreTransparent.@Tooltip": "Allows travelling through transparent blocks in freecam.",
"text.autoconfig.freecam.option.collision.ignoreOpenable": "Ignore Openable Blocks",
"text.autoconfig.freecam.option.collision.ignoreOpenable.@Tooltip": "You can travel through any door, trapdoor, or gate in freecam.",
"text.autoconfig.freecam.option.collision.ignoreOpenable.@Tooltip": "Allows travelling through doors/trapdoors/gates in freecam.",
"text.autoconfig.freecam.option.collision.ignoreAll": "Ignore All Collision",
"text.autoconfig.freecam.option.collision.ignoreAll.@Tooltip[0]": "You can travel through any block in freecam.",
"text.autoconfig.freecam.option.collision.ignoreAll.@Tooltip[0]": "Allows travelling through all blocks in freecam.",
"text.autoconfig.freecam.option.collision.ignoreAll.@Tooltip[1]": "§eOverrides above settings.",
"text.autoconfig.freecam.option.collision.alwaysCheck": "Always Check Initial Collision",
"text.autoconfig.freecam.option.collision.alwaysCheck.@Tooltip[0]": "Whether §7Initial Perspective§r should check for",
Expand Down
Loading

0 comments on commit ed886af

Please sign in to comment.