generated from Turnip-Labs/bta-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
213 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
org.gradle.jvmargs=-Xmx2G | ||
|
||
# BTA | ||
bta_version=7.1-pre2a | ||
bta_version=7.1 | ||
|
||
# Loader | ||
loader_version=0.14.19-babric.3-bta | ||
|
||
# HalpLibe | ||
halplibe_version=3.5.1 | ||
halplibe_version=3.5.2 | ||
|
||
prismatic_version=3.0.3-7.1 | ||
|
||
# Mod | ||
mod_version=1.0.3 | ||
mod_version=1.0.4 | ||
mod_group=Mizuri-n | ||
mod_name=Better with Defense |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package mizurin.shieldmod; | ||
|
||
import com.mojang.nbt.CompoundTag; | ||
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.ItemDye; | ||
import net.minecraft.core.item.ItemStack; | ||
import net.minecraft.core.player.inventory.InventoryCrafting; | ||
import net.minecraft.core.util.helper.Color; | ||
import useless.prismaticlibe.IColoredArmor; | ||
import useless.prismaticlibe.debug.ItemArmorColored; | ||
|
||
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 armorRecipeColor extends RecipeEntryCraftingDynamic { | ||
public static HashMap<Item, Map<Integer, Color>> dyeMap = new HashMap<>(); | ||
private static final Map<Integer, Color> vanillaDye; | ||
static { | ||
vanillaDye = new HashMap<>(); | ||
ItemDye.field_31002_bk[7] = 13027014; | ||
ItemDye.field_31002_bk[15] = 16777215; | ||
for (int color = 0; color < 16; color++) { | ||
vanillaDye.put(color, new Color().setARGB(ItemDye.field_31002_bk[color])); | ||
} | ||
dyeMap.put(Item.dye, vanillaDye); | ||
} | ||
@Override | ||
public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) { | ||
ItemStack armorStack = null; | ||
List<ItemStack> 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 IColoredArmor) { | ||
armorStack = stack; | ||
} else if (dyeMap.containsKey(stack.getItem())) { | ||
dyeStacks.add(stack); | ||
} | ||
} | ||
} | ||
if (armorStack != null && !dyeStacks.isEmpty()) { | ||
ItemStack outStack = armorStack.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 armorStack = 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 IColoredArmor) { | ||
if (armorStack != null) { | ||
return false; | ||
} | ||
armorStack = stack; | ||
continue; | ||
} | ||
if (dyeMap.containsKey(stack.getItem())) { | ||
dyeStack = stack; | ||
continue; | ||
} | ||
return false; | ||
} | ||
} | ||
return armorStack != 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package mizurin.shieldmod.item; | ||
|
||
import com.mojang.nbt.CompoundTag; | ||
import mizurin.shieldmod.ShieldMod; | ||
import net.minecraft.core.item.ItemArmor; | ||
import net.minecraft.core.item.material.ArmorMaterial; | ||
import turniplabs.halplibe.helper.TextureHelper; | ||
import net.minecraft.core.item.ItemStack; | ||
import useless.prismaticlibe.ColoredArmorTexture; | ||
import useless.prismaticlibe.ColoredTexture; | ||
import useless.prismaticlibe.IColored; | ||
import useless.prismaticlibe.IColoredArmor; | ||
|
||
import java.awt.*; | ||
|
||
public class ArmorColored extends ItemArmor implements IColoredArmor, IColored { | ||
public static final String MOD_ID = ShieldMod.MOD_ID; | ||
public static final int[][] baseColor = new int[][] { | ||
TextureHelper.getOrCreateItemTexture(ShieldMod.MOD_ID, "leather_helmet.png"), | ||
TextureHelper.getOrCreateItemTexture(ShieldMod.MOD_ID, "leather_chestplate.png"), | ||
TextureHelper.getOrCreateItemTexture(ShieldMod.MOD_ID, "leather_leggings.png"), | ||
TextureHelper.getOrCreateItemTexture(ShieldMod.MOD_ID, "leather_boots.png")}; | ||
|
||
public ArmorColored(String name, int id, ArmorMaterial material, int armorPiece) { | ||
super(name, id, material, armorPiece); | ||
} | ||
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[armorPiece], getColor(itemStack))}; | ||
} | ||
|
||
@Override | ||
public ColoredArmorTexture[] getArmorTextures(ItemStack itemStack) { | ||
return new ColoredArmorTexture[]{new ColoredArmorTexture("leather", getColor(itemStack))}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters