From 7879957e0de8392ed643b79b7740a99369a045ac Mon Sep 17 00:00:00 2001 From: Rin Date: Mon, 10 Jun 2024 00:25:54 -0500 Subject: [PATCH] 7.1_01 --- gradle.properties | 6 +- .../java/mizurin/shieldmod/IThrownItem.java | 9 +++ .../java/mizurin/shieldmod/ShieldMod.java | 6 ++ .../mizurin/shieldmod/item/EntityShield.java | 68 ++++++++++++++++++ .../mizurin/shieldmod/item/LightShield.java | 25 +++++++ .../mizurin/shieldmod/item/ShieldColored.java | 16 +++++ .../mizurin/shieldmod/item/ShieldItem.java | 1 + .../shieldmod/item/ShieldMaterials.java | 1 + .../java/mizurin/shieldmod/item/Shields.java | 5 +- .../mizurin/shieldmod/item/ThrowShield.java | 43 +++++++++++ .../shieldmod/mixins/BlockFarmlandMixin.java | 24 +++++++ .../mizurin/shieldmod/mixins/FieldMixin.java | 55 ++++++++++++++ .../mizurin/shieldmod/mixins/ItemMixin.java | 4 +- .../mizurin/shieldmod/mixins/ShieldMixin.java | 8 ++- .../mixins/WorldFeatureLabyrinthMixin.java | 27 +++++++ src/main/java/mizurin/shieldmod/recipes.java | 2 + .../shieldmod/item/ammotearstone_shield.png | Bin 0 -> 263 bytes .../assets/shieldmod/item/diamond_shield.png | Bin 394 -> 362 bytes .../assets/shieldmod/item/gold_shield.png | Bin 378 -> 340 bytes .../assets/shieldmod/item/iron_shield.png | Bin 367 -> 345 bytes .../shieldmod/item/tearstone_shield.png | Bin 0 -> 486 bytes src/main/resources/lang/shieldmod/en_US.lang | 6 +- src/main/resources/shieldmod.mixins.json | 5 +- 23 files changed, 300 insertions(+), 11 deletions(-) create mode 100644 src/main/java/mizurin/shieldmod/IThrownItem.java create mode 100644 src/main/java/mizurin/shieldmod/item/EntityShield.java create mode 100644 src/main/java/mizurin/shieldmod/item/LightShield.java create mode 100644 src/main/java/mizurin/shieldmod/item/ThrowShield.java create mode 100644 src/main/java/mizurin/shieldmod/mixins/BlockFarmlandMixin.java create mode 100644 src/main/java/mizurin/shieldmod/mixins/FieldMixin.java create mode 100644 src/main/java/mizurin/shieldmod/mixins/WorldFeatureLabyrinthMixin.java create mode 100644 src/main/resources/assets/shieldmod/item/ammotearstone_shield.png create mode 100644 src/main/resources/assets/shieldmod/item/tearstone_shield.png diff --git a/gradle.properties b/gradle.properties index 01068a2..6626c2d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,17 @@ org.gradle.jvmargs=-Xmx2G # BTA -bta_version=7.1 +bta_version=7.1_01 # Loader loader_version=0.15.6-babric.5-bta # HalpLibe -halplibe_version=3.5.2 +halplibe_version=3.5.4 prismatic_version=3.1.2-7.1 # Mod -mod_version=1.1.4 +mod_version=1.0.6 mod_group=Mizuri-n mod_name=Better with Defense diff --git a/src/main/java/mizurin/shieldmod/IThrownItem.java b/src/main/java/mizurin/shieldmod/IThrownItem.java new file mode 100644 index 0000000..24c4cf3 --- /dev/null +++ b/src/main/java/mizurin/shieldmod/IThrownItem.java @@ -0,0 +1,9 @@ +package mizurin.shieldmod; + +import net.minecraft.core.item.Item; +import net.minecraft.core.item.ItemStack; + +public interface IThrownItem { +public ItemStack getThrownItem(); +public ItemStack setThrownItem(ItemStack itemStack); +} diff --git a/src/main/java/mizurin/shieldmod/ShieldMod.java b/src/main/java/mizurin/shieldmod/ShieldMod.java index 3f7afff..5a24190 100644 --- a/src/main/java/mizurin/shieldmod/ShieldMod.java +++ b/src/main/java/mizurin/shieldmod/ShieldMod.java @@ -1,11 +1,16 @@ package mizurin.shieldmod; +import mizurin.shieldmod.item.EntityShield; import net.fabricmc.api.ModInitializer; +import net.minecraft.client.render.entity.SnowballRenderer; import net.minecraft.core.crafting.LookupFuelFurnace; import net.minecraft.core.data.registry.Registries; +import net.minecraft.core.entity.projectile.EntitySnowball; +import net.minecraft.core.item.Item; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import turniplabs.halplibe.helper.AchievementHelper; +import turniplabs.halplibe.helper.EntityHelper; import turniplabs.halplibe.util.ConfigHandler; import turniplabs.halplibe.util.GameStartEntrypoint; import mizurin.shieldmod.item.Shields; @@ -39,6 +44,7 @@ public void beforeGameStart() { //AchievementPage SHIELDACHIEVEMENTS; //SHIELDACHIEVEMENTS = new ShieldAchievements(); AchievementHelper.addPage(new ShieldAchievements()); + EntityHelper.Client.assignEntityRenderer(EntityShield.class, new SnowballRenderer(Shields.ammotearShield.getIconFromDamage(0))); } diff --git a/src/main/java/mizurin/shieldmod/item/EntityShield.java b/src/main/java/mizurin/shieldmod/item/EntityShield.java new file mode 100644 index 0000000..b6606d9 --- /dev/null +++ b/src/main/java/mizurin/shieldmod/item/EntityShield.java @@ -0,0 +1,68 @@ +package mizurin.shieldmod.item; + +import mizurin.shieldmod.IThrownItem; +import net.minecraft.core.HitResult; +import net.minecraft.core.entity.Entity; +import net.minecraft.core.entity.EntityLiving; +import net.minecraft.core.entity.player.EntityPlayer; +import net.minecraft.core.entity.projectile.EntityPebble; +import net.minecraft.core.item.Item; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.player.inventory.InventoryPlayer; +import net.minecraft.core.util.helper.DamageType; +import net.minecraft.core.world.World; + +public class EntityShield extends EntityPebble { + public EntityShield(World world) { + super(world); + this.modelItem = Item.ammoSnowball; + this.setSize(0.9F, 0.9F); + } + + public EntityShield(World world, EntityLiving entityliving) { + super(world, entityliving); + this.modelItem = Item.ammoSnowball; + } + + public EntityShield(World world, double d, double d1, double d2) { + super(world, d, d1, d2); + this.modelItem = Item.ammoSnowball; + } + + public void init() { + super.init(); + this.damage = 0; + } + public void storeOrDropItem(EntityPlayer player, ItemStack stack){ + if(stack == null || stack.stackSize <= 0){ + return; + } + InventoryPlayer inventory = player.inventory; + inventory.insertItem(stack, false); + if (stack.stackSize > 0){ + player.dropPlayerItem(stack); + } + } + + + public void onHit(HitResult hitResult) { + damage = ticksInAir /3 + 3; + if (damage > 14){ + damage = 14; + } + if (hitResult.entity != null) { + hitResult.entity.hurt(this.owner, this.damage, DamageType.COMBAT); + //hitResult.entity.push(this.xd * 0.2, 0, this.zd * 0.2); + } + if (!this.world.isClientSide) { + this.world.playSoundAtEntity((Entity) null, this, "mob.ghast.fireball", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); + } + if (this.modelItem != null) { + for(int j = 0; j < 8; ++j) { + this.world.spawnParticle("item", this.x, this.y, this.z, (double)this.modelItem.id, 0.0, 0.0); + } + } + this.remove(); + storeOrDropItem((EntityPlayer) owner, ((IThrownItem)owner).getThrownItem()); + } + } diff --git a/src/main/java/mizurin/shieldmod/item/LightShield.java b/src/main/java/mizurin/shieldmod/item/LightShield.java new file mode 100644 index 0000000..731cb89 --- /dev/null +++ b/src/main/java/mizurin/shieldmod/item/LightShield.java @@ -0,0 +1,25 @@ +package mizurin.shieldmod.item; +import net.minecraft.core.entity.Entity; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.item.material.ToolMaterial; +import net.minecraft.core.world.World; + +public class LightShield extends ShieldItem{ + public LightShield(String name, int id, ToolMaterial toolMaterial) { + super(name, id, toolMaterial); + } + @Override + public void inventoryTick(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { + if(itemstack.getData().getBoolean("active")){ + entity.xd *= 0.65D; + entity.zd *= 0.65D; + int ticks = itemstack.getData().getInteger("ticks"); + + if (ticks > 0){ + itemstack.getData().putInt("ticks", ticks - 1); + } else { + itemstack.getData().putBoolean("active", false); + } + } + } +} diff --git a/src/main/java/mizurin/shieldmod/item/ShieldColored.java b/src/main/java/mizurin/shieldmod/item/ShieldColored.java index 8e86e57..ddb2b54 100644 --- a/src/main/java/mizurin/shieldmod/item/ShieldColored.java +++ b/src/main/java/mizurin/shieldmod/item/ShieldColored.java @@ -2,6 +2,8 @@ import com.mojang.nbt.CompoundTag; import mizurin.shieldmod.ShieldMod; +import net.minecraft.core.entity.Entity; +import net.minecraft.core.world.World; import turniplabs.halplibe.helper.TextureHelper; import net.minecraft.core.item.ItemStack; import net.minecraft.core.item.material.ToolMaterial; @@ -30,5 +32,19 @@ public Color getColor(ItemStack itemStack){ public ColoredTexture[] getTextures(ItemStack itemStack) { return new ColoredTexture[]{new ColoredTexture(baseColor, getColor(itemStack)), new ColoredTexture(overlayShield, getColor(itemStack))}; } + @Override + public void inventoryTick(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { + if(itemstack.getData().getBoolean("active")){ + entity.xd *= 0.65D; + entity.zd *= 0.65D; + int ticks = itemstack.getData().getInteger("ticks"); + + if (ticks > 0){ + itemstack.getData().putInt("ticks", ticks - 1); + } else { + itemstack.getData().putBoolean("active", false); + } + } + } } diff --git a/src/main/java/mizurin/shieldmod/item/ShieldItem.java b/src/main/java/mizurin/shieldmod/item/ShieldItem.java index c88a777..8f22cbf 100644 --- a/src/main/java/mizurin/shieldmod/item/ShieldItem.java +++ b/src/main/java/mizurin/shieldmod/item/ShieldItem.java @@ -23,6 +23,7 @@ public ShieldItem(String name, int id, ToolMaterial toolMaterial){ } + @Override public boolean hitEntity(ItemStack itemstack, EntityLiving target, EntityLiving player) { if(itemstack.getItem() == Shields.leatherShield){ diff --git a/src/main/java/mizurin/shieldmod/item/ShieldMaterials.java b/src/main/java/mizurin/shieldmod/item/ShieldMaterials.java index 51441a8..74cf292 100644 --- a/src/main/java/mizurin/shieldmod/item/ShieldMaterials.java +++ b/src/main/java/mizurin/shieldmod/item/ShieldMaterials.java @@ -18,6 +18,7 @@ public ToolMaterial setGuard(float guard){ public static final ToolMaterial TOOL_GOLD = new ToolMaterial().setDurability(96).setDamage(-1).setEfficiency(2.0f, 0.50f).setSilkTouch(true); public static final ToolMaterial TOOL_DIAMOND = new ToolMaterial().setDurability(1536).setDamage(3).setEfficiency(2.0f, 0.40f); public static final ToolMaterial TOOL_STEEL = new ToolMaterial().setDurability(4608).setDamage(2).setEfficiency(2.0f, 0.60f); + public static final ToolMaterial TOOL_TEAR = new ToolMaterial().setDurability(512).setDamage(1).setEfficiency(2.0F, 0.60F); @Override public ToolMaterial setEfficiency(float efficiency, float guard) { diff --git a/src/main/java/mizurin/shieldmod/item/Shields.java b/src/main/java/mizurin/shieldmod/item/Shields.java index 269618a..d6815a9 100644 --- a/src/main/java/mizurin/shieldmod/item/Shields.java +++ b/src/main/java/mizurin/shieldmod/item/Shields.java @@ -12,19 +12,20 @@ public class Shields { public static final String MOD_ID = ShieldMod.MOD_ID; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - public static final Item woodenShield = ItemHelper.createItem(MOD_ID, new ShieldItem("wooden.shield", ++itemID, ShieldMaterials.TOOL_WOOD),"wooden_shield.png").withTags(ItemTags.preventCreativeMining); + public static final Item woodenShield = ItemHelper.createItem(MOD_ID, new LightShield("wooden.shield", ++itemID, ShieldMaterials.TOOL_WOOD),"wooden_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item stoneShield = ItemHelper.createItem(MOD_ID, new ShieldItem("stone.shield", ++itemID, ShieldMaterials.TOOL_STONE), "stone_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item ironShield = ItemHelper.createItem(MOD_ID, new ShieldItem("iron.shield", ++itemID, ShieldMaterials.TOOL_IRON), "iron_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item goldShield = ItemHelper.createItem(MOD_ID, new ShieldItem("gold.shield", ++itemID, ShieldMaterials.TOOL_GOLD), "gold_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item diamondShield = ItemHelper.createItem(MOD_ID, new ShieldItem("diamond.shield", ++itemID, ShieldMaterials.TOOL_DIAMOND), "diamond_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item steelShield = ItemHelper.createItem(MOD_ID, new ShieldItem("steel.shield", ++itemID, ShieldMaterials.TOOL_STEEL), "steel_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item leatherShield = ItemHelper.createItem(MOD_ID, new ShieldColored("leather.shield", ++itemID, ShieldMaterials.TOOL_LEATHER), "wooden_shield.png").withTags(ItemTags.preventCreativeMining); + public static final Item tearShield = ItemHelper.createItem(MOD_ID, new ThrowShield("tear.shield", ++itemID, ShieldMaterials.TOOL_TEAR), "tearstone_shield.png").withTags(ItemTags.preventCreativeMining); + public static final Item ammotearShield = ItemHelper.createItem(MOD_ID, new Item("tear.shield.ammo", ++itemID), "ammotearstone_shield.png").setNotInCreativeMenu(); public static final Item armorLeatherHelmet = ItemHelper.createItem(MOD_ID, new ArmorColored("Leather Cap", 16426,ArmorMaterial.LEATHER , 0 ), "armor.helmet.leather"); public static final Item armorLeatherChest = ItemHelper.createItem(MOD_ID, new ArmorColored("Leather Tunic", 16427,ArmorMaterial.LEATHER , 1 ), "armor.chestplate.leather"); public static final Item armorLeatherLeg = ItemHelper.createItem(MOD_ID, new ArmorColored("Leather Pants", 16428,ArmorMaterial.LEATHER , 2 ), "armor.leggings.leather"); public static final Item armorLeatherBoot = ItemHelper.createItem(MOD_ID, new ArmorColored("Leather Boots", 16429,ArmorMaterial.LEATHER , 3 ), "armor.boots.leather"); - public void initializeItems(){} } diff --git a/src/main/java/mizurin/shieldmod/item/ThrowShield.java b/src/main/java/mizurin/shieldmod/item/ThrowShield.java new file mode 100644 index 0000000..0fd73ce --- /dev/null +++ b/src/main/java/mizurin/shieldmod/item/ThrowShield.java @@ -0,0 +1,43 @@ +package mizurin.shieldmod.item; + +import mizurin.shieldmod.IThrownItem; +import net.minecraft.core.entity.player.EntityPlayer; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.item.material.ToolMaterial; +import net.minecraft.core.world.World; + +public class ThrowShield extends ShieldItem{ + int ticksToAdd = 5; + + + public ThrowShield(String name, int id, ToolMaterial toolMaterial) { + super(name, id, toolMaterial); + maxStackSize = 1; + setMaxDamage(toolMaterial.getDurability()); + this.tool = toolMaterial; + this.weaponDamage = 4 + toolMaterial.getDamage(); + + } + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + itemstack.getData().putBoolean("active", true); + itemstack.getData().putInt("ticks", ticksToAdd); + onBlock(itemstack, world, entityplayer); + + return itemstack; + } + + public void onBlock(ItemStack itemstack, World world, EntityPlayer entityplayer){ + if (entityplayer.isSneaking()){ + ((IThrownItem)entityplayer).setThrownItem(itemstack); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem,null); + world.playSoundAtEntity(null, entityplayer, "mob.ghast.fireball", 0.3F, 1.0F / (itemRand.nextFloat() * 0.4F + 0.8F)); + if (!world.isClientSide) { + world.entityJoinedWorld(new EntityShield(world, entityplayer)); + itemstack.damageItem(4, entityplayer); + itemstack.getData().putBoolean("active", false); + } + } + } + +} diff --git a/src/main/java/mizurin/shieldmod/mixins/BlockFarmlandMixin.java b/src/main/java/mizurin/shieldmod/mixins/BlockFarmlandMixin.java new file mode 100644 index 0000000..d94d40f --- /dev/null +++ b/src/main/java/mizurin/shieldmod/mixins/BlockFarmlandMixin.java @@ -0,0 +1,24 @@ +package mizurin.shieldmod.mixins; + + +import mizurin.shieldmod.item.Shields; +import net.minecraft.core.block.BlockFarmland; +import net.minecraft.core.item.Item; +import net.minecraft.core.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(value = BlockFarmland.class, remap = false) +public class BlockFarmlandMixin { + @Redirect(method = "onEntityWalking(Lnet/minecraft/core/world/World;IIILnet/minecraft/core/entity/Entity;)V", + at = @At(value = "INVOKE",target = "Lnet/minecraft/core/item/ItemStack;getItem()Lnet/minecraft/core/item/Item;")) + public Item addCustomBoots(ItemStack instance){ + Item item = instance.getItem(); + if (item == Shields.armorLeatherBoot){ + return Item.armorBootsLeather; + } + return item; + } +} + diff --git a/src/main/java/mizurin/shieldmod/mixins/FieldMixin.java b/src/main/java/mizurin/shieldmod/mixins/FieldMixin.java new file mode 100644 index 0000000..e361b18 --- /dev/null +++ b/src/main/java/mizurin/shieldmod/mixins/FieldMixin.java @@ -0,0 +1,55 @@ +package mizurin.shieldmod.mixins; +import com.mojang.nbt.CompoundTag; +import mizurin.shieldmod.IThrownItem; +import net.minecraft.core.entity.player.EntityPlayer; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.player.inventory.InventoryPlayer; +import net.minecraft.core.world.chunk.ChunkCoordinates; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = EntityPlayer.class, remap = false) +public abstract class FieldMixin implements IThrownItem { + @Shadow + public abstract ChunkCoordinates getLastDeathCoordinate(); + + @Unique + private ItemStack thrownItem; + + @Override + public ItemStack getThrownItem() { + return thrownItem; + } + public void storeOrDropItem(EntityPlayer player, ItemStack stack){ + if(stack == null || stack.stackSize <= 0){ + return; + } + InventoryPlayer inventory = player.inventory; + inventory.insertItem(stack, false); + if (stack.stackSize > 0){ + player.dropPlayerItem(stack); + } + } + + @Override + public ItemStack setThrownItem(ItemStack itemStack) { + this.thrownItem = itemStack; + return itemStack; + } + @Inject(method = "addAdditionalSaveData(Lcom/mojang/nbt/CompoundTag;)V", at = @At("TAIL")) + private void addData(CompoundTag tag, CallbackInfo ci){ + ItemStack thrownItem = getThrownItem(); + if(thrownItem != null) { + tag.putCompound("item", thrownItem.writeToNBT(new CompoundTag())); + } + } + @Inject(method = "readAdditionalSaveData(Lcom/mojang/nbt/CompoundTag;)V", at = @At("TAIL")) + private void loadData(CompoundTag tag, CallbackInfo ci){ + this.thrownItem = ItemStack.readItemStackFromNbt(tag.getCompound("item")); + storeOrDropItem((EntityPlayer)(Object)this, this.thrownItem); + } +} diff --git a/src/main/java/mizurin/shieldmod/mixins/ItemMixin.java b/src/main/java/mizurin/shieldmod/mixins/ItemMixin.java index 010802b..4f5a994 100644 --- a/src/main/java/mizurin/shieldmod/mixins/ItemMixin.java +++ b/src/main/java/mizurin/shieldmod/mixins/ItemMixin.java @@ -22,7 +22,7 @@ public ItemMixin(ModelBase model, float shadowSize) { @Shadow private ModelBiped modelBipedMain; - @Inject(method = "renderSpecials", at = @At("HEAD"), cancellable = true) + @Inject(method = "renderSpecials", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/player/inventory/InventoryPlayer;getCurrentItem()Lnet/minecraft/core/item/ItemStack;"), cancellable = true) public void injectRenderer(EntityPlayer entity, float f, CallbackInfo ci) { ItemStack itemstack = entity.inventory.getCurrentItem(); @@ -64,8 +64,6 @@ public void injectRenderer(EntityPlayer entity, float f, CallbackInfo ci) { GL11.glPopMatrix(); ci.cancel(); } - - } } diff --git a/src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java b/src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java index b7c094b..a328902 100644 --- a/src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java +++ b/src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java @@ -1,7 +1,9 @@ package mizurin.shieldmod.mixins; +import mizurin.shieldmod.item.Shields; import net.minecraft.core.achievement.stat.Stat; import net.minecraft.core.entity.Entity; +import net.minecraft.core.entity.EntityLiving; import net.minecraft.core.entity.monster.EntityMonster; import net.minecraft.core.entity.player.EntityPlayer; import net.minecraft.core.entity.projectile.EntityArrow; @@ -26,7 +28,7 @@ // extend Entity so we get access to entity methods and fields. // abstract so we don't have to implement interfaces, constructor is not used but required. -public abstract class ShieldMixin extends Entity { +public abstract class ShieldMixin extends EntityLiving { public ShieldMixin(World world) { super(world); } @@ -41,6 +43,7 @@ public ShieldMixin(World world) { @Shadow public Gamemode gamemode; + @Shadow public abstract ItemStack getHeldItem(); @@ -79,6 +82,9 @@ public void injectHurt(Entity attacker, int damage, DamageType type, CallbackInf World world = attacker.world; if (!this.gamemode.isPlayerInvulnerable()) { + if(shield.tool == ShieldMaterials.TOOL_TEAR && getHealth() <= 6){ + damage = Math.round(damage * 0.5f); + } if (stack.getData().getBoolean("active")) { int newDamage = Math.round(damage * (shield.tool.getEfficiency(true))); diff --git a/src/main/java/mizurin/shieldmod/mixins/WorldFeatureLabyrinthMixin.java b/src/main/java/mizurin/shieldmod/mixins/WorldFeatureLabyrinthMixin.java new file mode 100644 index 0000000..c9c0a97 --- /dev/null +++ b/src/main/java/mizurin/shieldmod/mixins/WorldFeatureLabyrinthMixin.java @@ -0,0 +1,27 @@ +package mizurin.shieldmod.mixins; + +import mizurin.shieldmod.item.Shields; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.world.generate.feature.WorldFeatureLabyrinth; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Random; + +@Mixin(value = WorldFeatureLabyrinth.class, remap = false) +public class WorldFeatureLabyrinthMixin { + @Shadow + private boolean isCold; + + + @Inject(method = "pickCheckLootItem(Ljava/util/Random;)Lnet/minecraft/core/item/ItemStack;", at = @At(value = "FIELD", target = "Lnet/minecraft/core/world/generate/feature/WorldFeatureLabyrinth;treasureGenerated:Z", ordinal = 1, shift = At.Shift.AFTER), cancellable = true) + private void addTreasure(Random random, CallbackInfoReturnable cir) { + if (isCold && random.nextInt(2) == 0) { + cir.setReturnValue(new ItemStack(Shields.tearShield)); + } + } +} diff --git a/src/main/java/mizurin/shieldmod/recipes.java b/src/main/java/mizurin/shieldmod/recipes.java index d628d91..6b02985 100644 --- a/src/main/java/mizurin/shieldmod/recipes.java +++ b/src/main/java/mizurin/shieldmod/recipes.java @@ -7,6 +7,7 @@ import net.minecraft.core.data.registry.recipe.RecipeGroup; import net.minecraft.core.data.registry.recipe.RecipeSymbol; import net.minecraft.core.data.registry.recipe.entry.RecipeEntryCrafting; +import net.minecraft.core.data.registry.recipe.entry.RecipeEntryRepairable; import net.minecraft.core.entity.player.EntityPlayer; import net.minecraft.core.item.ItemStack; import turniplabs.halplibe.util.RecipeEntrypoint; @@ -74,6 +75,7 @@ public void onRecipesReady() { .create("leatherShield", Shields.leatherShield.getDefaultStack()); + WORKBENCH.register("tearstoneShield", new RecipeEntryRepairable(Shields.tearShield, Item.ingotIron)); } public void initializeRecipe(){ Registries.RECIPE_TYPES.register("colored/shield", recipeColor.class); diff --git a/src/main/resources/assets/shieldmod/item/ammotearstone_shield.png b/src/main/resources/assets/shieldmod/item/ammotearstone_shield.png new file mode 100644 index 0000000000000000000000000000000000000000..8ae2d5067a439806d8539788fd84e0803d19bce4 GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5hd`K7RKu$QD7e$p z#WBRfKRH2yRivFkSx@-OoaO(f2Tn>cFf>oA`1{TD@RuUtHCYdvX3l;7&)DEkvVf=< zYqo&!#SX z9_^ppt$kR&O`fOzpP^yQzM|O=zpg&db7xKskA3}LmfdZ$r%!)){kuGm&YCqm#jkZ0 z^$w(d?|G~L@BO{XIS=p4i?P`;*0r_jmRVe#^!{Jq+$)@n3=AL5Zr|84g$L*f22WQ% Jmvv4FO#q9;X_Ei| literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/shieldmod/item/diamond_shield.png b/src/main/resources/assets/shieldmod/item/diamond_shield.png index 81362798a7252b16e5d1692141ba3c87be588221..0a31d87ed87910bde83a513951d8bd221c6a4690 100644 GIT binary patch delta 314 zcmV-A0mc4`1L^{hIe#2UL_t(IPh()95HOP@9o8gYKAlp&K(0YR(tPI5!P>mP{!2JqT@BB{LFANHEQygoHIEf+WE4i!Ui7r9zM^D9%ji$$(@&04+jzzh`fV-T(jq M07*qoM6N<$f~f|E3jhEB delta 346 zcmV-g0j2)x0*V8WIe$D!L_t(I5o2JW5HO)`k9;{Y) z_cmlbaP~7rZ8#fd5DQ!c$^dCrl;A=ahVbuSWq9lA#qjgaL%2NH1u$nz0TsYB%S&*= z6)8$`GTeXuo#Ek&?+o`}e1jVTas}K4G7qmZ$U|*L)(kQQq<YAwxvK?g%tvC3=%3yNHdN2$CITr?g00WBy z8Z+25gVbSo0VD`g9L4a0VOd2Nh|3Vg{{l!t0un5ML|`=l<_cuL!(stRFPI7U!fR(Q za1?=}3Isr|fKwR+;={y2(FltHkT^UgiYAAGlQ6!7gq{XK2Ee@lOI={ofe8v50Lvkz sLXaA`3t$>xsS?IVr(t;jU7Tz_00sAcC&~Z5umAu607*qoM6N<$fJrkI&3Cdl^vlz&XeouiWOwYKD&L zSGYLLAQohmni@I`t2f_gP?X@pYQUA-3=E;ZiVW9pT!G7jT>!EjU9-FdCtQ)DBqziD z=ieC~zWB~?|HU`BAs|=4U4U#evSyGeAk82{U;w06M-{?jLVtHFvgS8mA2EP1%mvu| zg<$~9CXmKit9=++JDnL$-?<6ai|h)RVHgI0oC^c5?|o+wRf0Gjn`V$WN-V%Mf)ziP zW2i3Q3l*Y>wY^dR0000g*0!e5l_7r%kfTyQgtbn_B9E;|-aiuCSAPezos0`cu9kAv6qR$5 z&NG=UGD#O36M+kJ@E;i}AVY)!mvL=ZT@qyWCx5TM1P>js$L9k9o&;jA{~+Dhro2r) zmBYQ00c=owmP%kIztJdOwG4lT8H zXHW`>0zH8(t?$)LqdtUiK=Hl#zHfe2YM_nU{2&PGKFuUa8XP`I;v+j7HD=zL?@4GZ zk-qOMkX^?%KJWn}ZGr=$!*MzuG!eFNEXKK0OXbB=pMlxz_J8=Sk%bl@hlvay$PkfO zDu)HgDI;GhPhW4Bcg~>QoJJ4eq(~sgajc>!Qt@@Jc`^$U>IhJ+0HkTkO*4^!>6E~c zicE!Jr~|F+?EU^VQkG#9pe$tVxVx2~Nl4=oFq*uq7$ipr0+E6Fj#2A0HnF`6?Px?s vZ)g)6CBT9C<{~|-42-nFKU1eE|6aTROs;wEG2ain00000NkvXXu0mjfhn$1P delta 319 zcmV-F0l@y*0`CHlIe#HZL_t(I5v5ZxZo*Iub*nDn1RxbvsEC|_xnblE?8$L*0PfH+ z>D)6U0!0-_Z~`&{&+W6!CooVCKlb~6FLvyR{L`L7ev%}|5c6?amKPigK#b#9bH6^9 zo@4&&WNJQzUJUtjKpypbA*^vzf6K>wAyrk`y;i`ox90?s-+%g%C5;A=G`m)Q_N_Gg zgNdLDtKb$HDj-9IhAP>P3GmXtd3Bg5JbT}$2y^`N*$43XCXkDwkUY<&SPwOgcb;=4 zfO2X0Se#538F^PN0Mz7NEm@W!lyR>;MF;1#TDAv2k67JLd7;Dj>kEWE?*E4}|!`@d@P)H)MF|22qB>ew__m|=9LTKH`)bI&=ybMBq*0wanV zu1{_6sedu^H&+8S#)r8uk=(RpJQf~|eI4X9XQsJ*l&cbog?n2-BDsaglpmLT&WQH` zr2BBO${wNBm9ev%0_EtTEL2du&0tM~kX%hFnZlu?%$-}F1H4y6_*oAWwTqG{AQ%o| z<1pKwj^yex0Qv@ZoW=BP1fT6D*dU9qjtog^LKH>Fa?5hGfjc14nk0Y?F<4!X!sqiq zD2ZsxGHQx~Mx$W?SSE;s!idEe5eWNHsS2Pd3N%f_>2Sd7_5KeSQyBy%{fMtD;9KcH zYJ7lp(O{SfxV3dymI*Q^XUJXf7^hr_EiJ>%xS{lV=xIlI%b)&!2gD?4jstiech?=f zJilUQE{gf3C@S?j%1`J0Vou93`(VI{#DT;pyauroDJH*=G_!T0ZdKwqJDEG{@sS_X ch>scg0Y%uL$MMAv0RR9107*qoM6N<$f?G<{QUCw| literal 0 HcmV?d00001 diff --git a/src/main/resources/lang/shieldmod/en_US.lang b/src/main/resources/lang/shieldmod/en_US.lang index 147cb73..11fd187 100644 --- a/src/main/resources/lang/shieldmod/en_US.lang +++ b/src/main/resources/lang/shieldmod/en_US.lang @@ -12,6 +12,10 @@ item.shieldmod.diamond.shield.name=Diamond Shield item.shieldmod.diamond.shield.desc=A rare and pretty shield. item.shieldmod.steel.shield.name=Steel Shield item.shieldmod.steel.shield.desc=A tool to block and set enemies on fire. + +item.shieldmod.tear.shield.name=Tearstone Shield +item.shieldmod.tear.shield.desc=Bolsters defense when close to death + item.shieldmod.armor.helmet.leather.name=Leather Cap item.shieldmod.armor.helmet.leather.desc=A hat made from a cow's hide item.shieldmod.armor.chestplate.leather.name=Leather Tunic @@ -23,7 +27,7 @@ item.shieldmod.armor.boots.leather.desc=A pair of boots made from a cow's hide -achievements.page.defense.desc=BWD achievements +achievements.page.defense.desc=BWD achievements WIP achievement.shieldmod.block=Block Blocked achievement.shieldmod.block.desc=Block an attack achievement.shieldmod.shield.got=Time to Defend! diff --git a/src/main/resources/shieldmod.mixins.json b/src/main/resources/shieldmod.mixins.json index 5b3a557..121c26f 100644 --- a/src/main/resources/shieldmod.mixins.json +++ b/src/main/resources/shieldmod.mixins.json @@ -4,8 +4,11 @@ "package": "mizurin.shieldmod.mixins", "compatibilityLevel": "JAVA_8", "mixins": [ + "BlockFarmlandMixin", + "FieldMixin", "ItemMixin", - "ShieldMixin" + "ShieldMixin", + "WorldFeatureLabyrinthMixin" ], "client": [ ],