Fix JABBA-related issues with crafting station slots (#54)

* Fix shift-merging tools voiding items

fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392>

* Change 0-sized ItemStacks into null stacks in crafting station attached slots

Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425>

* Update buildscript

* spotlessApply
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2022-09-22 20:51:23 +02:00
1 parent 18bfeaff32
commit 39be06c23b
571 files changed
+25959 -28223

No files matched your search

@@ -9,47 +9,36 @@ import tconstruct.library.TConstructRegistry;
import tconstruct.library.util.IToolPart;
import tconstruct.tools.TinkerTools;
public class Bowstring extends CraftingItem implements IToolPart
{
public Bowstring()
{
public class Bowstring extends CraftingItem implements IToolPart {
public Bowstring() {
super(toolMaterialNames, buildTextureNames("_bowstring"), "parts/", "tinker", TConstructRegistry.materialTab);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
private static String[] buildTextureNames (String textureType)
{
private static String[] buildTextureNames(String textureType) {
String[] names = new String[toolMaterialNames.length];
for (int i = 0; i < toolMaterialNames.length; i++)
{
if (toolTextureNames[i].equals(""))
names[i] = "";
else
names[i] = toolTextureNames[i] + textureType;
for (int i = 0; i < toolMaterialNames.length; i++) {
if (toolTextureNames[i].equals("")) names[i] = "";
else names[i] = toolTextureNames[i] + textureType;
}
return names;
}
public static final String[] toolMaterialNames = new String[] { "string", "enchantedfabric", "flamestring" };
public static final String[] toolMaterialNames = new String[] {"string", "enchantedfabric", "flamestring"};
public static final String[] toolTextureNames = new String[] { "string", "magicfabric", "flamestring" };
public static final String[] toolTextureNames = new String[] {"string", "magicfabric", "flamestring"};
@Override
public int getMaterialID (ItemStack stack)
{
if (stack.getItemDamage() >= toolMaterialNames.length)
return -1;
public int getMaterialID(ItemStack stack) {
if (stack.getItemDamage() >= toolMaterialNames.length) return -1;
return stack.getItemDamage();
}
@Override
public void getSubItems (Item b, CreativeTabs tab, List list)
{
public void getSubItems(Item b, CreativeTabs tab, List list) {
list.add(new ItemStack(b, 1, 0));
if (TinkerTools.thaumcraftAvailable)
list.add(new ItemStack(b, 1, 1));
if (Loader.isModLoaded("Natura"))
list.add(new ItemStack(b, 1, 2));
if (TinkerTools.thaumcraftAvailable) list.add(new ItemStack(b, 1, 1));
if (Loader.isModLoaded("Natura")) list.add(new ItemStack(b, 1, 2));
}
}
@@ -12,11 +12,9 @@ import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.*;
import tconstruct.library.tools.ToolCore;
public class CreativeModifier extends Item
{
public class CreativeModifier extends Item {
public CreativeModifier()
{
public CreativeModifier() {
super();
this.setCreativeTab(TConstructRegistry.materialTab);
}
@@ -26,12 +24,10 @@ public class CreativeModifier extends Item
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
@Override
public void getSubItems (Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
for (ToolRecipe recipe : ToolBuilder.instance.combos)
{
for (ToolRecipe recipe : ToolBuilder.instance.combos) {
ToolCore tool = recipe.getType();
ItemStack item = new ItemStack(par1, 1, 0);
NBTTagCompound compound = new NBTTagCompound();
@@ -44,21 +40,18 @@ public class CreativeModifier extends Item
@SideOnly(Side.CLIENT)
@Override
public void registerIcons (IIconRegister iconRegister)
{
public void registerIcons(IIconRegister iconRegister) {
this.itemIcon = iconRegister.registerIcon("tinker:skull_char_gold");
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
{
if (stack.hasTagCompound())
{
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
if (stack.hasTagCompound()) {
String targetLock = "None";
targetLock = stack.getTagCompound().getString("TargetLock");
targetLock = StatCollector.translateToLocal("infitool." + targetLock.toLowerCase());
list.add(StatCollector.translateToLocal("creativeModLock.tooltip") + targetLock);
}
}
}
}
@@ -5,37 +5,30 @@ import net.minecraft.item.ItemStack;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.util.IToolPart;
public class Fletching extends CraftingItem implements IToolPart
{
public Fletching()
{
public class Fletching extends CraftingItem implements IToolPart {
public Fletching() {
super(toolMaterialNames, buildTextureNames("_fletching"), "parts/", "tinker", TConstructRegistry.materialTab);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
private static String[] buildTextureNames (String textureType)
{
private static String[] buildTextureNames(String textureType) {
String[] names = new String[toolMaterialNames.length];
for (int i = 0; i < toolMaterialNames.length; i++)
{
if (toolTextureNames[i].equals(""))
names[i] = "";
else
names[i] = toolTextureNames[i] + textureType;
for (int i = 0; i < toolMaterialNames.length; i++) {
if (toolTextureNames[i].equals("")) names[i] = "";
else names[i] = toolTextureNames[i] + textureType;
}
return names;
}
public static final String[] toolMaterialNames = new String[] { "feather", "leaf", "slime", "blueslime", "slimeleaf" };
public static final String[] toolMaterialNames =
new String[] {"feather", "leaf", "slime", "blueslime", "slimeleaf"};
public static final String[] toolTextureNames = new String[] { "feather", "leaf", "slime", "blueslime", "slimeleaf" };
public static final String[] toolTextureNames = new String[] {"feather", "leaf", "slime", "blueslime", "slimeleaf"};
@Override
public int getMaterialID (ItemStack stack)
{
if (stack.getItemDamage() >= toolMaterialNames.length)
return -1;
public int getMaterialID(ItemStack stack) {
if (stack.getItemDamage() >= toolMaterialNames.length) return -1;
return stack.getItemDamage();
}
}
@@ -1,14 +1,12 @@
package tconstruct.tools.items;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.*;
import java.util.List;
import mantle.books.BookData;
import mantle.client.gui.GuiManual;
import mantle.items.abstracts.CraftingItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
@@ -17,24 +15,22 @@ import tconstruct.achievements.TAchievements;
import tconstruct.client.TProxyClient;
import tconstruct.library.TConstructRegistry;
public class Manual extends CraftingItem
{
static String[] name = new String[] { "beginner", "toolstation", "smeltery", "diary", "weaponry" };
static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery", "tinkerbook_blue", "tinkerbook_green" };
public class Manual extends CraftingItem {
static String[] name = new String[] {"beginner", "toolstation", "smeltery", "diary", "weaponry"};
static String[] textureName = new String[] {
"tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery", "tinkerbook_blue", "tinkerbook_green"
};
public Manual()
{
public Manual() {
super(name, textureName, "", "tinker", TConstructRegistry.materialTab);
setUnlocalizedName("tconstruct.manual");
}
@Override
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
{
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
TAchievements.triggerAchievement(player, "tconstruct.beginner");
if(world.isRemote) {
if (world.isRemote) {
openBook(stack, world, player);
}
return stack;
@@ -46,45 +42,40 @@ public class Manual extends CraftingItem
FMLClientHandler.instance().displayGuiScreen(player, new GuiManual(stack, getData(stack)));
}
private BookData getData (ItemStack stack)
{
switch (stack.getItemDamage())
{
case 0:
return TProxyClient.manualData.beginner;
case 1:
return TProxyClient.manualData.toolStation;
case 2:
return TProxyClient.manualData.smeltery;
case 4:
return TProxyClient.manualData.weaponry;
default:
return TProxyClient.manualData.diary;
private BookData getData(ItemStack stack) {
switch (stack.getItemDamage()) {
case 0:
return TProxyClient.manualData.beginner;
case 1:
return TProxyClient.manualData.toolStation;
case 2:
return TProxyClient.manualData.smeltery;
case 4:
return TProxyClient.manualData.weaponry;
default:
return TProxyClient.manualData.diary;
}
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
{
switch (stack.getItemDamage())
{
case 0:
list.add("\u00a7o" + StatCollector.translateToLocal("manual1.tooltip"));
break;
case 1:
list.add("\u00a7o" + StatCollector.translateToLocal("manual2.tooltip"));
break;
case 2:
list.add("\u00a7o" + StatCollector.translateToLocal("manual3.tooltip"));
break;
case 4:
list.add("\u00a7o" + StatCollector.translateToLocal("manual4.tooltip"));
break;
default:
list.add("\u00a7o" + StatCollector.translateToLocal("manual5.tooltip"));
break;
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
switch (stack.getItemDamage()) {
case 0:
list.add("\u00a7o" + StatCollector.translateToLocal("manual1.tooltip"));
break;
case 1:
list.add("\u00a7o" + StatCollector.translateToLocal("manual2.tooltip"));
break;
case 2:
list.add("\u00a7o" + StatCollector.translateToLocal("manual3.tooltip"));
break;
case 4:
list.add("\u00a7o" + StatCollector.translateToLocal("manual4.tooltip"));
break;
default:
list.add("\u00a7o" + StatCollector.translateToLocal("manual5.tooltip"));
break;
}
}
}
@@ -7,10 +7,10 @@ import net.minecraft.util.*;
import org.w3c.dom.Document;
import tconstruct.client.TProxyClient;
public class ManualInfo
{
public class ManualInfo {
// static String[] name = new String[] { "beginner", "toolstation", "smeltery", "diary" };
// static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery", "tinkerbook_blue" };
// static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation",
// "tinkerbook_smeltery", "tinkerbook_blue" };
BookData beginner = new BookData();
BookData toolStation = new BookData();
@@ -23,19 +23,42 @@ public class ManualInfo
volume2 = readManual("/assets/tinker/manuals/materials.xml", dbFactory);
smelter = readManual("/assets/tinker/manuals/smeltery.xml", dbFactory);*/
public ManualInfo()
{
public ManualInfo() {
Side side = FMLCommonHandler.instance().getEffectiveSide();
beginner = initManual(beginner, "tconstruct.manual.beginner", "\u00a7o" + StatCollector.translateToLocal("manual1.tooltip"), side == Side.CLIENT ? TProxyClient.volume1 : null, "tinker:tinkerbook_diary");
toolStation = initManual(toolStation, "tconstruct.manual.toolstation", "\u00a7o" + StatCollector.translateToLocal("manual2.tooltip"), side == Side.CLIENT ? TProxyClient.volume2 : null, "tinker:tinkerbook_toolstation");
smeltery = initManual(smeltery, "tconstruct.manual.smeltery", "\u00a7o" + StatCollector.translateToLocal("manual3.tooltip"), side == Side.CLIENT ? TProxyClient.smelter : null, "tinker:tinkerbook_smeltery");
diary = initManual(diary, "tconstruct.manual.diary", "\u00a7o" + StatCollector.translateToLocal("manual4.tooltip"), side == Side.CLIENT ? TProxyClient.diary : null, "tinker:tinkerbook_blue");
weaponry = initManual(weaponry, "tconstruct.manual.weaponry", "\u00a7o" + StatCollector.translateToLocal("manual5.tooltip"), side == Side.CLIENT ? TProxyClient.weaponry : null, "tinker:tinkerbook_green");
beginner = initManual(
beginner,
"tconstruct.manual.beginner",
"\u00a7o" + StatCollector.translateToLocal("manual1.tooltip"),
side == Side.CLIENT ? TProxyClient.volume1 : null,
"tinker:tinkerbook_diary");
toolStation = initManual(
toolStation,
"tconstruct.manual.toolstation",
"\u00a7o" + StatCollector.translateToLocal("manual2.tooltip"),
side == Side.CLIENT ? TProxyClient.volume2 : null,
"tinker:tinkerbook_toolstation");
smeltery = initManual(
smeltery,
"tconstruct.manual.smeltery",
"\u00a7o" + StatCollector.translateToLocal("manual3.tooltip"),
side == Side.CLIENT ? TProxyClient.smelter : null,
"tinker:tinkerbook_smeltery");
diary = initManual(
diary,
"tconstruct.manual.diary",
"\u00a7o" + StatCollector.translateToLocal("manual4.tooltip"),
side == Side.CLIENT ? TProxyClient.diary : null,
"tinker:tinkerbook_blue");
weaponry = initManual(
weaponry,
"tconstruct.manual.weaponry",
"\u00a7o" + StatCollector.translateToLocal("manual5.tooltip"),
side == Side.CLIENT ? TProxyClient.weaponry : null,
"tinker:tinkerbook_green");
}
public BookData initManual (BookData data, String unlocName, String toolTip, Document xmlDoc, String itemImage)
{
//proxy.readManuals();
public BookData initManual(BookData data, String unlocName, String toolTip, Document xmlDoc, String itemImage) {
// proxy.readManuals();
data.unlocalizedName = unlocName;
data.toolTip = unlocName;
data.modID = "TConstruct";
@@ -44,5 +67,4 @@ public class ManualInfo
BookDataStore.addBook(data);
return data;
}
}
@@ -3,28 +3,110 @@ package tconstruct.tools.items;
import mantle.items.abstracts.CraftingItem;
import tconstruct.library.TConstructRegistry;
public class MaterialItem extends CraftingItem
{
public class MaterialItem extends CraftingItem {
public MaterialItem()
{
public MaterialItem() {
super(materialNames, getTextures(), "materials/", "tinker", TConstructRegistry.materialTab);
}
private static String[] getTextures ()
{
private static String[] getTextures() {
String[] names = new String[craftingTextures.length];
for (int i = 0; i < craftingTextures.length; i++)
{
if (craftingTextures[i].equals(""))
names[i] = "";
else
names[i] = "material_" + craftingTextures[i];
for (int i = 0; i < craftingTextures.length; i++) {
if (craftingTextures[i].equals("")) names[i] = "";
else names[i] = "material_" + craftingTextures[i];
}
return names;
}
static String[] materialNames = new String[] { "PaperStack", "SlimeCrystal", "SearedBrick", "CobaltIngot", "ArditeIngot", "ManyullynIngot", "Mossball", "LavaCrystal", "NecroticBone", "CopperIngot", "TinIngot", "AluminumIngot", "RawAluminum", "BronzeIngot", "AluBrassIngot", "AlumiteIngot", "SteelIngot", "BlueSlimeCrystal", "ObsidianIngot", "IronNugget", "CopperNugget", "TinNugget", "AluminumNugget", "EssenceCrystal", "AluBrassNugget", "SilkyCloth", "SilkyJewel", "ObsidianNugget", "CobaltNugget", "ArditeNugget", "ManyullynNugget", "BronzeNugget", "AlumiteNugget", "SteelNugget", "PigIronIngot", "PigIronNugget", "GlueBall", "SearedBrick", "ArditeDust", "CobaltDust", "AluminumDust", "ManyullynDust", "AluBrassDust" };
static String[] materialNames = new String[] {
"PaperStack",
"SlimeCrystal",
"SearedBrick",
"CobaltIngot",
"ArditeIngot",
"ManyullynIngot",
"Mossball",
"LavaCrystal",
"NecroticBone",
"CopperIngot",
"TinIngot",
"AluminumIngot",
"RawAluminum",
"BronzeIngot",
"AluBrassIngot",
"AlumiteIngot",
"SteelIngot",
"BlueSlimeCrystal",
"ObsidianIngot",
"IronNugget",
"CopperNugget",
"TinNugget",
"AluminumNugget",
"EssenceCrystal",
"AluBrassNugget",
"SilkyCloth",
"SilkyJewel",
"ObsidianNugget",
"CobaltNugget",
"ArditeNugget",
"ManyullynNugget",
"BronzeNugget",
"AlumiteNugget",
"SteelNugget",
"PigIronIngot",
"PigIronNugget",
"GlueBall",
"SearedBrick",
"ArditeDust",
"CobaltDust",
"AluminumDust",
"ManyullynDust",
"AluBrassDust"
};
static String[] craftingTextures = new String[] { "paperstack", "slimecrystal", "searedbrick", "cobaltingot", "arditeingot", "manyullyningot", "mossball", "lavacrystal", "necroticbone", "copperingot", "tiningot", "aluminumingot", "aluminumraw", "bronzeingot", "alubrassingot", "alumiteingot", "steelingot", "blueslimecrystal", "obsidianingot", "nugget_iron", "nugget_copper", "nugget_tin", "nugget_aluminum", "", "nugget_alubrass", "silkycloth", "silkyjewel", "nugget_obsidian", "nugget_cobalt", "nugget_ardite", "nugget_manyullyn", "nugget_bronze", "nugget_alumite", "nugget_steel", "pigironingot", "nugget_pigiron", "glueball", "searedbrick_nether", "ardite_dust", "cobalt_dust", "aluminum_dust", "manyullyn_dust", "alubrass_dust" };
static String[] craftingTextures = new String[] {
"paperstack",
"slimecrystal",
"searedbrick",
"cobaltingot",
"arditeingot",
"manyullyningot",
"mossball",
"lavacrystal",
"necroticbone",
"copperingot",
"tiningot",
"aluminumingot",
"aluminumraw",
"bronzeingot",
"alubrassingot",
"alumiteingot",
"steelingot",
"blueslimecrystal",
"obsidianingot",
"nugget_iron",
"nugget_copper",
"nugget_tin",
"nugget_aluminum",
"",
"nugget_alubrass",
"silkycloth",
"silkyjewel",
"nugget_obsidian",
"nugget_cobalt",
"nugget_ardite",
"nugget_manyullyn",
"nugget_bronze",
"nugget_alumite",
"nugget_steel",
"pigironingot",
"nugget_pigiron",
"glueball",
"searedbrick_nether",
"ardite_dust",
"cobalt_dust",
"aluminum_dust",
"manyullyn_dust",
"alubrass_dust"
};
}
@@ -1,11 +1,9 @@
package tconstruct.tools.items;
import cpw.mods.fml.relauncher.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mantle.items.abstracts.CraftingItem;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -15,15 +13,12 @@ import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.PatternBuilder.MaterialSet;
import tconstruct.library.util.IPattern;
public class Pattern extends CraftingItem implements IPattern
{
public Pattern(String patternType, String folder)
{
public class Pattern extends CraftingItem implements IPattern {
public Pattern(String patternType, String folder) {
this(patternName, getPatternNames(patternType), folder);
}
public Pattern(String[] names, String[] patternTypes, String folder)
{
public Pattern(String[] names, String[] patternTypes, String folder) {
super(names, patternTypes, folder, "tinker", TConstructRegistry.materialTab);
this.setHasSubtypes(true);
this.setMaxDamage(0);
@@ -31,31 +26,53 @@ public class Pattern extends CraftingItem implements IPattern
this.setMaxStackSize(1);
}
protected static String[] getPatternNames (String partType)
{
protected static String[] getPatternNames(String partType) {
String[] names = new String[patternName.length];
for (int i = 0; i < patternName.length; i++)
names[i] = partType + patternName[i];
for (int i = 0; i < patternName.length; i++) names[i] = partType + patternName[i];
return names;
}
private static final String[] patternName = new String[] { "ingot", "rod", "pickaxe", "shovel", "axe", "swordblade", "largeguard", "mediumguard", "crossbar", "binding", "frypan", "sign", "knifeblade", "chisel", "largerod", "toughbinding", "largeplate", "broadaxe", "scythe", "excavator", "largeblade", "hammerhead", "fullguard", "bowstring", "fletching", "arrowhead" };
private static final String[] patternName = new String[] {
"ingot",
"rod",
"pickaxe",
"shovel",
"axe",
"swordblade",
"largeguard",
"mediumguard",
"crossbar",
"binding",
"frypan",
"sign",
"knifeblade",
"chisel",
"largerod",
"toughbinding",
"largeplate",
"broadaxe",
"scythe",
"excavator",
"largeblade",
"hammerhead",
"fullguard",
"bowstring",
"fletching",
"arrowhead"
};
private static final Map<Integer, Integer> patternCosts = buildPatternCostMap();
@Override
public void getSubItems (Item b, CreativeTabs tab, List list)
{
for (int i = 1; i < patternName.length; i++)
{
public void getSubItems(Item b, CreativeTabs tab, List list) {
for (int i = 1; i < patternName.length; i++) {
// if (i != 23)
list.add(new ItemStack(b, 1, i));
}
}
// 2 for full material, 1 for half.
private static Map<Integer, Integer> buildPatternCostMap()
{
private static Map<Integer, Integer> buildPatternCostMap() {
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(0, 2);
@@ -89,56 +106,44 @@ public class Pattern extends CraftingItem implements IPattern
}
@Override
public ItemStack getContainerItem (ItemStack stack)
{
if (stack.stackSize <= 0)
return null;
public ItemStack getContainerItem(ItemStack stack) {
if (stack.stackSize <= 0) return null;
return stack;
}
@Override
public boolean doesContainerItemLeaveCraftingGrid (ItemStack stack)
{
public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) {
return false;
}
/* Tags and information about the pattern */
@Override
@SideOnly(Side.CLIENT)
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
{
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
float cost = getPatternCost(stack) / 2f;
if (cost > 0)
{
if (cost - (int) cost < 0.1)
list.add(StatCollector.translateToLocal("pattern1.tooltip") + (int) cost);
else
list.add(StatCollector.translateToLocal("pattern2.tooltip") + cost);
if (cost > 0) {
if (cost - (int) cost < 0.1) list.add(StatCollector.translateToLocal("pattern1.tooltip") + (int) cost);
else list.add(StatCollector.translateToLocal("pattern2.tooltip") + cost);
}
}
public static Map<Integer, Integer> getPatternCosts()
{
public static Map<Integer, Integer> getPatternCosts() {
return patternCosts;
}
public static void setPatternCost (Integer index, Integer newCost)
{
if (patternCosts.containsKey(index))
{
public static void setPatternCost(Integer index, Integer newCost) {
if (patternCosts.containsKey(index)) {
patternCosts.put(index, newCost);
}
}
@Override
public int getPatternCost (ItemStack pattern)
{
public int getPatternCost(ItemStack pattern) {
return patternCosts.containsKey(pattern.getItemDamage()) ? patternCosts.get(pattern.getItemDamage()) : 0;
}
@Override
public ItemStack getPatternOutput (ItemStack stack, ItemStack input, MaterialSet set)
{
public ItemStack getPatternOutput(ItemStack stack, ItemStack input, MaterialSet set) {
return TConstructRegistry.getPartMapping((Item) this, stack.getItemDamage(), set.materialID);
}
}
@@ -18,49 +18,43 @@ import tconstruct.world.entity.BlueSlime;
import tconstruct.world.entity.KingBlueSlime;
// spawn egg.
public class TitleIcon extends Item
{
int[] primaryColor = { 0x66BBE8, 0x66BBE8 };
int[] secondaryColor = { 0x1567BF, 0xFFEC6E };
String[] mobNames = { "TConstruct.EdibleSlime", "TConstruct.KingSlime" };
public class TitleIcon extends Item {
int[] primaryColor = {0x66BBE8, 0x66BBE8};
int[] secondaryColor = {0x1567BF, 0xFFEC6E};
String[] mobNames = {"TConstruct.EdibleSlime", "TConstruct.KingSlime"};
String[] achievementIconNames = new String[] { "tinkerer", "preparedFight", "proTinkerer", "enemySlayer", "dualConvenience" };
String[] achievementIconNames =
new String[] {"tinkerer", "preparedFight", "proTinkerer", "enemySlayer", "dualConvenience"};
IIcon[] achievementIcons = new IIcon[achievementIconNames.length];
public TitleIcon()
{
public TitleIcon() {
super();
this.setCreativeTab(CreativeTabs.tabMisc);
this.setHasSubtypes(true);
}
@Override
public void registerIcons (IIconRegister iconRegister)
{
public void registerIcons(IIconRegister iconRegister) {
ToolCore.blankSprite = iconRegister.registerIcon("tinker:blanksprite");
TProxyClient.metalBall = iconRegister.registerIcon("tinker:metalball");
itemIcon = iconRegister.registerIcon("tinker:tparts");
for (int i = 0; i < achievementIcons.length; i++)
{
achievementIcons[i] = iconRegister.registerIcon("tinker:achievementIcons/" + (i < achievementIconNames.length ? achievementIconNames[i] : ""));
for (int i = 0; i < achievementIcons.length; i++) {
achievementIcons[i] = iconRegister.registerIcon(
"tinker:achievementIcons/" + (i < achievementIconNames.length ? achievementIconNames[i] : ""));
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses ()
{
public boolean requiresMultipleRenderPasses() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamageForRenderPass (int par1, int par2)
{
if (par1 == 255)
return itemIcon;
if (par1 >= 4096)
{
public IIcon getIconFromDamageForRenderPass(int par1, int par2) {
if (par1 == 255) return itemIcon;
if (par1 >= 4096) {
return getIconFromDamage(par1);
}
return new ItemStack(Items.spawn_egg).getItem().getIconFromDamageForRenderPass(par1, par2);
@@ -68,13 +62,10 @@ public class TitleIcon extends Item
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage (int par1)
{
if (par1 >= 4096)
{
public IIcon getIconFromDamage(int par1) {
if (par1 >= 4096) {
int index = par1 - 4096;
if (index < achievementIcons.length)
{
if (index < achievementIcons.length) {
return achievementIcons[index];
}
}
@@ -83,13 +74,11 @@ public class TitleIcon extends Item
}
@Override
public String getItemStackDisplayName (ItemStack par1ItemStack)
{
public String getItemStackDisplayName(ItemStack par1ItemStack) {
String s = ("" + StatCollector.translateToLocal(this.getUnlocalizedName() + ".name")).trim();
String s1 = mobNames[par1ItemStack.getItemDamage()];
if (s1 != null)
{
if (s1 != null) {
s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name");
}
@@ -97,101 +86,95 @@ public class TitleIcon extends Item
}
@Override
public void getSubItems (Item b, CreativeTabs tab, List list)
{
for (int i = 0; i < mobNames.length; i++)
list.add(new ItemStack(b, 1, i));
public void getSubItems(Item b, CreativeTabs tab, List list) {
for (int i = 0; i < mobNames.length; i++) list.add(new ItemStack(b, 1, i));
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack (ItemStack stack, int pass)
{
public int getColorFromItemStack(ItemStack stack, int pass) {
int damage = stack.getItemDamage();
if (damage == 255)
return 0xffffff;
if (damage >= 4096)
return 0xffffff;
if (damage == 255) return 0xffffff;
if (damage >= 4096) return 0xffffff;
return pass == 0 ? primaryColor[damage] : secondaryColor[damage];
}
@Override
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int posX, int posY, int posZ, int par7, float par8, float par9, float par10)
{
if (!world.isRemote)
{
public boolean onItemUse(
ItemStack stack,
EntityPlayer player,
World world,
int posX,
int posY,
int posZ,
int par7,
float par8,
float par9,
float par10) {
if (!world.isRemote) {
Block b = world.getBlock(posX, posY, posZ);
posX += Facing.offsetsXForSide[par7];
posY += Facing.offsetsYForSide[par7];
posZ += Facing.offsetsZForSide[par7];
double d0 = 0.0D;
if (par7 == 1 && b != null && b.getRenderType() == 11)
{
if (par7 == 1 && b != null && b.getRenderType() == 11) {
d0 = 0.5D;
}
int damage = stack.getItemDamage();
switch (damage)
{
case 0:
spawnEntity(posX, posY, posZ, new BlueSlime(world), world, player);
break;
case 1:
spawnBossSlime(posX, posY, posZ, new KingBlueSlime(world), world, player);
break;
switch (damage) {
case 0:
spawnEntity(posX, posY, posZ, new BlueSlime(world), world, player);
break;
case 1:
spawnBossSlime(posX, posY, posZ, new KingBlueSlime(world), world, player);
break;
}
if (!player.capabilities.isCreativeMode)
{
if (!player.capabilities.isCreativeMode) {
--stack.stackSize;
}
}
return true;
}
public static EntityLiving activateSpawnEgg (ItemStack stack, World world, double posX, double posY, double posZ, int par7)
{
public static EntityLiving activateSpawnEgg(
ItemStack stack, World world, double posX, double posY, double posZ, int par7) {
Block b = world.getBlock((int) posX, (int) posY, (int) posZ);
posX += Facing.offsetsXForSide[par7];
posY += Facing.offsetsYForSide[par7];
posZ += Facing.offsetsZForSide[par7];
double d0 = 0.0D;
if (par7 == 1 && b != null && b.getRenderType() == 11)
{
if (par7 == 1 && b != null && b.getRenderType() == 11) {
d0 = 0.5D;
}
int damage = stack.getItemDamage();
EntityLiving entity = null;
switch (damage)
{
case 0:
entity = new BlueSlime(world);
spawnEntity(posX, posY, posZ, entity, world);
break;
case 1:
entity = new KingBlueSlime(world);
spawnBossSlime(posX, posY, posZ, new KingBlueSlime(world), world);
break;
switch (damage) {
case 0:
entity = new BlueSlime(world);
spawnEntity(posX, posY, posZ, entity, world);
break;
case 1:
entity = new KingBlueSlime(world);
spawnBossSlime(posX, posY, posZ, new KingBlueSlime(world), world);
break;
}
return entity;
}
public static void spawnEntity (double x, double y, double z, Entity entity, World world)
{
if (!world.isRemote)
{
public static void spawnEntity(double x, double y, double z, Entity entity, World world) {
if (!world.isRemote) {
entity.setPosition(x, y, z);
((EntityLiving) entity).onSpawnWithEgg((IEntityLivingData) null);
world.spawnEntityInWorld(entity);
}
}
public static void spawnEntity (double x, double y, double z, Entity entity, World world, EntityPlayer player)
{
if (!world.isRemote)
{
public static void spawnEntity(double x, double y, double z, Entity entity, World world, EntityPlayer player) {
if (!world.isRemote) {
entity.setPosition(x, y, z);
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
entity.setAngles(player.cameraYaw, player.cameraYaw);
@@ -200,10 +183,9 @@ public class TitleIcon extends Item
}
}
public static void spawnBossSlime (double x, double y, double z, KingBlueSlime entity, World world, EntityPlayer player)
{
if (!world.isRemote)
{
public static void spawnBossSlime(
double x, double y, double z, KingBlueSlime entity, World world, EntityPlayer player) {
if (!world.isRemote) {
entity.setPosition(x, y, z);
entity.setSlimeSize(8);
entity.onSpawnWithEgg((IEntityLivingData) null);
@@ -211,10 +193,8 @@ public class TitleIcon extends Item
}
}
public static void spawnBossSlime (double x, double y, double z, KingBlueSlime entity, World world)
{
if (!world.isRemote)
{
public static void spawnBossSlime(double x, double y, double z, KingBlueSlime entity, World world) {
if (!world.isRemote) {
entity.setPosition(x, y, z);
entity.setSlimeSize(8);
entity.onSpawnWithEgg((IEntityLivingData) null);
@@ -10,12 +10,10 @@ import tconstruct.library.util.IToolPart;
import tconstruct.tools.TinkerTools;
@Deprecated
public class ToolPart extends CraftingItem implements IToolPart
{
public class ToolPart extends CraftingItem implements IToolPart {
public String partName;
public ToolPart(String textureType, String name)
{
public ToolPart(String textureType, String name) {
super(toolMaterialNames, buildTextureNames(textureType), "parts/", "tinker", TConstructRegistry.partTab);
this.setHasSubtypes(true);
this.setMaxDamage(0);
@@ -23,19 +21,15 @@ public class ToolPart extends CraftingItem implements IToolPart
}
@Override
public String getItemStackDisplayName (ItemStack par1ItemStack)
{
public String getItemStackDisplayName(ItemStack par1ItemStack) {
String material = "";
if(par1ItemStack.getItemDamage() < toolTextureNames.length)
if (par1ItemStack.getItemDamage() < toolTextureNames.length)
material = toolTextureNames[par1ItemStack.getItemDamage()];
String name = "";
if (StatCollector.canTranslate("toolpart." + partName + "." + material))
{
if (StatCollector.canTranslate("toolpart." + partName + "." + material)) {
name = StatCollector.translateToLocal("toolpart." + partName + "." + material);
}
else
{
} else {
material = StatCollector.translateToLocal("material." + material);
name = StatCollector.translateToLocal("toolpart." + partName);
name = name.replaceAll("%%material", material);
@@ -44,38 +38,95 @@ public class ToolPart extends CraftingItem implements IToolPart
return name;
}
private static String[] buildTextureNames (String textureType)
{
private static String[] buildTextureNames(String textureType) {
String[] names = new String[toolMaterialNames.length];
for (int i = 0; i < toolMaterialNames.length; i++)
{
if (toolTextureNames[i].equals(""))
names[i] = "";
else
names[i] = toolTextureNames[i] + textureType;
for (int i = 0; i < toolMaterialNames.length; i++) {
if (toolTextureNames[i].equals("")) names[i] = "";
else names[i] = toolTextureNames[i] + textureType;
}
return names;
}
public static final String[] toolMaterialNames = new String[] { "Wood", "Stone", "Iron", "Flint", "Cactus", "Bone", "Obsidian", "Netherrack", "Slime", "Paper", "Cobalt", "Ardite", "Manyullyn", "Copper", "Bronze", "Alumite", "Steel", "Blue Slime", "Pig Iron", "", "", "", "", "", "", "", "", "", "", "", "", "Thaumium" };
public static final String[] toolMaterialNames = new String[] {
"Wood",
"Stone",
"Iron",
"Flint",
"Cactus",
"Bone",
"Obsidian",
"Netherrack",
"Slime",
"Paper",
"Cobalt",
"Ardite",
"Manyullyn",
"Copper",
"Bronze",
"Alumite",
"Steel",
"Blue Slime",
"Pig Iron",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"Thaumium"
};
public static final String[] toolTextureNames = new String[] { "wood", "stone", "iron", "flint", "cactus", "bone", "obsidian", "netherrack", "slime", "paper", "cobalt", "ardite", "manyullyn", "copper", "bronze", "alumite", "steel", "blueslime", "pigiron", "", "", "", "", "", "", "", "", "", "", "", "", "thaumium" };
public static final String[] toolTextureNames = new String[] {
"wood",
"stone",
"iron",
"flint",
"cactus",
"bone",
"obsidian",
"netherrack",
"slime",
"paper",
"cobalt",
"ardite",
"manyullyn",
"copper",
"bronze",
"alumite",
"steel",
"blueslime",
"pigiron",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"thaumium"
};
@Override
public void getSubItems (Item b, CreativeTabs tab, List list)
{
for (int i = 0; i < 19; i++)
list.add(new ItemStack(b, 1, i));
public void getSubItems(Item b, CreativeTabs tab, List list) {
for (int i = 0; i < 19; i++) list.add(new ItemStack(b, 1, i));
if (TinkerTools.thaumcraftAvailable)
list.add(new ItemStack(b, 1, 31));
if (TinkerTools.thaumcraftAvailable) list.add(new ItemStack(b, 1, 31));
}
@Override
public int getMaterialID (ItemStack stack)
{
if (TConstructRegistry.toolMaterials.keySet().contains(stack.getItemDamage()))
return stack.getItemDamage();
public int getMaterialID(ItemStack stack) {
if (TConstructRegistry.toolMaterials.keySet().contains(stack.getItemDamage())) return stack.getItemDamage();
return -1;
}
@@ -5,17 +5,12 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
@Deprecated
public class ToolPartHidden extends ToolPart
{
public class ToolPartHidden extends ToolPart {
public ToolPartHidden(String textureType, String name)
{
public ToolPartHidden(String textureType, String name) {
super(textureType, name);
}
@Override
public void getSubItems (Item id, CreativeTabs tab, List list)
{
}
public void getSubItems(Item id, CreativeTabs tab, List list) {}
}
@@ -1,29 +1,24 @@
package tconstruct.tools.items;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.DynamicToolPart;
import java.util.List;
public class ToolShard extends DynamicToolPart {
public class ToolShard extends DynamicToolPart
{
public ToolShard(String tex, String name)
{
public ToolShard(String tex, String name) {
super(tex, name);
}
@Override
public void getSubItems (Item item, CreativeTabs tab, List list)
{
public void getSubItems(Item item, CreativeTabs tab, List list) {
// material id == metadata
for(Integer matID : TConstructRegistry.defaultShardMaterials) {
for (Integer matID : TConstructRegistry.defaultShardMaterials) {
ItemStack stack = new ItemStack(item, 1, matID);
if (this.getMaterialID(stack) != -1)
list.add(stack);
if (this.getMaterialID(stack) != -1) list.add(stack);
}
}
}