diff --git a/src/main/java/tschipp/carryon/CarryOn.java b/src/main/java/tschipp/carryon/CarryOn.java index b48366e..8c1f25d 100644 --- a/src/main/java/tschipp/carryon/CarryOn.java +++ b/src/main/java/tschipp/carryon/CarryOn.java @@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import tschipp.carryon.common.CommonProxy; @EventBusSubscriber @@ -26,12 +27,12 @@ public class CarryOn { public static CarryOn instance; public static final String MODID = "carryon"; - public static final String VERSION = "1.2.1"; + public static final String VERSION = "1.3"; public static final String NAME = "Carry On"; public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/"; public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn"); - //public static SimpleNetworkWrapper network; + public static SimpleNetworkWrapper network; @EventHandler public void preInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/tschipp/carryon/client/ClientProxy.java b/src/main/java/tschipp/carryon/client/ClientProxy.java index 5986f60..f42de29 100644 --- a/src/main/java/tschipp/carryon/client/ClientProxy.java +++ b/src/main/java/tschipp/carryon/client/ClientProxy.java @@ -3,6 +3,7 @@ package tschipp.carryon.client; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import tschipp.carryon.client.keybinds.CarryOnKeybinds; import tschipp.carryon.common.CommonProxy; import tschipp.carryon.common.handler.RegistrationHandler; @@ -19,6 +20,7 @@ public class ClientProxy extends CommonProxy { @Override public void init(FMLInitializationEvent event) { + CarryOnKeybinds.init(); super.init(event); } diff --git a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java b/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java index 8157e62..c48580d 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java +++ b/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java @@ -13,6 +13,7 @@ import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.client.resources.DefaultPlayerSkin; @@ -155,8 +156,9 @@ public class RenderEntityEvents GlStateManager.enableAlpha(); - if (perspective == 0 && Minecraft.getMinecraft().inGameHasFocus) + if (perspective == 0) { + RenderHelper.enableStandardItemLighting(); Minecraft.getMinecraft().getRenderManager().setRenderShadow(false); Minecraft.getMinecraft().getRenderManager().renderEntityStatic(entity, 0.0f, false); Minecraft.getMinecraft().getRenderManager().setRenderShadow(true); @@ -167,6 +169,12 @@ public class RenderEntityEvents GlStateManager.scale(1, 1, 1); GlStateManager.popMatrix(); + + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableRescaleNormal(); + GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GlStateManager.disableTexture2D(); + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); if (perspective == 0) event.setCanceled(true); @@ -240,37 +248,5 @@ public class RenderEntityEvents } - public void renderEntityStaticCO(Entity entityIn, float partialTicks, boolean p_188388_3_) - { - if (entityIn.ticksExisted == 0) - { - entityIn.lastTickPosX = entityIn.posX; - entityIn.lastTickPosY = entityIn.posY; - entityIn.lastTickPosZ = entityIn.posZ; - } - - double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks; - double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks; - double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks; - float f = entityIn.prevRotationYaw + (entityIn.rotationYaw - entityIn.prevRotationYaw) * partialTicks; - - int i = 0; - if (!Minecraft.getMinecraft().theWorld.isDaytime()) { - i = entityIn.getBrightnessForRender(partialTicks); - } else { - i = 50000; - } - if (entityIn.isBurning()) - { - i = 15728880; - } - - int j = i % 65536; - int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - RenderManager manager = Minecraft.getMinecraft().getRenderManager(); - manager.doRenderEntity(entityIn, d0, d1, d2, f, partialTicks, p_188388_3_); - } } diff --git a/src/main/java/tschipp/carryon/client/event/RenderEvents.java b/src/main/java/tschipp/carryon/client/event/RenderEvents.java index 0428b41..6f1e709 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEvents.java +++ b/src/main/java/tschipp/carryon/client/event/RenderEvents.java @@ -1,8 +1,6 @@ package tschipp.carryon.client.event; import java.lang.reflect.Field; -import java.util.Iterator; -import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -36,13 +34,17 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import tschipp.carryon.CarryOn; +import tschipp.carryon.client.keybinds.CarryOnKeybinds; import tschipp.carryon.common.config.CarryOnConfig; import tschipp.carryon.common.handler.ModelOverridesHandler; import tschipp.carryon.common.handler.RegistrationHandler; import tschipp.carryon.common.item.ItemEntity; import tschipp.carryon.common.item.ItemTile; +import tschipp.carryon.network.server.SyncKeybindPacket; public class RenderEvents { @@ -65,6 +67,30 @@ public class RenderEvents } } + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void onPlayerTick(PlayerTickEvent event) + { + EntityPlayer player = event.player; + if (player != null && event.side == Side.CLIENT) + { + + boolean keyPressed = CarryOnKeybinds.carryKey.isKeyDown(); + boolean playerKeyPressed = CarryOnKeybinds.isKeyPressed(player); + + if (keyPressed && !playerKeyPressed) + { + CarryOnKeybinds.setKeyPressed(player, true); + CarryOn.network.sendToServer(new SyncKeybindPacket(true)); + } + else if(!keyPressed && playerKeyPressed) + { + CarryOnKeybinds.setKeyPressed(player, false); + CarryOn.network.sendToServer(new SyncKeybindPacket(false)); + } + } + } + /* * Prevents the Player from opening Guis */ @@ -265,7 +291,6 @@ public class RenderEvents GlStateManager.popMatrix(); } - } /* @@ -275,15 +300,16 @@ public class RenderEvents @SubscribeEvent public void onPlayerRenderPre(RenderPlayerEvent.Pre event) { - - if (!Loader.isModLoaded("mobends")) { + + if (!Loader.isModLoaded("mobends") && CarryOnConfig.settings.renderArms) + { EntityPlayer player = event.getEntityPlayer(); AbstractClientPlayer aplayer = (AbstractClientPlayer) player; ItemStack stack = player.getHeldItemMainhand(); ModelPlayer model = event.getRenderer().getMainModel(); EntityPlayerSP clientPlayer = Minecraft.getMinecraft().thePlayer; - + ResourceLocation skinLoc = DefaultPlayerSkin.getDefaultSkin(player.getPersistentID()); ModelRenderer fakeLeftArm = new ModelRenderer(model, 32, 48); @@ -293,9 +319,19 @@ public class RenderEvents if (stack != null ? ((stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) || (stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))) : false) { - - if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty()) { - model.bipedBody.childModels.clear(); + if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty()) + { + + for (int k = 0; k < model.bipedBody.childModels.size(); k++) + { + float chkRot = model.bipedBody.childModels.get(k).rotateAngleX; + if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F) + { + model.bipedBody.childModels.remove(k); + k = k - 1; + } + } + } Item item = stack.getItem(); @@ -305,6 +341,7 @@ public class RenderEvents Minecraft.getMinecraft().getTextureManager().bindTexture(skinLoc); float rotation = -player.renderYawOffset; + if (aplayer.getSkinType().equals("default")) { fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F); @@ -327,26 +364,26 @@ public class RenderEvents { if (!player.isSneaking()) { - fakeRightArm.rotateAngleX = -.9F; - fakeLeftArm.rotateAngleX = -.9F; + fakeRightArm.rotateAngleX = -.9001F; + fakeLeftArm.rotateAngleX = -.9001F; } else { - fakeRightArm.rotateAngleX = -1.4F; - fakeLeftArm.rotateAngleX = -1.4F; + fakeRightArm.rotateAngleX = -1.4001F; + fakeLeftArm.rotateAngleX = -1.4001F; } } else { if (!player.isSneaking()) { - fakeRightArm.rotateAngleX = -1.2F; - fakeLeftArm.rotateAngleX = -1.2F; + fakeRightArm.rotateAngleX = -1.2001F; + fakeLeftArm.rotateAngleX = -1.2001F; } else { - fakeRightArm.rotateAngleX = -1.7F; - fakeLeftArm.rotateAngleX = -1.7F; + fakeRightArm.rotateAngleX = -1.7001F; + fakeLeftArm.rotateAngleX = -1.7001F; } fakeRightArm.rotateAngleY = -0.15f; @@ -361,10 +398,18 @@ public class RenderEvents { model.bipedLeftArm.isHidden = false; model.bipedRightArm.isHidden = false; - + if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty()) { - model.bipedBody.childModels.clear(); + for (int k = 0; k < model.bipedBody.childModels.size(); k++) + { + float chkRot = model.bipedBody.childModels.get(k).rotateAngleX; + if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F) + { + model.bipedBody.childModels.remove(k); + k = k - 1; + } + } } } @@ -374,7 +419,6 @@ public class RenderEvents model.bipedRightArm.isHidden = false; } } - } diff --git a/src/main/java/tschipp/carryon/client/keybinds/CarryOnKeybinds.java b/src/main/java/tschipp/carryon/client/keybinds/CarryOnKeybinds.java new file mode 100644 index 0000000..25eaad2 --- /dev/null +++ b/src/main/java/tschipp/carryon/client/keybinds/CarryOnKeybinds.java @@ -0,0 +1,44 @@ +package tschipp.carryon.client.keybinds; + +import org.lwjgl.input.Keyboard; + +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fml.client.registry.ClientRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class CarryOnKeybinds +{ + + public static final String KEYBIND_KEY = "carryOnKeyPressed"; + public static KeyBinding carryKey; + + @SideOnly(Side.CLIENT) + public static void init() + { + carryKey = new KeyBinding("key.carry.desc", Keyboard.KEY_LSHIFT, "key.carry.category"); + + ClientRegistry.registerKeyBinding(carryKey); + } + + public static boolean isKeyPressed(EntityPlayer player) + { + NBTTagCompound tag = player.getEntityData(); + if(tag != null && tag.hasKey(KEYBIND_KEY)) + { + return tag.getBoolean(KEYBIND_KEY); + } + return false; + } + + public static void setKeyPressed(EntityPlayer player, boolean pressed) + { + NBTTagCompound tag = player.getEntityData(); + tag.setBoolean(KEYBIND_KEY, pressed); + } + + + +} diff --git a/src/main/java/tschipp/carryon/common/CommonProxy.java b/src/main/java/tschipp/carryon/common/CommonProxy.java index 3edebe9..29538cd 100644 --- a/src/main/java/tschipp/carryon/common/CommonProxy.java +++ b/src/main/java/tschipp/carryon/common/CommonProxy.java @@ -4,8 +4,12 @@ import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.relauncher.Side; import tschipp.carryon.CarryOn; import tschipp.carryon.common.handler.RegistrationHandler; +import tschipp.carryon.network.server.SyncKeybindPacket; +import tschipp.carryon.network.server.SyncKeybindPacketHandler; public class CommonProxy { @@ -13,6 +17,10 @@ public class CommonProxy @EventHandler public void preInit(FMLPreInitializationEvent event) { + CarryOn.network = NetworkRegistry.INSTANCE.newSimpleChannel("CarryOn"); + + CarryOn.network.registerMessage(SyncKeybindPacketHandler.class, SyncKeybindPacket.class, 0, Side.SERVER); + RegistrationHandler.regItems(); RegistrationHandler.regCommonEvents(); } diff --git a/src/main/java/tschipp/carryon/common/config/Configs.java b/src/main/java/tschipp/carryon/common/config/Configs.java index ebd8123..7db9296 100644 --- a/src/main/java/tschipp/carryon/common/config/Configs.java +++ b/src/main/java/tschipp/carryon/common/config/Configs.java @@ -36,6 +36,15 @@ public class Configs { @Comment("Larger Entities slow down the player more") public boolean heavyEntities = true; + + @Comment("Slowness multiplier for blocks") + public double blockSlownessMultiplier = 1.0; + + @Comment("Slowness multiplier for entities") + public double entitySlownessMultiplier = 1.0; + + @Comment("Arms should render on sides when carrying") + public boolean renderArms = true; } public static class Blacklist @@ -61,6 +70,8 @@ public class Configs { "bigreactors:*", "forestry:*", "tconstruct:*", + "refinedstorage:*", + "rustic:*", "immersiveengineering:*", "embers:block_furnace", "embers:ember_bore", @@ -85,7 +96,8 @@ public class Configs { "EnderDragon", "Ghast", "Shulker", - "animania:textures/entity/pigs/hamster_tarou.png" + "animania:textures/entity/pigs/hamster_tarou.png", + "mynko:*" }; } @@ -106,6 +118,7 @@ public class Configs { "minecraft:tallgrass;2->(item)minecraft:tallgrass;2", "minecraft:flower_pot->(block)minecraft:flower_pot", "minecraft:leaves2->(item)minecraft:leaves2", + "minecraft:reeds->(block)minecraft:reeds", "quark:custom_chest{type:\"spruce\"}->quark:custom_chest;0", "quark:custom_chest{type:\"birch\"}->quark:custom_chest;1", "quark:custom_chest{type:\"jungle\"}->quark:custom_chest;2", diff --git a/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java b/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java index 76ded9d..1510011 100644 --- a/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java +++ b/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java @@ -1,19 +1,24 @@ package tschipp.carryon.common.event; +import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.Event.Result; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import tschipp.carryon.client.keybinds.CarryOnKeybinds; import tschipp.carryon.common.handler.PickupHandler; import tschipp.carryon.common.handler.RegistrationHandler; import tschipp.carryon.common.item.ItemEntity; @@ -56,7 +61,7 @@ public class ItemEntityEvents } } - @SubscribeEvent(priority = EventPriority.NORMAL) + @SubscribeEvent(priority = EventPriority.HIGH) public void onEntityRightClick(PlayerInteractEvent.EntityInteract event) { EntityPlayer player = event.getEntityPlayer(); @@ -69,7 +74,7 @@ public class ItemEntityEvents Entity entity = event.getTarget(); BlockPos pos = entity.getPosition(); - if (main == null && off == null && player.isSneaking()) + if (main == null && off == null && CarryOnKeybinds.isKeyPressed(player)) { ItemStack stack = new ItemStack(RegistrationHandler.itemEntity); @@ -88,4 +93,29 @@ public class ItemEntityEvents } + @SubscribeEvent + public void onLivingUpdate(LivingUpdateEvent event) + { + EntityLivingBase entity = event.getEntityLiving(); + World world = entity.worldObj; + ItemStack main = entity.getHeldItemMainhand(); + if (main != null ? (main.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(main)) : false) + { + BlockPos pos = entity.getPosition(); + BlockPos below = pos.offset(EnumFacing.DOWN); + + if (world.getBlockState(pos).getMaterial() == Material.WATER || world.getBlockState(below).getMaterial() == Material.WATER) + { + Entity contained = ItemEntity.getEntity(main, world); + if (contained != null) + { + float height = contained.height; + float width = contained.width; + + entity.addVelocity(0, -0.01 * height * width, 0); + } + } + } + } + } diff --git a/src/main/java/tschipp/carryon/common/event/ItemEvents.java b/src/main/java/tschipp/carryon/common/event/ItemEvents.java index c2ea45a..aa040d8 100644 --- a/src/main/java/tschipp/carryon/common/event/ItemEvents.java +++ b/src/main/java/tschipp/carryon/common/event/ItemEvents.java @@ -2,6 +2,7 @@ package tschipp.carryon.common.event; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -19,6 +20,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.Event.Result; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import tschipp.carryon.client.keybinds.CarryOnKeybinds; import tschipp.carryon.common.config.CarryOnConfig; import tschipp.carryon.common.handler.ForbiddenTileHandler; import tschipp.carryon.common.handler.PickupHandler; @@ -92,7 +94,7 @@ public class ItemEvents Block block = world.getBlockState(pos).getBlock(); IBlockState state = world.getBlockState(pos); - if (main == null && off == null && player.isSneaking() && !ForbiddenTileHandler.isForbidden(block)) + if (main == null && off == null && CarryOnKeybinds.isKeyPressed(player) && !ForbiddenTileHandler.isForbidden(block)) { ItemStack stack = new ItemStack(RegistrationHandler.itemTile); diff --git a/src/main/java/tschipp/carryon/common/handler/PickupHandler.java b/src/main/java/tschipp/carryon/common/handler/PickupHandler.java index b4edfac..fa77ac3 100644 --- a/src/main/java/tschipp/carryon/common/handler/PickupHandler.java +++ b/src/main/java/tschipp/carryon/common/handler/PickupHandler.java @@ -8,6 +8,7 @@ import com.feed_the_beast.ftbu.api_impl.ClaimedChunkStorage; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.passive.EntityTameable; diff --git a/src/main/java/tschipp/carryon/common/item/ItemEntity.java b/src/main/java/tschipp/carryon/common/item/ItemEntity.java index 769ac67..3f87220 100644 --- a/src/main/java/tschipp/carryon/common/item/ItemEntity.java +++ b/src/main/java/tschipp/carryon/common/item/ItemEntity.java @@ -211,6 +211,6 @@ public class ItemEntity extends Item if (!CarryOnConfig.settings.heavyEntities) i = 1; - return i; + return (int) (i * CarryOnConfig.settings.entitySlownessMultiplier); } } diff --git a/src/main/java/tschipp/carryon/common/item/ItemTile.java b/src/main/java/tschipp/carryon/common/item/ItemTile.java index b1bfa1e..598a00c 100644 --- a/src/main/java/tschipp/carryon/common/item/ItemTile.java +++ b/src/main/java/tschipp/carryon/common/item/ItemTile.java @@ -316,6 +316,6 @@ public class ItemTile extends Item if (!CarryOnConfig.settings.heavyTiles) i = 1; - return i; + return (int) (i * CarryOnConfig.settings.blockSlownessMultiplier); } } diff --git a/src/main/java/tschipp/carryon/network/server/SyncKeybindPacket.java b/src/main/java/tschipp/carryon/network/server/SyncKeybindPacket.java new file mode 100644 index 0000000..3dbca52 --- /dev/null +++ b/src/main/java/tschipp/carryon/network/server/SyncKeybindPacket.java @@ -0,0 +1,35 @@ +package tschipp.carryon.network.server; + +import io.netty.buffer.ByteBuf; +import net.minecraftforge.fml.common.network.ByteBufUtils; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; + +public class SyncKeybindPacket implements IMessage +{ + + private int p; + public boolean pressed; + + public SyncKeybindPacket() + { + } + + public SyncKeybindPacket(boolean pressed) + { + this.p = pressed ? 1 : 0; + } + + @Override + public void fromBytes(ByteBuf buf) + { + this.p = ByteBufUtils.readVarInt(buf, 4); + this.pressed = p == 1 ? true : false; + } + + @Override + public void toBytes(ByteBuf buf) + { + ByteBufUtils.writeVarInt(buf, p, 4); + } + +} diff --git a/src/main/java/tschipp/carryon/network/server/SyncKeybindPacketHandler.java b/src/main/java/tschipp/carryon/network/server/SyncKeybindPacketHandler.java new file mode 100644 index 0000000..95232e6 --- /dev/null +++ b/src/main/java/tschipp/carryon/network/server/SyncKeybindPacketHandler.java @@ -0,0 +1,34 @@ +package tschipp.carryon.network.server; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.IThreadListener; +import net.minecraft.world.WorldServer; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import tschipp.carryon.client.keybinds.CarryOnKeybinds; + +public class SyncKeybindPacketHandler implements IMessageHandler +{ + + @Override + public IMessage onMessage(final SyncKeybindPacket message, final MessageContext ctx) + { + IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; + + mainThread.addScheduledTask(new Runnable() + { + EntityPlayerMP player = ctx.getServerHandler().playerEntity; + + @Override + public void run() + { + CarryOnKeybinds.setKeyPressed(player, message.pressed); + } + + }); + + return null; + } + +} diff --git a/src/main/resources/assets/carryon/lang/en_US.lang b/src/main/resources/assets/carryon/lang/en_US.lang index d0c67fb..5811dbb 100644 --- a/src/main/resources/assets/carryon/lang/en_US.lang +++ b/src/main/resources/assets/carryon/lang/en_US.lang @@ -8,3 +8,6 @@ carryon.general.blacklist.forbiddenentities=Entities that the Player cannot pick carryon.general.blacklist.forbiddentiles=Blocks that the Player cannot pick up carryon.category.custompickupconditions.custompickupconditionsblocks=Custom Block Pickup Conditions carryon.category.custompickupconditions.custompickupconditionsentities=Custom Entity Pickup Conditions + +key.carry.desc=Carry +key.carry.category=Carry On \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 1da0171..dc12efc 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ { "modid" : "carryon", "name" : "Carry On", - "version" : "1.2.2", "mcversion" : "1.10.2", + "version" : "1.3", "mcversion" : "1.10.2", "url" : "", "credits" : "Tschipp, Purplicious_Cow, cy4n", "authorList" : ["Tschipp, Purplicious_Cow, cy4n"],