From ae098b0fe3b03962a192af519c43d9ac4d5afd27 Mon Sep 17 00:00:00 2001 From: "[Corbin Ray]" Date: Sun, 31 Mar 2024 04:50:41 -0500 Subject: [PATCH] large update --- build.gradle | 10 ++ gradle.properties | 2 + .../mizurin/shieldmod/ShieldAchievements.java | 45 ++++++ .../java/mizurin/shieldmod/ShieldMod.java | 5 + .../mizurin/shieldmod/item/ShieldColored.java | 33 +++++ .../mizurin/shieldmod/item/ShieldItem.java | 13 +- .../shieldmod/item/ShieldMaterials.java | 3 +- .../java/mizurin/shieldmod/item/Shields.java | 8 +- .../mizurin/shieldmod/mixins/ItemMixin.java | 4 + .../mizurin/shieldmod/mixins/ShieldMixin.java | 32 +++- .../java/mizurin/shieldmod/recipeColor.java | 138 ++++++++++++++++++ src/main/java/mizurin/shieldmod/recipes.java | 13 ++ .../assets/shieldmod/item/colored.png | Bin 0 -> 540 bytes .../assets/shieldmod/item/outline.png | Bin 0 -> 347 bytes src/main/resources/lang/shieldmod/en_US.lang | 27 +++- 15 files changed, 314 insertions(+), 19 deletions(-) create mode 100644 src/main/java/mizurin/shieldmod/ShieldAchievements.java create mode 100644 src/main/java/mizurin/shieldmod/item/ShieldColored.java create mode 100644 src/main/java/mizurin/shieldmod/recipeColor.java create mode 100644 src/main/resources/assets/shieldmod/item/colored.png create mode 100644 src/main/resources/assets/shieldmod/item/outline.png diff --git a/build.gradle b/build.gradle index cd982b4..1b029f8 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,14 @@ repositories { name = 'Fabric' url = 'https://maven.fabricmc.net/' } + ivy { + url = "https://github.com/UselessSolutions" + patternLayout { + artifact "[organisation]/releases/download/v[revision]/[module]-[revision].jar" + m2compatible = true + } + metadataSources { artifact() } + } ivy { url = "https://github.com/Better-than-Adventure" patternLayout { @@ -85,6 +93,8 @@ dependencies { // If you do not need Halplibe you can comment this line out or delete this line modImplementation "com.github.Turnip-Labs:bta-halplibe:${project.halplibe_version}" + modImplementation "BTA_Babric_PrismaticLibe:prismaticlibe:${project.prismatic_version}" + modImplementation "ModMenu:ModMenu:2.0.4" implementation "org.slf4j:slf4j-api:1.8.0-beta4" diff --git a/gradle.properties b/gradle.properties index a1dc4ab..8c202eb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,8 @@ loader_version=0.14.19-babric.3-bta # HalpLibe halplibe_version=3.5.1 +prismatic_version=3.0.3-7.1 + # Mod mod_version=1.0.2 mod_group=Mizuri-n diff --git a/src/main/java/mizurin/shieldmod/ShieldAchievements.java b/src/main/java/mizurin/shieldmod/ShieldAchievements.java new file mode 100644 index 0000000..8032aa3 --- /dev/null +++ b/src/main/java/mizurin/shieldmod/ShieldAchievements.java @@ -0,0 +1,45 @@ +package mizurin.shieldmod; +import net.minecraft.client.render.TextureFX; +import net.minecraft.core.Global; +import net.minecraft.core.achievement.Achievement; +import net.minecraft.core.achievement.AchievementList; +import net.minecraft.core.achievement.stat.Stat; +import net.minecraft.core.block.Block; +import net.minecraft.core.util.helper.Side; +import org.lwjgl.opengl.GL11; +import turniplabs.halplibe.util.achievements.AchievementPage; +import turniplabs.halplibe.util.achievements.GuiAchievements; + +import java.util.Random; + +public class ShieldAchievements extends AchievementPage { + public static final Achievement SHIELD_GOT = new Achievement(AchievementList.achievementList.size() + 1, "shieldmod.shield.got", 0, 0, Block.cobbleStone, null); + public static final Achievement BLOCK = new Achievement(AchievementList.achievementList.size() + 1, "shieldmod.block", 2, 1, Block.brickStone, SHIELD_GOT); + public static final Achievement MODERN_AGE = new Achievement(AchievementList.achievementList.size() + 1, "shieldmod.modern.age", 2, 0, Block.blockSteel, SHIELD_GOT); + public static final Achievement FLY_HIGH = new Achievement(AchievementList.achievementList.size() + 1, "shieldmod.fly.high", 2, 2, Block.wool, BLOCK); + public static final Achievement GOLD_RETAL = new Achievement(AchievementList.achievementList.size() + 1, "shieldmod.gold.retal", 3, 2, Block.blockGold, BLOCK); + public ShieldAchievements(){ + super("Better with defense", "achievements.page.defense"); + ((Stat) BLOCK).registerStat(); + achievementList.add(SHIELD_GOT); + achievementList.add(BLOCK); + achievementList.add(MODERN_AGE); + achievementList.add(FLY_HIGH); + achievementList.add(GOLD_RETAL); + } + @Override + public void getBackground(GuiAchievements guiAchievements, Random random, int iOffset, int jOffset, int blockX1, int blockY1, int blockX2, int blockY2) { + int l7 = 0; + while (l7 * 16 - blockY2 < 155) { + float f5 = 0.6f - (float)(blockY1 + l7) / 25.0f * 0.3f; + GL11.glColor4f(f5, f5, f5, 1.0f); + int i8 = 0; + while (i8 * 16 - blockX2 < 224) { + int k8 = Block.cobbleStone.getBlockTextureFromSideAndMetadata(Side.BOTTOM,0); + guiAchievements.drawTexturedModalRect(iOffset + i8 * 16 - blockX2, jOffset + l7 * 16 - blockY2, k8 % Global.TEXTURE_ATLAS_WIDTH_TILES * TextureFX.tileWidthTerrain, k8 / Global.TEXTURE_ATLAS_WIDTH_TILES * TextureFX.tileWidthTerrain, 16, 16, TextureFX.tileWidthTerrain, 1.0f / (float)(Global.TEXTURE_ATLAS_WIDTH_TILES * TextureFX.tileWidthTerrain)); + ++i8; + } + ++l7; + } + } +} diff --git a/src/main/java/mizurin/shieldmod/ShieldMod.java b/src/main/java/mizurin/shieldmod/ShieldMod.java index 03652d2..ca920df 100644 --- a/src/main/java/mizurin/shieldmod/ShieldMod.java +++ b/src/main/java/mizurin/shieldmod/ShieldMod.java @@ -4,8 +4,10 @@ import net.minecraft.core.crafting.LookupFuelFurnace; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import turniplabs.halplibe.helper.AchievementHelper; import turniplabs.halplibe.util.GameStartEntrypoint; import mizurin.shieldmod.item.Shields; +import turniplabs.halplibe.util.achievements.AchievementPage; public class ShieldMod implements ModInitializer, GameStartEntrypoint { public static final String MOD_ID = "shieldmod"; @@ -21,6 +23,9 @@ public void onInitialize() { @Override public void beforeGameStart() { new Shields().initializeItems(); + AchievementPage SHIELDACHIEVEMENTS; + SHIELDACHIEVEMENTS = new ShieldAchievements(); + AchievementHelper.addPage(SHIELDACHIEVEMENTS); } diff --git a/src/main/java/mizurin/shieldmod/item/ShieldColored.java b/src/main/java/mizurin/shieldmod/item/ShieldColored.java new file mode 100644 index 0000000..32aef4c --- /dev/null +++ b/src/main/java/mizurin/shieldmod/item/ShieldColored.java @@ -0,0 +1,33 @@ +package mizurin.shieldmod.item; + +import com.mojang.nbt.CompoundTag; +import mizurin.shieldmod.ShieldMod; +import turniplabs.halplibe.helper.TextureHelper; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.item.material.ToolMaterial; +import useless.prismaticlibe.ColoredTexture; +import useless.prismaticlibe.IColored; +import java.awt.*; + +public class ShieldColored extends ShieldItem implements IColored { + public static final String MOD_ID = ShieldMod.MOD_ID; + public static final int[] baseColor = TextureHelper.getOrCreateItemTexture(ShieldMod.MOD_ID, "colored.png"); + public static final int[] overlayShield = TextureHelper.getOrCreateItemTexture(ShieldMod.MOD_ID, "outline.png"); + public ShieldColored(String name, int id, ToolMaterial toolMaterial) { + super(name, id, toolMaterial); + } + public Color getColor(ItemStack itemStack){ + if (itemStack.getData().containsKey("dyed_color")){ + CompoundTag colorTag = itemStack.getData().getCompound("dyed_color"); + int red = colorTag.getShort("red"); + int green = colorTag.getShort("green"); + int blue = colorTag.getShort("blue"); + return new Color(red, green, blue); + } + return new Color(255, 255,255); + } + @Override + public ColoredTexture[] getTextures(ItemStack itemStack) { + return new ColoredTexture[]{new ColoredTexture(baseColor, getColor(itemStack)), new ColoredTexture(overlayShield, getColor(itemStack))}; + } +} diff --git a/src/main/java/mizurin/shieldmod/item/ShieldItem.java b/src/main/java/mizurin/shieldmod/item/ShieldItem.java index 0f1579a..6bbf51f 100644 --- a/src/main/java/mizurin/shieldmod/item/ShieldItem.java +++ b/src/main/java/mizurin/shieldmod/item/ShieldItem.java @@ -1,5 +1,7 @@ package mizurin.shieldmod.item; +import mizurin.shieldmod.ShieldAchievements; +import net.minecraft.client.Minecraft; import net.minecraft.core.entity.Entity; import net.minecraft.core.entity.EntityLiving; import net.minecraft.core.entity.player.EntityPlayer; @@ -25,13 +27,12 @@ public ShieldItem(String name, int id, ToolMaterial toolMaterial){ } @Override public boolean hitEntity(ItemStack itemstack, EntityLiving target, EntityLiving player) { - if(itemstack.getItem() == Shields.goldShield){ + if(itemstack.getItem() == Shields.leatherShield){ target.knockBack(player, 1, (player.x - target.x), (player.z - target.z )); target.push((target.x - player.x)/7, 0, (target.z - player.z)/7); } else { target.knockBack(player, 3, player.x - target.x, player.z - target.z); } - // Decrease durability itemstack.damageItem(1, player); return true; @@ -60,6 +61,14 @@ public void inventoryTick(ItemStack itemstack, World world, Entity entity, int i itemstack.getData().putBoolean("active", false); } } + if (itemstack != null && itemstack.getItem() instanceof ShieldItem) { + EntityPlayer thePlayer = Minecraft.getMinecraft(this).thePlayer; + thePlayer.triggerAchievement(ShieldAchievements.SHIELD_GOT); + ShieldItem shield = ((ShieldItem) itemstack.getItem()); + if(shield.tool == ShieldMaterials.TOOL_STEEL){ + thePlayer.triggerAchievement(ShieldAchievements.MODERN_AGE); + } + } } } diff --git a/src/main/java/mizurin/shieldmod/item/ShieldMaterials.java b/src/main/java/mizurin/shieldmod/item/ShieldMaterials.java index d8094da..51441a8 100644 --- a/src/main/java/mizurin/shieldmod/item/ShieldMaterials.java +++ b/src/main/java/mizurin/shieldmod/item/ShieldMaterials.java @@ -11,10 +11,11 @@ public ToolMaterial setGuard(float guard){ this.guard = guard; return this; } + public static final ToolMaterial TOOL_LEATHER = new ToolMaterial().setDurability(96).setDamage(-2).setEfficiency(2.0f, 0.85f); public static final ToolMaterial TOOL_WOOD = new ToolMaterial().setDurability(64).setDamage(-1).setEfficiency(2.0f, 0.85f); public static final ToolMaterial TOOL_STONE = new ToolMaterial().setDurability(128).setDamage(0).setEfficiency(2.0f, 0.75f); public static final ToolMaterial TOOL_IRON = new ToolMaterial().setDurability(256).setDamage(1).setEfficiency(2.0f, 0.60f); - public static final ToolMaterial TOOL_GOLD = new ToolMaterial().setDurability(64).setDamage(-1).setEfficiency(2.0f, 0.40f).setSilkTouch(true); + 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); diff --git a/src/main/java/mizurin/shieldmod/item/Shields.java b/src/main/java/mizurin/shieldmod/item/Shields.java index 12329ad..6a0e5f7 100644 --- a/src/main/java/mizurin/shieldmod/item/Shields.java +++ b/src/main/java/mizurin/shieldmod/item/Shields.java @@ -10,6 +10,7 @@ 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 leatherShield = ItemHelper.createItem(MOD_ID, new ShieldColored("leather.shield", 17006, ShieldMaterials.TOOL_LEATHER), "wooden_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item woodenShield = ItemHelper.createItem(MOD_ID, new ShieldItem("wooden.shield", 17000, ShieldMaterials.TOOL_WOOD),"wooden_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item stoneShield = ItemHelper.createItem(MOD_ID, new ShieldItem("stone.shield", 17001, ShieldMaterials.TOOL_STONE), "stone_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item ironShield = ItemHelper.createItem(MOD_ID, new ShieldItem("iron.shield", 17002, ShieldMaterials.TOOL_IRON), "iron_shield.png").withTags(ItemTags.preventCreativeMining); @@ -17,12 +18,5 @@ public class Shields { public static final Item diamondShield = ItemHelper.createItem(MOD_ID, new ShieldItem("diamond.shield", 17004, ShieldMaterials.TOOL_DIAMOND), "diamond_shield.png").withTags(ItemTags.preventCreativeMining); public static final Item steelShield = ItemHelper.createItem(MOD_ID, new ShieldItem("steel.shield", 17005, ShieldMaterials.TOOL_STEEL), "steel_shield.png").withTags(ItemTags.preventCreativeMining); - - //woodenShield = ItemHelper.createItem(MOD_ID, new ShieldItem("wooden.shield", 17000, ShieldMaterials.TOOL_WOOD),"wooden_shield.png").withTags(ItemTags.preventCreativeMining); - //stoneShield = ItemHelper.createItem(MOD_ID, new ShieldItem("stone.shield", 17001, ShieldMaterials.TOOL_STONE), "stone_shield.png").withTags(ItemTags.preventCreativeMining); - //ironShield = ItemHelper.createItem(MOD_ID, new ShieldItem("iron.shield", 17002, ShieldMaterials.TOOL_IRON), "iron_shield.png").withTags(ItemTags.preventCreativeMining); - //goldShield = ItemHelper.createItem(MOD_ID, new ShieldItem("gold.shield", 17003, ShieldMaterials.TOOL_GOLD), "gold_shield.png").withTags(ItemTags.preventCreativeMining); - //diamondShield = ItemHelper.createItem(MOD_ID, new ShieldItem("diamond.shield", 17004, ShieldMaterials.TOOL_DIAMOND), "diamond_shield.png").withTags(ItemTags.preventCreativeMining); - //steelShield = ItemHelper.createItem(MOD_ID, new ShieldItem("steel.shield", 17005, ShieldMaterials.TOOL_STEEL), "steel_shield.png").withTags(ItemTags.preventCreativeMining); public void initializeItems(){} } diff --git a/src/main/java/mizurin/shieldmod/mixins/ItemMixin.java b/src/main/java/mizurin/shieldmod/mixins/ItemMixin.java index ec85098..dacb49b 100644 --- a/src/main/java/mizurin/shieldmod/mixins/ItemMixin.java +++ b/src/main/java/mizurin/shieldmod/mixins/ItemMixin.java @@ -1,5 +1,7 @@ package mizurin.shieldmod.mixins; +import mizurin.shieldmod.ShieldAchievements; import mizurin.shieldmod.item.ShieldItem; +import net.minecraft.client.Minecraft; import net.minecraft.client.render.entity.LivingRenderer; import net.minecraft.client.render.entity.PlayerRenderer; import net.minecraft.client.render.model.ModelBase; @@ -27,6 +29,8 @@ public void injectRenderer(EntityPlayer entity, float f, CallbackInfo ci) { ItemStack itemstack = entity.inventory.getCurrentItem(); if (itemstack != null && itemstack.getItem() instanceof ShieldItem) { + EntityPlayer thePlayer = Minecraft.getMinecraft(this).thePlayer; + thePlayer.triggerAchievement(ShieldAchievements.SHIELD_GOT); if (itemstack.getData().getBoolean("active")) { GL11.glPushMatrix(); modelBipedMain.bipedRightArm.postRender(0.0625F); diff --git a/src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java b/src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java index fcd9210..7f9a762 100644 --- a/src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java +++ b/src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java @@ -1,7 +1,10 @@ package mizurin.shieldmod.mixins; +import net.minecraft.client.Minecraft; import net.minecraft.core.entity.Entity; +import net.minecraft.core.entity.monster.EntityMonster; import net.minecraft.core.entity.player.EntityPlayer; +import net.minecraft.core.entity.projectile.EntityArrow; import net.minecraft.core.item.ItemStack; import net.minecraft.core.player.gamemode.Gamemode; import net.minecraft.core.util.helper.DamageType; @@ -14,6 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import mizurin.shieldmod.item.ShieldItem; import mizurin.shieldmod.item.ShieldMaterials; +import mizurin.shieldmod.ShieldAchievements; // mixin to EntityPlayer, do not remap(forgot what remap does) @@ -44,23 +48,45 @@ public ShieldMixin(World world) { // inject at the top(HEAD) of hurt(), allow us to call return(cancel/set return value) @Inject(method = "hurt", at = @At("HEAD"), cancellable = true) public void injectHurt(Entity attacker, int damage, DamageType type, CallbackInfoReturnable ci) { + if (attacker instanceof EntityMonster || attacker instanceof EntityArrow) { + if (this.world.difficultySetting == 0) { + damage = 0; + } + + if (this.world.difficultySetting == 1) { + damage = damage / 3 + 1; + } + + if (this.world.difficultySetting == 3) { + damage = damage * 3 / 2; + } + } // check if we are holding the shield item. + EntityPlayer thePlayer = Minecraft.getMinecraft(this).thePlayer; ItemStack stack = inventory.mainInventory[inventory.currentItem]; if (stack != null) { if (stack.getItem() instanceof ShieldItem) { + ShieldItem shield = ((ShieldItem) stack.getItem()); { if (attacker != null) { World world = attacker.world; - int newDamage = Math.round(damage * (shield.tool.getEfficiency(true))); if (!this.gamemode.isPlayerInvulnerable()) { if (stack.getData().getBoolean("active")) { - if (shield.tool == ShieldMaterials.TOOL_WOOD){ - attacker.push(0,1,0); + int newDamage = Math.round(damage * (shield.tool.getEfficiency(true))); + if (shield.tool == ShieldMaterials.TOOL_LEATHER){ + attacker.push(0 ,1,0); + thePlayer.triggerAchievement(ShieldAchievements.FLY_HIGH); + } + if(shield.tool == ShieldMaterials.TOOL_GOLD){ + attacker.hurt(attacker, newDamage, type); + thePlayer.triggerAchievement(ShieldAchievements.GOLD_RETAL); } super.hurt(attacker, newDamage, type); + thePlayer.triggerAchievement(ShieldAchievements.BLOCK); + world.playSoundAtEntity(attacker, attacker, ("mob.ghast.fireball"), 1.0F, diff --git a/src/main/java/mizurin/shieldmod/recipeColor.java b/src/main/java/mizurin/shieldmod/recipeColor.java new file mode 100644 index 0000000..75038cf --- /dev/null +++ b/src/main/java/mizurin/shieldmod/recipeColor.java @@ -0,0 +1,138 @@ +package mizurin.shieldmod; + +import com.mojang.nbt.CompoundTag; +import net.minecraft.client.util.helper.Colors; +import net.minecraft.core.data.registry.recipe.SearchQuery; +import net.minecraft.core.data.registry.recipe.entry.RecipeEntryCraftingDynamic; +import net.minecraft.core.item.Item; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.player.inventory.InventoryCrafting; +import net.minecraft.core.util.helper.Color; +import useless.prismaticlibe.IColored; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +//Special thanks to UselessBullets for being extremely awesome https://github.com/UselessBullets/Lunacy/tree/7.1 +public class recipeColor extends RecipeEntryCraftingDynamic { + public static HashMap> dyeMap = new HashMap<>(); + private static final Map vanillaDye; + static { + vanillaDye = new HashMap<>(); + for (int color = 0; color < 16; color++) { + vanillaDye.put(color, Colors.allSignColors[15 - color]); + } + dyeMap.put(Item.dye, vanillaDye); + } + @Override + public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) { + ItemStack shieldStack = null; + List dyeStacks = new ArrayList<>(); + for (int x = 0; x < 3; ++x) { + for (int y = 0; y < 3; ++y) { + ItemStack stack = inventorycrafting.getItemStackAt(x, y); + if (stack == null) continue; + if (stack.getItem() instanceof IColored) { + shieldStack = stack; + } else if (dyeMap.containsKey(stack.getItem())) { + dyeStacks.add(stack); + } + } + } + if (shieldStack != null && !dyeStacks.isEmpty()) { + ItemStack outStack = shieldStack.copy(); + int r = -1; + int g = -1; + int b = -1; + int count = 0; + if (outStack.getData().containsKey("dyed_color")){ + CompoundTag armorColorTag = outStack.getData().getCompound("dyed_color"); + r = armorColorTag.getShort("red"); + g = armorColorTag.getShort("green"); + b = armorColorTag.getShort("blue"); + count += 1; + } + + for (ItemStack dyeStack : dyeStacks){ + Color color = dyeMap.getOrDefault(dyeStack.getItem(), vanillaDye).getOrDefault(dyeStack.getMetadata(), vanillaDye.get(0)); + if (r == -1 || g == -1 || b == -1){ + r = (int) (color.getRed() * 0.85f); + g = (int) (color.getGreen() * 0.85f); + b = (int) (color.getBlue() * 0.85f); + } else { + r += color.getRed(); + g += color.getGreen(); + b += color.getBlue(); + } + count += 1; + } + + if (count > 0){ + r /= count; + g /= count; + b /= count; + CompoundTag colorTag = new CompoundTag(); + colorTag.putShort("red", (short) r); + colorTag.putShort("green", (short) g); + colorTag.putShort("blue", (short) b); + outStack.getData().putCompound("dyed_color", colorTag); + } + + outStack.stackSize = 1; + return outStack; + } + return null; + } + + @Override + public int getRecipeSize() { + return 9; + } + + @Override + public boolean matches(InventoryCrafting crafting) { + ItemStack shieldStack = null; + ItemStack dyeStack = null; + for (int x = 0; x < 3; ++x) { + for (int y = 0; y < 3; ++y) { + ItemStack stack = crafting.getItemStackAt(x, y); + if (stack == null) continue; + if (stack.getItem() instanceof IColored) { + if (shieldStack != null) { + return false; + } + shieldStack = stack; + continue; + } + if (dyeMap.containsKey(stack.getItem())) { + dyeStack = stack; + continue; + } + return false; + } + } + return shieldStack != null && dyeStack != null; + } + + @Override + public boolean matchesQuery(SearchQuery query) { + return false; + } + + @Override + public ItemStack[] onCraftResult(InventoryCrafting crafting) { + ItemStack[] returnStack = new ItemStack[9]; + for (int x = 0; x < 3; ++x) { + for (int y = 0; y < 3; ++y) { + ItemStack stack = crafting.getItemStackAt(x, y); + if (stack == null) continue; + --stack.stackSize; + if (stack.stackSize > 0) continue; + crafting.setSlotContentsAt(x, y, null); + } + } + return returnStack; + } +} diff --git a/src/main/java/mizurin/shieldmod/recipes.java b/src/main/java/mizurin/shieldmod/recipes.java index 9d5845f..8c8121a 100644 --- a/src/main/java/mizurin/shieldmod/recipes.java +++ b/src/main/java/mizurin/shieldmod/recipes.java @@ -1,16 +1,19 @@ package mizurin.shieldmod; +import net.minecraft.client.Minecraft; import net.minecraft.core.block.Block; import net.minecraft.core.data.registry.Registries; import net.minecraft.core.data.registry.recipe.RecipeNamespace; 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.entity.player.EntityPlayer; import net.minecraft.core.item.ItemStack; import turniplabs.halplibe.util.RecipeEntrypoint; import net.minecraft.core.item.Item; import turniplabs.halplibe.helper.RecipeBuilder; import net.minecraft.core.data.DataLoader; +import java.awt.*; import mizurin.shieldmod.item.Shields; @@ -63,6 +66,16 @@ public void onRecipesReady() { .addInput('L',"minecraft:planks") .create("steelShield", Shields.steelShield.getDefaultStack()); + + RecipeBuilder.Shaped(MOD_ID) + .setShape(" P ","PLP"," P ") + .addInput('P', Item.leather) + .addInput('L', Block.wool) + .create("leatherShield", Shields.leatherShield.getDefaultStack()); + + Registries.RECIPE_TYPES.register("colored/shield", recipeColor.class); + WORKBENCH.register("leather", new recipeColor()); + } } diff --git a/src/main/resources/assets/shieldmod/item/colored.png b/src/main/resources/assets/shieldmod/item/colored.png new file mode 100644 index 0000000000000000000000000000000000000000..18473e821eb6ba8e1c48c298082a585db00494d6 GIT binary patch literal 540 zcmV+%0^|LOP)k2b~QaSR3n`2BvQ(`hxk-EM{T)oK;T;}J5Q zP8I!hI+4u;gFzT$(CKuj1er_*;cysKbUvR^E|&=;!{JbgrCzV&e!n9YiWaz8TyK)umD?(KQm4(yg5v7911L(?FiSyX%d|Uye{i53~z%r#^W(~AN1|>`Gi)e ekcyf6`}hIe05E%w6|F%40000iE9z4;>&O7Z4Eg zG))Ts`KD>89qYP!-UOr?lhZVHP@d;uS(bqCh2b|@pC6$vbqixM3CM_$mxy>SphQfb z=Q*&{fiSUu2mr<)o?V5yuERKvmQ&4w>+=wxUD>v6);94Qnf&7wV(>5wgrO)3^Rc)k z&d;lWfK^r51p+2VM|bmI;C;_0a?t(aL