mirror of
https://github.com/squeek502/Squake.git
synced 2025-08-03 09:47:22 -04:00
Merge branch '1.10.2' of https://github.com/squeek502/Squake into 1.12
# Conflicts: # java/squeek/quakemovement/QuakeClientPlayer.java
This commit is contained in:
commit
d08ff1666b
@ -2,6 +2,7 @@ package squeek.quakemovement;
|
||||
|
||||
import java.io.File;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
public class ModConfig
|
||||
{
|
||||
@ -59,6 +60,11 @@ public class ModConfig
|
||||
private static final String MAX_AIR_ACCEL_PER_TICK_NAME = "maxAirAccelerationPerTick";
|
||||
private static final double MAX_AIR_ACCEL_PER_TICK_DEFAULT = 0.045D;
|
||||
|
||||
public static boolean ENABLED;
|
||||
private static Property ENABLED_PROPERTY;
|
||||
private static final String ENABLED_NAME = "enabled";
|
||||
private static final boolean ENABLED_DEFAULT = true;
|
||||
|
||||
private static Configuration config;
|
||||
|
||||
public static void init(File file)
|
||||
@ -84,6 +90,16 @@ public class ModConfig
|
||||
|
||||
INCREASED_FALL_DISTANCE = (float) (config.get(CATEGORY_MOVEMENT, INCREASED_FALL_DISTANCE_NAME, INCREASED_FALL_DISTANCE_DEFAULT, "increases the distance needed to fall in order to take fall damage; this is a server-side setting").getDouble(INCREASED_FALL_DISTANCE_DEFAULT));
|
||||
|
||||
ENABLED_PROPERTY = config.get(CATEGORY_MOVEMENT, ENABLED_NAME, ENABLED_DEFAULT, "turns off/on the quake-style movement for the client (essentially the saved value of the ingame toggle keybind)");
|
||||
ENABLED = ENABLED_PROPERTY.getBoolean(ENABLED_DEFAULT);
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setEnabled(boolean enabled)
|
||||
{
|
||||
ModConfig.ENABLED = enabled;
|
||||
ENABLED_PROPERTY.set(enabled);
|
||||
save();
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import net.minecraftforge.fml.common.Mod.Instance;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
@Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, name="Squake", acceptedMinecraftVersions="[1.12,1.13)", dependencies = "after:squeedometer")
|
||||
public class ModQuakeMovement
|
||||
@ -22,6 +23,10 @@ public class ModQuakeMovement
|
||||
{
|
||||
ModConfig.init(event.getSuggestedConfigurationFile());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
if (event.getSide() == Side.CLIENT)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(new ToggleKeyHandler());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -50,6 +50,9 @@ public class QuakeClientPlayer
|
||||
if (!player.world.isRemote)
|
||||
return false;
|
||||
|
||||
if (!ModConfig.ENABLED)
|
||||
return false;
|
||||
|
||||
boolean didQuakeMovement;
|
||||
double d0 = player.posX;
|
||||
double d1 = player.posY;
|
||||
@ -113,7 +116,10 @@ public class QuakeClientPlayer
|
||||
if (!player.world.isRemote)
|
||||
return false;
|
||||
|
||||
if ((player.capabilities.isFlying && player.getRidingEntity() == null) || player.isInWater() || player.isInLava())
|
||||
if (!ModConfig.ENABLED)
|
||||
return false;
|
||||
|
||||
if ((player.capabilities.isFlying && player.getRidingEntity() == null) || player.isInWater() || player.isInLava() || player.isOnLadder())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -133,6 +139,9 @@ public class QuakeClientPlayer
|
||||
if (!player.world.isRemote)
|
||||
return;
|
||||
|
||||
if (!ModConfig.ENABLED)
|
||||
return;
|
||||
|
||||
// undo this dumb thing
|
||||
if (player.isSprinting())
|
||||
{
|
||||
@ -442,8 +451,13 @@ public class QuakeClientPlayer
|
||||
*/
|
||||
public static boolean quake_moveEntityWithHeading(EntityPlayer player, float sidemove, float upmove, float forwardmove)
|
||||
{
|
||||
// take care of ladder movement using default code
|
||||
if (player.isOnLadder())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// take care of lava movement using default code
|
||||
if ((player.isInLava() && !player.capabilities.isFlying))
|
||||
else if ((player.isInLava() && !player.capabilities.isFlying))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -508,15 +522,9 @@ public class QuakeClientPlayer
|
||||
}
|
||||
}
|
||||
|
||||
// make adjustments for ladder interaction
|
||||
minecraft_ApplyLadderPhysics(player);
|
||||
|
||||
// apply velocity
|
||||
player.move(MoverType.SELF, player.motionX, player.motionY, player.motionZ);
|
||||
|
||||
// climb ladder here for some reason
|
||||
minecraft_ClimbLadder(player);
|
||||
|
||||
// HL2 code applies half gravity before acceleration and half after acceleration, but this seems to work fine
|
||||
minecraft_ApplyGravity(player);
|
||||
}
|
||||
|
37
java/squeek/quakemovement/ToggleKeyHandler.java
Normal file
37
java/squeek/quakemovement/ToggleKeyHandler.java
Normal file
@ -0,0 +1,37 @@
|
||||
package squeek.quakemovement;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ToggleKeyHandler
|
||||
{
|
||||
private static final KeyBinding TOGGLE_KEY = new KeyBinding("squake.key.toggle", Keyboard.CHAR_NONE, ModInfo.MODID);
|
||||
|
||||
static
|
||||
{
|
||||
ClientRegistry.registerKeyBinding(TOGGLE_KEY);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyEvent(InputEvent.KeyInputEvent event)
|
||||
{
|
||||
if (TOGGLE_KEY.isPressed())
|
||||
{
|
||||
ModConfig.setEnabled(!ModConfig.ENABLED);
|
||||
|
||||
EntityPlayer player = FMLClientHandler.instance().getClientPlayerEntity();
|
||||
String feedback = ModConfig.ENABLED ? I18n.format("squake.key.toggle.enabled") : I18n.format("squake.key.toggle.disabled");
|
||||
player.sendMessage(new TextComponentString("[" + ModInfo.MODID + "] " + feedback));
|
||||
}
|
||||
}
|
||||
}
|
4
resources/assets/squake/lang/en_US.lang
Normal file
4
resources/assets/squake/lang/en_US.lang
Normal file
@ -0,0 +1,4 @@
|
||||
# Keybinds
|
||||
squake.key.toggle=Toggle Movement System On/Off
|
||||
squake.key.toggle.enabled=Movement system enabled
|
||||
squake.key.toggle.disabled=Movement system disabled
|
Loading…
x
Reference in New Issue
Block a user