mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-10-25 20:32:32 +00:00
Fix slimeboots & slimesling (#63)
* Fix slimeboots & slimesling * Use vec3 instead of Vector3d which isn't found on the server * set entity.motionXYZ manually, as setVelocity is ClientOnly * spotlessApply (#64) Co-authored-by: Jason Mitchell <mitchej+github@gmail.com> Co-authored-by: GitHub GTNH Actions <> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
3 files changed
+19
-13
No files matched your search
@@ -20,7 +20,7 @@ import tconstruct.gadgets.item.ItemSlimeSling;
|
||||
import tconstruct.library.SlimeBounceHandler;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
@Pulse(id = "Tinkers' Gadgets", description = "All the fun toys.")
|
||||
@Pulse(id = "Tinkers' Gadgets", description = "All the fun toys.", forced = true)
|
||||
public class TinkerGadgets {
|
||||
|
||||
public static final String PulseId = "TinkerGadgets";
|
||||
@@ -32,7 +32,7 @@ public class TinkerGadgets {
|
||||
|
||||
@Handler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
log.info("Pre Init");
|
||||
SlimeBounceHandler.init();
|
||||
slimeSling = registerItem(new ItemSlimeSling(), "slimesling");
|
||||
slimeBoots = registerItem(new ItemSlimeBoots(), "slime_boots");
|
||||
@@ -40,6 +40,7 @@ public class TinkerGadgets {
|
||||
|
||||
@Handler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
log.info("Init");
|
||||
String ore = "blockSlime";
|
||||
|
||||
GameRegistry.addRecipe(
|
||||
|
||||
@@ -4,7 +4,6 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import javax.vecmath.Vector3d;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -19,6 +18,7 @@ import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
@@ -76,7 +76,7 @@ public class ItemSlimeBoots extends ItemArmor implements ISpecialArmor {
|
||||
@SubscribeEvent
|
||||
// RUBBERY BOUNCY BOUNCERY WOOOOO
|
||||
public void onFall(LivingFallEvent event) {
|
||||
EntityLivingBase living = event.entityLiving;
|
||||
final EntityLivingBase living = event.entityLiving;
|
||||
// TinkerGadgets.log.info("Fall event.");
|
||||
// using fall distance as the event distance could be reduced by jump boost
|
||||
if (living == null || living.fallDistance <= 2f) {
|
||||
@@ -109,13 +109,15 @@ public class ItemSlimeBoots extends ItemArmor implements ISpecialArmor {
|
||||
|
||||
// server players behave differently than non-server players, they have no
|
||||
// velocity during the event, so we need to reverse engineer it
|
||||
Vector3d motion = SlimeBounceHandler.getMotion(living);
|
||||
Vec3 motion = SlimeBounceHandler.getMotion(living);
|
||||
if (living instanceof EntityPlayerMP) {
|
||||
// velocity is lost on server players, but we dont have to defer the bounce
|
||||
double gravity = 0.2353455252;
|
||||
double time = Math.sqrt(living.fallDistance / gravity);
|
||||
double velocity = gravity * time;
|
||||
living.setVelocity(motion.x / 0.95f, velocity, motion.z / 0.95f);
|
||||
living.motionX = motion.xCoord / 0.95f;
|
||||
living.motionY = velocity;
|
||||
living.motionZ = motion.zCoord / 0.95f;
|
||||
living.velocityChanged = true;
|
||||
// preserve momentum
|
||||
SlimeBounceHandler.addBounceHandler(living);
|
||||
@@ -123,8 +125,10 @@ public class ItemSlimeBoots extends ItemArmor implements ISpecialArmor {
|
||||
} else {
|
||||
// for non-players, need to defer the bounce
|
||||
// only slow down half as much when bouncing
|
||||
living.setVelocity(motion.x / 0.95f, motion.y * -0.9, motion.z / 0.95f);
|
||||
SlimeBounceHandler.addBounceHandler(living, SlimeBounceHandler.getMotion(living).y);
|
||||
living.motionX = motion.xCoord / 0.95f;
|
||||
living.motionY = motion.yCoord * -0.9;
|
||||
living.motionZ = motion.zCoord / 0.95f;
|
||||
SlimeBounceHandler.addBounceHandler(living, SlimeBounceHandler.getMotion(living).yCoord);
|
||||
// TinkerGadgets.log.info("Not Player");
|
||||
}
|
||||
// TinkerGadgets.log.info("Server Fall Handler.");
|
||||
|
||||
@@ -3,9 +3,9 @@ package tconstruct.library;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import java.util.IdentityHashMap;
|
||||
import javax.vecmath.Vector3d;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
@@ -122,7 +122,7 @@ public class SlimeBounceHandler {
|
||||
// resets y motion after landing
|
||||
if (entity.ticksExisted == info.bounceTick) {
|
||||
TinkerGadgets.log.info("Bounce Tick?");
|
||||
entity.setVelocity(entity.motionX, info.bounce, entity.motionZ);
|
||||
entity.motionY = info.bounce;
|
||||
info.bounceTick = 0;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,8 @@ public class SlimeBounceHandler {
|
||||
// preserve 95% of former speed
|
||||
double boost = Math.sqrt(info.lastMagSq / motionSq) * 0.95f;
|
||||
if (boost > 1) {
|
||||
entity.setVelocity(entity.motionX * boost, entity.motionY, entity.motionZ * boost);
|
||||
entity.motionX *= boost;
|
||||
entity.motionZ *= boost;
|
||||
entity.isAirBorne = true;
|
||||
info.lastMagSq = info.lastMagSq * 0.95f * 0.95f;
|
||||
// play sound if we had a big angle change
|
||||
@@ -181,8 +182,8 @@ public class SlimeBounceHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3d getMotion(EntityLivingBase aEntity) {
|
||||
return new Vector3d(aEntity.motionX, aEntity.motionY, aEntity.motionZ);
|
||||
public static Vec3 getMotion(EntityLivingBase aEntity) {
|
||||
return Vec3.createVectorHelper(aEntity.motionX, aEntity.motionY, aEntity.motionZ);
|
||||
}
|
||||
|
||||
public static boolean hasSlimeBoots(EntityLivingBase entity) {
|
||||
|
||||
Reference in new issue
Block a user