From 4fbc2a73de94902a033ff61b628f559a49cc67d4 Mon Sep 17 00:00:00 2001 From: NorthWestWind Date: Mon, 4 Jan 2021 18:07:36 +0800 Subject: [PATCH] Week #6 Update --- build.gradle | 2 +- .../moreboots/handler/MoreBootsHandler.java | 45 +++++++++++++ .../handler/MoreBootsPacketHandler.java | 4 ++ .../packet/CPlayerMultiJumpPacket.java | 60 ++++++++++++++++++ .../moreboots/init/ItemInit.java | 13 ++-- .../moreboots/init/item/ArmorItemBase.java | 4 -- .../moreboots/init/item/ItemBase.java | 11 +++- src/main/resources/META-INF/mods.toml | 2 +- .../assets/moreboots/lang/en_us.json | 5 +- .../moreboots/models/item/sand_boots.json | 6 ++ .../moreboots/textures/items/sand_boots.png | Bin 0 -> 1532 bytes .../textures/models/armor/sand_layer_1.png | Bin 0 -> 2194 bytes .../advancements/moreboots/sandals.json | 36 +++++++++++ .../data/moreboots/recipes/sand_boots.json | 19 ++++++ update.json | 28 ++++---- 15 files changed, 209 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/northwestwind/moreboots/handler/packet/CPlayerMultiJumpPacket.java create mode 100644 src/main/resources/assets/moreboots/models/item/sand_boots.json create mode 100644 src/main/resources/assets/moreboots/textures/items/sand_boots.png create mode 100644 src/main/resources/assets/moreboots/textures/models/armor/sand_layer_1.png create mode 100644 src/main/resources/data/moreboots/advancements/moreboots/sandals.json create mode 100644 src/main/resources/data/moreboots/recipes/sand_boots.json diff --git a/build.gradle b/build.gradle index 321ed74..9059a48 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.5.0-1.16.x' +version = '1.6.0-1.16.x' group = 'com.northwestwind.moreboots' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'moreboots' diff --git a/src/main/java/com/northwestwind/moreboots/handler/MoreBootsHandler.java b/src/main/java/com/northwestwind/moreboots/handler/MoreBootsHandler.java index 35e58b5..d9b0b39 100644 --- a/src/main/java/com/northwestwind/moreboots/handler/MoreBootsHandler.java +++ b/src/main/java/com/northwestwind/moreboots/handler/MoreBootsHandler.java @@ -1,5 +1,6 @@ package com.northwestwind.moreboots.handler; +import com.google.common.collect.Sets; import com.northwestwind.moreboots.Reference; import com.northwestwind.moreboots.handler.packet.*; import com.northwestwind.moreboots.init.BlockInit; @@ -11,6 +12,7 @@ import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.enchantment.FrostWalkerEnchantment; import net.minecraft.entity.AreaEffectCloudEntity; import net.minecraft.entity.Entity; @@ -22,6 +24,7 @@ import net.minecraft.fluid.*; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; import net.minecraft.potion.*; import net.minecraft.server.MinecraftServer; @@ -429,6 +432,48 @@ public void onKeyInput(final InputEvent.KeyInputEvent event) { player.setMotion(motion.mul(0, 1, 0).add(direction.getX(), 0, direction.getZ())); } if (player.world.isRemote) MoreBootsPacketHandler.INSTANCE.sendToServer(new CPlayerSkatePacket()); + } else if (Minecraft.getInstance().gameSettings.keyBindJump.isPressed() && event.getAction() == GLFW.GLFW_PRESS) { + ClientPlayerEntity player = Minecraft.getInstance().player; + if (player == null || player.func_233570_aj_() || player.abilities.isFlying) return; + ItemStack boots = player.getItemStackFromSlot(EquipmentSlotType.FEET); + if (!boots.getItem().equals(ItemInit.SANDALS)) return; + BlockPos pos = new BlockPos(player.getPositionVec()); + if (pos.getY() > 255 || pos.getY() < 0) return; + if (!player.world.isAirBlock(pos) || !player.inventory.hasAny(Sets.newHashSet(Items.SAND))) return; + boolean shouldJump = player.isCreative(); + if (!shouldJump) for (ItemStack stack : player.inventory.mainInventory) { + if (stack.getItem().equals(Items.SAND)) { + int slot = player.inventory.getSlotFor(stack); + stack.shrink(1); + player.inventory.setInventorySlotContents(slot, stack); + shouldJump = true; + break; + } + } + if (!shouldJump) for (ItemStack stack : player.inventory.offHandInventory) { + if (stack.getItem().equals(Items.SAND)) { + int slot = player.inventory.getSlotFor(stack); + stack.shrink(1); + player.inventory.setInventorySlotContents(slot, stack); + shouldJump = true; + break; + } + } + if (!shouldJump) for (ItemStack stack : player.inventory.armorInventory) { + if (stack.getItem().equals(Items.SAND)) { + int slot = player.inventory.getSlotFor(stack); + stack.shrink(1); + player.inventory.setInventorySlotContents(slot, stack); + shouldJump = true; + break; + } + } + if (shouldJump) { + player.world.setBlockState(pos, Blocks.SAND.getDefaultState(), 3); + player.jump(); + player.setMotion(player.getMotion().add(0,1,0)); + if (player.world.isRemote) MoreBootsPacketHandler.INSTANCE.sendToServer(new CPlayerMultiJumpPacket()); + } } } diff --git a/src/main/java/com/northwestwind/moreboots/handler/MoreBootsPacketHandler.java b/src/main/java/com/northwestwind/moreboots/handler/MoreBootsPacketHandler.java index f74f41f..c26f49b 100644 --- a/src/main/java/com/northwestwind/moreboots/handler/MoreBootsPacketHandler.java +++ b/src/main/java/com/northwestwind/moreboots/handler/MoreBootsPacketHandler.java @@ -29,5 +29,9 @@ public static void registerPackets() { ctx.get().enqueueWork(() -> msg.handle(ctx.get())); ctx.get().setPacketHandled(true); }); + INSTANCE.registerMessage(ID++, CPlayerMultiJumpPacket.class, (packet, packetBuffer) -> packetBuffer.writeByteArray(Utils.objToBytes(packet)), packetBuffer -> (CPlayerMultiJumpPacket) Utils.bytesToObj(packetBuffer.readByteArray()), (msg, ctx) -> { + ctx.get().enqueueWork(() -> msg.handle(ctx.get())); + ctx.get().setPacketHandled(true); + }); } } diff --git a/src/main/java/com/northwestwind/moreboots/handler/packet/CPlayerMultiJumpPacket.java b/src/main/java/com/northwestwind/moreboots/handler/packet/CPlayerMultiJumpPacket.java new file mode 100644 index 0000000..eedb178 --- /dev/null +++ b/src/main/java/com/northwestwind/moreboots/handler/packet/CPlayerMultiJumpPacket.java @@ -0,0 +1,60 @@ +package com.northwestwind.moreboots.handler.packet; + +import com.northwestwind.moreboots.handler.MoreBootsPacketHandler; +import com.northwestwind.moreboots.init.ItemInit; +import net.minecraft.block.Blocks; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.network.NetworkDirection; +import net.minecraftforge.fml.network.NetworkEvent; + +import java.io.Serializable; + +public class CPlayerMultiJumpPacket implements Serializable { + public void handle(final NetworkEvent.Context ctx) { + if (!ctx.getDirection().equals(NetworkDirection.PLAY_TO_SERVER)) return; + ServerPlayerEntity player = ctx.getSender(); + if(player == null) return; + ItemStack boots = player.getItemStackFromSlot(EquipmentSlotType.FEET); + if(!boots.getItem().equals(ItemInit.SANDALS)) return; + BlockPos pos = new BlockPos(player.getPositionVec()); + if (pos.getY() > 255 || pos.getY() < 0) return; + if (!player.world.isAirBlock(pos)) return; + boolean shouldJump = player.isCreative(); + if (!shouldJump) for (ItemStack stack : player.inventory.mainInventory) { + if (stack.getItem().equals(Items.SAND)) { + int slot = player.inventory.getSlotFor(stack); + stack.shrink(1); + player.inventory.setInventorySlotContents(slot, stack); + shouldJump = true; + break; + } + } + if (!shouldJump) for (ItemStack stack : player.inventory.offHandInventory) { + if (stack.getItem().equals(Items.SAND)) { + int slot = player.inventory.getSlotFor(stack); + stack.shrink(1); + player.inventory.setInventorySlotContents(slot, stack); + shouldJump = true; + break; + } + } + if (!shouldJump) for (ItemStack stack : player.inventory.armorInventory) { + if (stack.getItem().equals(Items.SAND)) { + int slot = player.inventory.getSlotFor(stack); + stack.shrink(1); + player.inventory.setInventorySlotContents(slot, stack); + shouldJump = true; + break; + } + } + if (shouldJump) { + player.world.setBlockState(pos, Blocks.SAND.getDefaultState(), 3); + player.jump(); + player.setMotion(player.getMotion().add(0,1,0)); + } + } +} diff --git a/src/main/java/com/northwestwind/moreboots/init/ItemInit.java b/src/main/java/com/northwestwind/moreboots/init/ItemInit.java index 2bd6ee4..f133eb1 100644 --- a/src/main/java/com/northwestwind/moreboots/init/ItemInit.java +++ b/src/main/java/com/northwestwind/moreboots/init/ItemInit.java @@ -60,12 +60,13 @@ public class ItemInit { public static final Item GLASS_BOOTS_EMPTY = registerBoots(ModArmorMaterial.GLASS_EMPTY, "glass_boots_empty"); public static final Item FLOATIE_BOOTS = registerBoots(ModArmorMaterial.FLOATIE, "floatie_boots", true); public static final Item STRIDER_BOOTS = registerBoots(ModArmorMaterial.STRIDER, "strider_boots", true); + public static final Item SANDALS = registerBoots(ModArmorMaterial.SAND, "sand_boots"); //public static final Item SNIPER_BOOTS = registerBoots(ModArmorMaterial.SNIPER, "sniper_boots"); - public static final Item QUARTZ_INGOT = new ItemBase(new Item.Properties().group(MoreBoots.MoreBootsItemGroup.INSTANCE), "quartz_ingot").setRegistryName("quartz_ingot"); - public static final Item METAL_MIX = new ItemBase(new Item.Properties().group(MoreBoots.MoreBootsItemGroup.INSTANCE), "metal_mix").setRegistryName("metal_mix"); - public static final Item BAT_HIDE = new ItemBase(new Item.Properties().group(MoreBoots.MoreBootsItemGroup.INSTANCE), "bat_hide").setRegistryName("bat_hide"); - public static final Item STRIDER_FOOT = new ItemBase(new Item.Properties().group(MoreBoots.MoreBootsItemGroup.INSTANCE), "strider_foot").setRegistryName("strider_foot"); + public static final Item QUARTZ_INGOT = new ItemBase("quartz_ingot"); + public static final Item METAL_MIX = new ItemBase("metal_mix"); + public static final Item BAT_HIDE = new ItemBase("bat_hide"); + public static final Item STRIDER_FOOT = new ItemBase("strider_foot"); //public static final Item CROSSBOW = new SniperCrossbowItem().setRegistryName("minecraft", "crossbow"); @@ -105,6 +106,7 @@ public static void registerItems(final RegistryEvent.Register event) { event.getRegistry().register(GLASS_BOOTS_EMPTY); event.getRegistry().register(FLOATIE_BOOTS); event.getRegistry().register(STRIDER_BOOTS); + event.getRegistry().register(SANDALS); //event.getRegistry().register(SNIPER_BOOTS); event.getRegistry().register(QUARTZ_INGOT); @@ -188,7 +190,8 @@ public enum ModArmorMaterial implements IArmorMaterial { GLASS(Reference.MODID + ":glass", 10, new int[] { 4, 1, 1, 1 }, 20, SoundEvents.BLOCK_GLASS_BREAK, 0.0f, 0.0f, () -> Ingredient.fromItems(Items.GLASS)), SNIPER(Reference.MODID + ":sniper", 8, new int[] { 2, 1, 1, 1 }, 12, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0.0f, 0.0f, 90000, () -> Ingredient.fromItems(Items.TIPPED_ARROW)), FLOATIE(Reference.MODID + ":floatie", 40, new int[] { 4, 1, 1, 1 }, 15, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 1.0f, 0.0f, 160000, () -> Ingredient.fromItems(Items.field_234759_km_)), - STRIDER(Reference.MODID + ":strider", 40, new int[] { 4, 1, 1, 1 }, 15, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 1.0f, 0.0f, 160000, () -> Ingredient.fromItems(ItemInit.STRIDER_FOOT)); + STRIDER(Reference.MODID + ":strider", 40, new int[] { 4, 1, 1, 1 }, 15, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 1.0f, 0.0f, 160000, () -> Ingredient.fromItems(ItemInit.STRIDER_FOOT)), + SAND(Reference.MODID + ":sand", 18, new int[] { 2, 1, 1, 1 }, 8, SoundEvents.BLOCK_SAND_PLACE, 0.0f, 0.0f, 40000, () -> Ingredient.fromItems(Items.SAND)); private static final int[] MAX_DAMAGE_ARRAY = new int[] { 16, 16, 16, 16 }; private final String name; private final float maxDamageFactor; diff --git a/src/main/java/com/northwestwind/moreboots/init/item/ArmorItemBase.java b/src/main/java/com/northwestwind/moreboots/init/item/ArmorItemBase.java index 2aa69c3..c1d8839 100644 --- a/src/main/java/com/northwestwind/moreboots/init/item/ArmorItemBase.java +++ b/src/main/java/com/northwestwind/moreboots/init/item/ArmorItemBase.java @@ -41,10 +41,6 @@ public ArmorItemBase(IArmorMaterial material, String registryName, boolean isNet this.registryName = registryName; } - public ArmorItemBase(IArmorMaterial material, String registryName) { - this(material, registryName, false); - } - @Override @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { diff --git a/src/main/java/com/northwestwind/moreboots/init/item/ItemBase.java b/src/main/java/com/northwestwind/moreboots/init/item/ItemBase.java index 23034dd..062cb1e 100644 --- a/src/main/java/com/northwestwind/moreboots/init/item/ItemBase.java +++ b/src/main/java/com/northwestwind/moreboots/init/item/ItemBase.java @@ -1,5 +1,7 @@ package com.northwestwind.moreboots.init.item; +import com.northwestwind.moreboots.MoreBoots; +import com.northwestwind.moreboots.Reference; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; @@ -18,9 +20,14 @@ public class ItemBase extends Item { private String registryName; - public ItemBase(Properties p_i48487_1_, String registryName) { - super(p_i48487_1_); + public ItemBase(Properties properties, String registryName) { + super(properties); this.registryName = registryName; + setRegistryName(Reference.MODID, registryName); + } + + public ItemBase(String registryName) { + this(new Item.Properties().group(MoreBoots.MoreBootsItemGroup.INSTANCE), registryName); } @Override diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 70dd0c4..fd42b1c 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -5,7 +5,7 @@ issueTrackerURL="https://github.com/North-West-Wind/MoreBoots/issues" [[mods]] modId="moreboots" -version="1.5.0" +version="1.6.0" displayName="More Boots" updateJSONURL="https://github.com/North-West-Wind/MoreBoots/raw/main/update.json" displayURL="https://github.com/North-West-Wind/MoreBoots" diff --git a/src/main/resources/assets/moreboots/lang/en_us.json b/src/main/resources/assets/moreboots/lang/en_us.json index 96c9cee..e03c6fb 100644 --- a/src/main/resources/assets/moreboots/lang/en_us.json +++ b/src/main/resources/assets/moreboots/lang/en_us.json @@ -37,6 +37,7 @@ "item.moreboots.glass_boots": "Glass Boots", "item.moreboots.floatie_boots": "Floatie Boots", "item.moreboots.strider_boots": "Strider Boots", + "item.moreboots.sand_boots": "SANDals", "item.moreboots.quartz_ingot": "Quartz Ingot", "item.moreboots.metal_mix": "Metal Mix", @@ -91,6 +92,7 @@ "tooltip.moreboots.glass_boots": "\u00A77\u00A7oActs like potions but on feet", "tooltip.moreboots.floatie_boots": "\u00A77\u00A7oFloats on water", "tooltip.moreboots.strider_boots": "\u00A77\u00A7oWalks on lava", + "tooltip.moreboots.sand_boots": "\u00A77\u00A7oAllows multi-jumping", "itemGroup.morebootstab": "More Boots", "death.attack.stomp": "%1$s was stomped by %2$s", @@ -168,7 +170,8 @@ "advancements.moreboots.floatie_boots.description": "Obtain the Floatie Boots", "advancements.moreboots.strider_boots.title": "I Need Lava", "advancements.moreboots.strider_boots.description": "Obtain the Strider Boots", - + "advancements.moreboots.sand_boots.title": "Jumping 2368 Times", + "advancements.moreboots.sand_boots.description": "Obtain the SANDals", "key.categories.moreboots": "More Boots", "key.moreboots.teleport": "Ender Boots Teleport" diff --git a/src/main/resources/assets/moreboots/models/item/sand_boots.json b/src/main/resources/assets/moreboots/models/item/sand_boots.json new file mode 100644 index 0000000..29dd70e --- /dev/null +++ b/src/main/resources/assets/moreboots/models/item/sand_boots.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "moreboots:items/sand_boots" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/moreboots/textures/items/sand_boots.png b/src/main/resources/assets/moreboots/textures/items/sand_boots.png new file mode 100644 index 0000000000000000000000000000000000000000..78345aa42f1ee337f51508545446918109f685d0 GIT binary patch literal 1532 zcmbVMOKjXk7Z=a6MLFSla8dA zrYXs)q^bf#2Z4dv zL^*e92=s7)i#L;CsNBO62}nqyEM-`wz{Xvg(X>ndhPpU@NC6A2>lQlpwIvJ-6=}A7 zfw?gb$iC>bxfK&>m85ht!DRUYGxKQfO$_aXpo}I>N`uKoH6|tl+s-e>1jo+$kw<&! zD|=*!gEC_As;nx4%wD}In^2RXt{;~xP?kqfmwJACYhP#u&S?)pS=M+cL;ni)Fl^H# zM9gPDL>(f$6BS)(sfeh$j4DXR6M2W?%{&Vx^4|ZH ze=G4>6{6sgdGgxK(+Af4lwIuBxO&cz^W$0IgJH%%g!4+Uc$}vI@%Zt!|Hu&-(e}E8 zk^Vzoj9@8kXFZgVr4EbMe@Q)w*)Qc~J90((tCz#GJtaPYv%Zl}i-yG(Mav@*>vIWf zXdli0{3~mQ@70~9X5|_D$L{W8>7@_R9j;lbe(Rk6eQ{c=PTiPYDOJm#eShxVFF!pd zU7fmh*L$vU?~_ZvUEKAn<;%C9-Ja&Ie0T4i*&n%`n;#!W<=ZnCf4Fq*)$N~lcB<#$ z4gPDlYSgCNm9Gw-zJ57)eQoLv_u|4Yk4=}>ufAV;>Ur?_lCs`?nQ((abZg;*BX8&Z NxxT#Od~tGp`%iF2;&=c6 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/moreboots/textures/models/armor/sand_layer_1.png b/src/main/resources/assets/moreboots/textures/models/armor/sand_layer_1.png new file mode 100644 index 0000000000000000000000000000000000000000..6579c020a9d5cc2d269082256e72c61b7d601873 GIT binary patch literal 2194 zcmbVO3sBQ$91kj>sEE4x!eI=|xx+ST+5(M~SIeM6ks)_J7;2iNZAP19Nr1w+ir_Ye z=X9Ps)J-;D=XC1WiH}XU;p8^BQ*d)A8xzr;o_B(e!#N%5_615$J#?PECi(Jxzwh_| z{U6`IeLp)ZZFI<#5D0=sThh%r;F$z2cz6)FZ{6%&2_7Sa^o0@xjU2CB0nnyTCP7eO z7n{34USQ26DBi6mY2L=DJ#GP@At*l4Bal=9Bf~bv!E#3A`jPJun5B)#e7zO33MR(M zrk9G$ywa>(sq1dhYL4+5--w4KN?zvirtsH753COs-niX31tGZH1Tg3R(9tT2)` zzECzIKxw}VZoyB>Nxm?FfT12zKs9Piaj6eTQ+}LKD7yNL(-g|M7&pVo62NNwSi#B5 zyyWDcK=2EMvn%s^-jgvJn! z#Ss|R54G|%YcClLs?$FX1yw_nGWow?nj-AH=q7>BtebQ&sK7Z8*dIy4#JhMA7zXOJ z56@dnrfiY7vo5e8<)o#+mQ+)W#t;*u!qu8SxmGJ-;Ut;lD8^zoA|O6$mZb?TMq)Hc z=~OgD(<+-mr%~DLxLt+o3^Y#K!K&6iu;0v6g-R6+?5DwgN~^cwv@KR;*J6~4vgvdx z8yTlp;d)A^V`4RS3bzgHpDVK96q2sz=26b3Qa(gFD}lt8_)gC}<}KgI#ln3RLy(km z5{w9?lmJ5`zG-%l2t1ny{j|kS29Q3bF8W~-ZY~J z@A(P?zX?M!E#~B0XUC<5C+9R^Vb^*q%Rh4@$9vWWj=h(hI=9?&15Q}=!r1jSy+Lok zTQgzFEBFfjZc*c!9p`izA;;|m`|(|Tb2OZTzfApUEDB}&idAD1>rN(aC z!ennFG9)K|*Z$>25Sk>SCe_r2t> zVUQ*kI=Xj8K@2%Fe>Ok2J5y~5=aCs*W4BW5fa73K-*_^EW=@cQ7A`lV~SHbm40 zRc@TwGw#!heSe=E0-eqag0`o%=ik@2Uaq`gYFpb3LG@7?Wr>x4HK#edYOl4FIWKIV zu$*VTn~n#RU8X|ImVGxmasae+zpn?3fHWr