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

+8 -16
View File
@@ -5,33 +5,25 @@ import net.minecraft.item.Item;
import tconstruct.library.crafting.ToolRecipe;
import tconstruct.library.tools.ToolCore;
public class BowRecipe extends ToolRecipe
{
public class BowRecipe extends ToolRecipe {
public BowRecipe(Item head, Item handle, ToolCore tool)
{
public BowRecipe(Item head, Item handle, ToolCore tool) {
super(head, handle, tool);
}
public BowRecipe(Item head, Item handle, Item accessory, ToolCore tool)
{
public BowRecipe(Item head, Item handle, Item accessory, ToolCore tool) {
super(head, handle, accessory, tool);
}
public BowRecipe(Item head, Item handle, Item accessory, Item extra, ToolCore tool)
{
public BowRecipe(Item head, Item handle, Item accessory, Item extra, ToolCore tool) {
super(head, handle, accessory, extra, tool);
}
@Override
public boolean validHead (Item input)
{
for (Item part : headList)
{
if (part == input)
return true;
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
return true;
public boolean validHead(Item input) {
for (Item part : headList) {
if (part == input) return true;
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone)) return true;
}
return false;
}
+104 -119
View File
@@ -20,33 +20,32 @@ import tconstruct.util.config.PHConstruct;
import tconstruct.world.TinkerWorld;
import tconstruct.world.entity.BlueSlime;
public class TActiveOmniMod extends ActiveToolMod
{
public class TActiveOmniMod extends ActiveToolMod {
Random random = new Random();
/* Updating */
@Override
public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity)
{
if (!world.isRemote && entity instanceof EntityLivingBase && !((EntityLivingBase) entity).isSwingInProgress && stack.getTagCompound() != null)
{
if(entity instanceof EntityPlayer && (((EntityPlayer) entity).isUsingItem()))
return;
public void updateTool(ToolCore tool, ItemStack stack, World world, Entity entity) {
if (!world.isRemote
&& entity instanceof EntityLivingBase
&& !((EntityLivingBase) entity).isSwingInProgress
&& stack.getTagCompound() != null) {
if (entity instanceof EntityPlayer && (((EntityPlayer) entity).isUsingItem())) return;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (tags.hasKey("Moss"))
{
if (tags.hasKey("Moss")) {
int chance = tags.getInteger("Moss");
int check = world.canBlockSeeTheSky((int) entity.posX, (int) entity.posY, (int) entity.posZ) ? 350 : 1150;
int check =
world.canBlockSeeTheSky((int) entity.posX, (int) entity.posY, (int) entity.posZ) ? 350 : 1150;
// REGROWING AMMO :OOoo
if(tool instanceof IAmmo && random.nextInt(check*3) < chance) // ammo regenerates at a much slower rate
if (tool instanceof IAmmo
&& random.nextInt(check * 3) < chance) // ammo regenerates at a much slower rate
{
IAmmo ammothing = (IAmmo)tool;
if(ammothing.getAmmoCount(stack) > 0) // must have ammo
ammothing.addAmmo(1, stack);
IAmmo ammothing = (IAmmo) tool;
if (ammothing.getAmmoCount(stack) > 0) // must have ammo
ammothing.addAmmo(1, stack);
}
// selfrepairing tool. LAAAAAME
else if (random.nextInt(check) < chance)
{
else if (random.nextInt(check) < chance) {
AbilityHelper.healTool(stack, 1, (EntityLivingBase) entity, true);
}
}
@@ -55,73 +54,59 @@ public class TActiveOmniMod extends ActiveToolMod
/* Harvesting */
@Override
public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityLivingBase entity)
{
public boolean beforeBlockBreak(ToolCore tool, ItemStack stack, int x, int y, int z, EntityLivingBase entity) {
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
baconator(tool, stack, entity, tags);
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode)
return false;
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode) return false;
TinkerTools.modLapis.midStreamModify(stack, tool);
if (autoSmelt(tool, tags, stack, x, y, z, entity))
return true;
if (autoSmelt(tool, tags, stack, x, y, z, entity)) return true;
return false;
}
@Override
public void afterBlockBreak(ToolCore tool, ItemStack stack, Block block, int x, int y, int z, EntityLivingBase entity) {
public void afterBlockBreak(
ToolCore tool, ItemStack stack, Block block, int x, int y, int z, EntityLivingBase entity) {
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
slimify(tool, tags, block, x,y,z, entity.worldObj);
slimify(tool, tags, block, x, y, z, entity.worldObj);
}
private boolean autoSmelt (ToolCore tool, NBTTagCompound tags, ItemStack stack, int x, int y, int z, EntityLivingBase entity)
{
private boolean autoSmelt(
ToolCore tool, NBTTagCompound tags, ItemStack stack, int x, int y, int z, EntityLivingBase entity) {
World world = entity.worldObj;
Block block = world.getBlock(x, y, z);
if (block == null)
return false;
if (block == null) return false;
int blockMeta = world.getBlockMetadata(x, y, z);
if(block.getMaterial().isToolNotRequired()) {
if (block.getMaterial().isToolNotRequired()) {
// only if effective tool
if(tool instanceof HarvestTool) {
if (!((HarvestTool) tool).isEffective(block, blockMeta))
return false;
}
else
return false;
}
else if(!ForgeHooks.canToolHarvestBlock(block, blockMeta, stack))
return false;
if (tool instanceof HarvestTool) {
if (!((HarvestTool) tool).isEffective(block, blockMeta)) return false;
} else return false;
} else if (!ForgeHooks.canToolHarvestBlock(block, blockMeta, stack)) return false;
if (tags.getBoolean("Lava") && block.quantityDropped(blockMeta, 0, random) > 0)
{
if (tags.getBoolean("Lava") && block.quantityDropped(blockMeta, 0, random) > 0) {
int itemMeta = block.damageDropped(blockMeta);
int amount = block.quantityDropped(random);
Item item = block.getItemDropped(blockMeta, random, EnchantmentHelper.getFortuneModifier(entity));
// apparently some things that don't drop blocks (like glass panes without silktouch) return null.
if (item == null)
return false;
if (item == null) return false;
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(item, amount, itemMeta));
if (result != null)
{
if (result != null) {
world.setBlockToAir(x, y, z);
if (entity instanceof EntityPlayer && !((EntityPlayer) entity).capabilities.isCreativeMode)
tool.onBlockDestroyed(stack, world, block, x, y, z, entity);
if (!world.isRemote)
{
ItemStack spawnme = new ItemStack(result.getItem(), amount * result.stackSize, result.getItemDamage());
if (result.hasTagCompound())
spawnme.setTagCompound(result.getTagCompound());
if (!(result.getItem() instanceof ItemBlock) && PHConstruct.lavaFortuneInteraction)
{
if (!world.isRemote) {
ItemStack spawnme =
new ItemStack(result.getItem(), amount * result.stackSize, result.getItemDamage());
if (result.hasTagCompound()) spawnme.setTagCompound(result.getTagCompound());
if (!(result.getItem() instanceof ItemBlock) && PHConstruct.lavaFortuneInteraction) {
int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack);
if (loot > 0)
{
if (loot > 0) {
spawnme.stackSize *= (random.nextInt(loot + 1) + 1);
}
}
@@ -135,31 +120,26 @@ public class TActiveOmniMod extends ActiveToolMod
float f = FurnaceRecipes.smelting().func_151398_b(spawnme);
int j;
if (f == 0.0F)
{
if (f == 0.0F) {
i = 0;
}
else if (f < 1.0F)
{
} else if (f < 1.0F) {
j = MathHelper.floor_float((float) i * f);
if (j < MathHelper.ceiling_float_int((float) i * f) && (float) Math.random() < (float) i * f - (float) j)
{
if (j < MathHelper.ceiling_float_int((float) i * f)
&& (float) Math.random() < (float) i * f - (float) j) {
++j;
}
i = j;
}
while (i > 0)
{
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
entity.worldObj.spawnEntityInWorld(new EntityXPOrb(world, x, y + 0.5, z, j));
}
}
for (int i = 0; i < 5; i++)
{
for (int i = 0; i < 5; i++) {
float f = (float) x + random.nextFloat();
float f1 = (float) y + random.nextFloat();
float f2 = (float) z + random.nextFloat();
@@ -186,15 +166,21 @@ public class TActiveOmniMod extends ActiveToolMod
/* Attacking */
@Override
public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
public int baseAttackDamage(
int earlyModDamage,
int damage,
ToolCore tool,
NBTTagCompound tags,
NBTTagCompound toolTags,
ItemStack stack,
EntityLivingBase player,
Entity entity) {
TinkerTools.modLapis.midStreamModify(stack, tool);
baconator(tool, stack, player, tags);
return 0;
}
private void baconator (ToolCore tool, ItemStack stack, EntityLivingBase entity, NBTTagCompound tags)
{
private void baconator(ToolCore tool, ItemStack stack, EntityLivingBase entity, NBTTagCompound tags) {
final int pigiron = TinkerTools.MaterialID.PigIron;
int bacon = 0;
bacon += tags.getInteger("Head") == pigiron ? 1 : 0;
@@ -202,37 +188,29 @@ public class TActiveOmniMod extends ActiveToolMod
bacon += tags.getInteger("Accessory") == pigiron ? 1 : 0;
bacon += tags.getInteger("Extra") == pigiron ? 1 : 0;
int chance = tool.getPartAmount() * 100;
if (random.nextInt(chance) < bacon)
{
if (random.nextInt(chance) < bacon) {
if (entity instanceof EntityPlayer)
AbilityHelper.spawnItemAtPlayer((EntityPlayer) entity, new ItemStack(TinkerWorld.strangeFood, 1, 2));
else
AbilityHelper.spawnItemAtEntity(entity, new ItemStack(TinkerWorld.strangeFood, 1, 2), 0);
else AbilityHelper.spawnItemAtEntity(entity, new ItemStack(TinkerWorld.strangeFood, 1, 2), 0);
}
}
private void slimify(ToolCore tool, NBTTagCompound tags, Block block, int x, int y, int z, World world)
{
if (world.isRemote)
return;
private void slimify(ToolCore tool, NBTTagCompound tags, Block block, int x, int y, int z, World world) {
if (world.isRemote) return;
int chance = tool.getPartAmount() * 100;
int count = 0;
int slimeMat = TinkerTools.MaterialID.Slime;
// regular slime
if(tags.getInteger("Head") == slimeMat)
count++;
if(tags.getInteger("Handle") == slimeMat)
count++;
if(tags.getInteger("Accessory") == slimeMat)
count++;
if(tags.getInteger("Extra") == slimeMat)
count++;
if (tags.getInteger("Head") == slimeMat) count++;
if (tags.getInteger("Handle") == slimeMat) count++;
if (tags.getInteger("Accessory") == slimeMat) count++;
if (tags.getInteger("Extra") == slimeMat) count++;
if(random.nextInt(chance) < count) {
if (random.nextInt(chance) < count) {
EntitySlime entity = new EntitySlime(world);
entity.setPosition(x+0.5,y,z+0.5);
entity.setPosition(x + 0.5, y, z + 0.5);
entity.setSlimeSize(1); // minislime!
world.spawnEntityInWorld(entity);
entity.playLivingSound();
@@ -241,18 +219,14 @@ public class TActiveOmniMod extends ActiveToolMod
// blueslime
slimeMat = TinkerTools.MaterialID.BlueSlime;
count = 0;
if(tags.getInteger("Head") == slimeMat)
count++;
if(tags.getInteger("Handle") == slimeMat)
count++;
if(tags.getInteger("Accessory") == slimeMat)
count++;
if(tags.getInteger("Extra") == slimeMat)
count++;
if (tags.getInteger("Head") == slimeMat) count++;
if (tags.getInteger("Handle") == slimeMat) count++;
if (tags.getInteger("Accessory") == slimeMat) count++;
if (tags.getInteger("Extra") == slimeMat) count++;
if(random.nextInt(chance) < count) {
if (random.nextInt(chance) < count) {
BlueSlime entity = new BlueSlime(world);
entity.setPosition(x+0.5,y,z+0.5);
entity.setPosition(x + 0.5, y, z + 0.5);
entity.setSlimeSize(1); // minislime!
world.spawnEntityInWorld(entity);
entity.playLivingSound();
@@ -260,30 +234,31 @@ public class TActiveOmniMod extends ActiveToolMod
}
@Override
public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
public int attackDamage(
int modDamage,
int currentDamage,
ToolCore tool,
NBTTagCompound tags,
NBTTagCompound toolTags,
ItemStack stack,
EntityLivingBase player,
Entity entity) {
int bonus = modDamage;
if (entity instanceof EntityLivingBase)
{
if (entity instanceof EntityLivingBase) {
EnumCreatureAttribute attribute = ((EntityLivingBase) entity).getCreatureAttribute();
if (attribute == EnumCreatureAttribute.UNDEAD)
{
if (tool == TinkerTools.hammer)
{
if (attribute == EnumCreatureAttribute.UNDEAD) {
if (tool == TinkerTools.hammer) {
int level = 2;
bonus += random.nextInt(level * 2 + 1) + level * 2;
}
if (toolTags.hasKey("ModSmite"))
{
if (toolTags.hasKey("ModSmite")) {
int[] array = toolTags.getIntArray("ModSmite");
int base = array[0] / 18;
bonus += 1 + base + random.nextInt(base + 1);
}
}
if (attribute == EnumCreatureAttribute.ARTHROPOD)
{
if (toolTags.hasKey("ModAntiSpider"))
{
if (attribute == EnumCreatureAttribute.ARTHROPOD) {
if (toolTags.hasKey("ModAntiSpider")) {
int[] array = toolTags.getIntArray("ModAntiSpider");
int base = array[0] / 2;
bonus += 1 + base + random.nextInt(base + 1);
@@ -294,11 +269,17 @@ public class TActiveOmniMod extends ActiveToolMod
}
@Override
public float knockback (float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
public float knockback(
float modKnockback,
float currentKnockback,
ToolCore tool,
NBTTagCompound tags,
NBTTagCompound toolTags,
ItemStack stack,
EntityLivingBase player,
Entity entity) {
float bonus = modKnockback;
if (toolTags.hasKey("Knockback"))
{
if (toolTags.hasKey("Knockback")) {
float level = toolTags.getFloat("Knockback");
bonus += level;
}
@@ -306,10 +287,14 @@ public class TActiveOmniMod extends ActiveToolMod
}
@Override
public boolean doesCriticalHit (ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
if (tool == TinkerTools.cutlass && random.nextInt(10) == 0)
return true;
public boolean doesCriticalHit(
ToolCore tool,
NBTTagCompound tags,
NBTTagCompound toolTags,
ItemStack stack,
EntityLivingBase player,
Entity entity) {
if (tool == TinkerTools.cutlass && random.nextInt(10) == 0) return true;
return false;
}
}
@@ -1,10 +1,9 @@
package tconstruct.tools;
import java.util.List;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityCreeper;
@@ -36,42 +35,37 @@ import tconstruct.util.ItemHelper;
import tconstruct.util.config.PHConstruct;
import tconstruct.util.network.MovementUpdatePacket;
public class TinkerToolEvents
{
public class TinkerToolEvents {
@SubscribeEvent
public void onCrafting (ItemCraftedEvent event)
{
if (event.crafting == null || event.player == null || event.player.worldObj == null || event.craftMatrix == null)
return;
public void onCrafting(ItemCraftedEvent event) {
if (event.crafting == null
|| event.player == null
|| event.player.worldObj == null
|| event.craftMatrix == null) return;
Item item = event.crafting.getItem();
if (!event.player.worldObj.isRemote)
{
if (item == Item.getItemFromBlock(TinkerTools.toolStationWood))
{
if (!PHConstruct.beginnerBook)
{
if (!event.player.worldObj.isRemote) {
if (item == Item.getItemFromBlock(TinkerTools.toolStationWood)) {
if (!PHConstruct.beginnerBook) {
return;
}
TPlayerStats stats = TPlayerStats.get(event.player);
if (!stats.materialManual)
{
if (!stats.materialManual) {
stats.materialManual = true;
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TinkerTools.manualBook, 1, 1));
}
}
// slab pattern chest
if(item == Item.getItemFromBlock(TinkerTools.craftingSlabWood) && event.crafting.getItemDamage() == 4) {
if (item == Item.getItemFromBlock(TinkerTools.craftingSlabWood) && event.crafting.getItemDamage() == 4) {
// copy over NBT
for(int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
ItemStack stack = event.craftMatrix.getStackInSlot(i);
if(stack == null)
continue;
if (stack == null) continue;
// regular pattern chest
if(stack.getItem() == Item.getItemFromBlock(TinkerTools.toolStationWood) && stack.getItemDamage() == 5)
{
if (stack.getItem() == Item.getItemFromBlock(TinkerTools.toolStationWood)
&& stack.getItemDamage() == 5) {
event.crafting.setTagCompound(stack.getTagCompound());
break;
}
@@ -81,11 +75,9 @@ public class TinkerToolEvents
}
@SubscribeEvent
public void buildTool (ToolBuildEvent event)
{
public void buildTool(ToolBuildEvent event) {
// check if the handle is a bone
if (event.handleStack.getItem() == Items.bone)
{
if (event.handleStack.getItem() == Items.bone) {
event.handleStack = new ItemStack(TinkerTools.toolRod, 1, 5); // bone tool rod
return;
}
@@ -93,25 +85,21 @@ public class TinkerToolEvents
// check if the handle is a stick
List<ItemStack> sticks = OreDictionary.getOres("stickWood");
for (ItemStack stick : sticks)
if (OreDictionary.itemMatches(stick, event.handleStack, false))
{
if (OreDictionary.itemMatches(stick, event.handleStack, false)) {
event.handleStack = new ItemStack(TinkerTools.toolRod, 1, 0); // wooden tool rod
return;
}
}
@SubscribeEvent
public void craftTool (ToolCraftEvent.NormalTool event)
{
public void craftTool(ToolCraftEvent.NormalTool event) {
NBTTagCompound toolTag = event.toolTag.getCompoundTag("InfiTool");
if (PHConstruct.denyMattock && event.tool == TinkerTools.mattock)
{
if (PHConstruct.denyMattock && event.tool == TinkerTools.mattock) {
int head = toolTag.getInteger("Head");
int handle = toolTag.getInteger("Handle");
int accessory = toolTag.getInteger("Accessory");
if (!allowCrafting(head, handle, accessory))
{
if (!allowCrafting(head, handle, accessory)) {
event.setResult(Result.DENY);
return;
}
@@ -121,169 +109,140 @@ public class TinkerToolEvents
handlePaper(toolTag, event.tool);
handleThaumium(toolTag, event.tool);
if (event.tool == TinkerTools.battlesign)
{
if (event.tool == TinkerTools.battlesign) {
int modifiers = toolTag.getInteger("Modifiers");
modifiers += 1;
toolTag.setInteger("Modifiers", modifiers);
}
}
private void handlePaper (NBTTagCompound toolTag, ToolCore tool)
{
private void handlePaper(NBTTagCompound toolTag, ToolCore tool) {
int modifiers = toolTag.getInteger("Modifiers");
if (toolTag.getInteger("Head") == TinkerTools.MaterialID.Paper)
modifiers++;
if (toolTag.getInteger("Handle") == TinkerTools.MaterialID.Paper)
modifiers++;
if (toolTag.getInteger("Accessory") == TinkerTools.MaterialID.Paper)
modifiers++;
if (toolTag.getInteger("Extra") == TinkerTools.MaterialID.Paper)
modifiers++;
if (toolTag.getInteger("Head") == TinkerTools.MaterialID.Paper) modifiers++;
if (toolTag.getInteger("Handle") == TinkerTools.MaterialID.Paper) modifiers++;
if (toolTag.getInteger("Accessory") == TinkerTools.MaterialID.Paper) modifiers++;
if (toolTag.getInteger("Extra") == TinkerTools.MaterialID.Paper) modifiers++;
// 2 part tools gain 2 modifiers for the head
if (tool.getPartAmount() == 2 && toolTag.getInteger("Head") == TinkerTools.MaterialID.Paper)
modifiers++;
if (tool.getPartAmount() == 2 && toolTag.getInteger("Head") == TinkerTools.MaterialID.Paper) modifiers++;
toolTag.setInteger("Modifiers", modifiers);
}
private void handleThaumium (NBTTagCompound toolTag, ToolCore tool)
{
private void handleThaumium(NBTTagCompound toolTag, ToolCore tool) {
// count thaumic parts
int thaum = 0;
if (toolTag.getInteger("Head") == TinkerTools.MaterialID.Thaumium)
thaum++;
if (toolTag.getInteger("Handle") == TinkerTools.MaterialID.Thaumium)
thaum++;
if (toolTag.getInteger("Accessory") == TinkerTools.MaterialID.Thaumium)
thaum++;
if (toolTag.getInteger("Extra") == TinkerTools.MaterialID.Thaumium)
thaum++;
if (toolTag.getInteger("Head") == TinkerTools.MaterialID.Thaumium) thaum++;
if (toolTag.getInteger("Handle") == TinkerTools.MaterialID.Thaumium) thaum++;
if (toolTag.getInteger("Accessory") == TinkerTools.MaterialID.Thaumium) thaum++;
if (toolTag.getInteger("Extra") == TinkerTools.MaterialID.Thaumium) thaum++;
// each part gives 0.5 modifiers, rounded up
int bonusModifiers = (int) Math.ceil((double) thaum / 2d);
// 2-part tools get 1 modifier per part
if (tool.getPartAmount() == 2)
bonusModifiers = thaum;
if (tool.getPartAmount() == 2) bonusModifiers = thaum;
int modifiers = toolTag.getInteger("Modifiers");
modifiers += bonusModifiers;
toolTag.setInteger("Modifiers", modifiers);
}
private boolean allowCrafting (int head, int handle, int accessory)
{
int[] nonMetals = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 17 };
for (int i = 0; i < nonMetals.length; i++)
{
if (head == nonMetals[i] || handle == nonMetals[i] || accessory == nonMetals[i])
return false;
private boolean allowCrafting(int head, int handle, int accessory) {
int[] nonMetals = {0, 1, 3, 4, 5, 6, 7, 8, 9, 17};
for (int i = 0; i < nonMetals.length; i++) {
if (head == nonMetals[i] || handle == nonMetals[i] || accessory == nonMetals[i]) return false;
}
return true;
}
@SubscribeEvent
public void craftPart (PartBuilderEvent.NormalPart event)
{
public void craftPart(PartBuilderEvent.NormalPart event) {
// bowstring
if (event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 23)
{
if (event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 23) {
ItemStack result = craftBowString(event.material);
if (result != null)
{
event.overrideResult(new ItemStack[] { result, null });
if (result != null) {
event.overrideResult(new ItemStack[] {result, null});
}
}
// fletching
if (event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 24)
{
if (event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 24) {
ItemStack result = craftFletching(event.material);
if (result != null)
{
event.overrideResult(new ItemStack[] { result, null });
if (result != null) {
event.overrideResult(new ItemStack[] {result, null});
}
}
}
public static ItemStack craftBowString (ItemStack stack)
{
if (stack.stackSize < 3)
return null;
public static ItemStack craftBowString(ItemStack stack) {
if (stack.stackSize < 3) return null;
BowstringMaterial mat = (BowstringMaterial) TConstructRegistry.getCustomMaterial(stack, BowstringMaterial.class);
if (mat != null)
return mat.craftingItem.copy();
BowstringMaterial mat =
(BowstringMaterial) TConstructRegistry.getCustomMaterial(stack, BowstringMaterial.class);
if (mat != null) return mat.craftingItem.copy();
return null;
}
public static ItemStack craftFletching (ItemStack stack)
{
FletchingMaterial mat = (FletchingMaterial) TConstructRegistry.getCustomMaterial(stack, FletchingMaterial.class);
public static ItemStack craftFletching(ItemStack stack) {
FletchingMaterial mat =
(FletchingMaterial) TConstructRegistry.getCustomMaterial(stack, FletchingMaterial.class);
// maybe it's a leaf fletchling
if (mat == null)
mat = (FletchingMaterial) TConstructRegistry.getCustomMaterial(stack, FletchlingLeafMaterial.class);
if (mat != null)
return mat.craftingItem.copy();
if (mat != null) return mat.craftingItem.copy();
return null;
}
@SubscribeEvent
public void onAttack (LivingAttackEvent event)
{
//System.out.println("Damage: "+event.ammount);
if (event.entityLiving instanceof EntityPlayer)
{
public void onAttack(LivingAttackEvent event) {
// System.out.println("Damage: "+event.ammount);
if (event.entityLiving instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entityLiving;
//Cutlass
// Cutlass
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.getItem() == TinkerTools.battlesign)
{
if (stack != null && stack.getItem() == TinkerTools.battlesign) {
// broken battlesign?
if(!stack.hasTagCompound() || stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken"))
return;
if (!stack.hasTagCompound()
|| stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken")) return;
DamageSource source = event.source;
if (!source.isUnblockable() && !source.isMagicDamage() && !source.isExplosion())
{
if (source.isProjectile())
{
if (!source.isUnblockable() && !source.isMagicDamage() && !source.isExplosion()) {
if (source.isProjectile()) {
Entity projectile = source.getSourceOfDamage();
if(projectile == null)
return;
Vec3 motion = Vec3.createVectorHelper(projectile.motionX, projectile.motionY, projectile.motionZ);
if (projectile == null) return;
Vec3 motion =
Vec3.createVectorHelper(projectile.motionX, projectile.motionY, projectile.motionZ);
Vec3 look = player.getLookVec();
// this gives a factor of how much we're looking at the incoming arrow
double strength = -look.dotProduct(motion.normalize());
// we're looking away. oh no.
if(strength < 0.1)
return;
if (strength < 0.1) return;
// no damage, hooraaay
event.setCanceled(true);
double speed = projectile.motionX*projectile.motionX + projectile.motionY*projectile.motionY + projectile.motionZ*projectile.motionZ;
double speed = projectile.motionX * projectile.motionX
+ projectile.motionY * projectile.motionY
+ projectile.motionZ * projectile.motionZ;
speed = Math.sqrt(speed);
speed = (speed+2)*strength;
speed = (speed + 2) * strength;
// now we simply set the look vector with the speed and get our new vector!
projectile.motionX = look.xCoord * speed;
projectile.motionY = look.yCoord * speed;
projectile.motionZ = look.zCoord * speed;
projectile.rotationYaw = (float)(Math.atan2(projectile.motionX, projectile.motionZ) * 180.0D / Math.PI);
projectile.rotationPitch = (float)(Math.atan2(projectile.motionY, speed) * 180.0D / Math.PI);
projectile.rotationYaw =
(float) (Math.atan2(projectile.motionX, projectile.motionZ) * 180.0D / Math.PI);
projectile.rotationPitch = (float) (Math.atan2(projectile.motionY, speed) * 180.0D / Math.PI);
// send the current status to the client
TConstruct.packetPipeline.sendToAll(new MovementUpdatePacket(projectile));
if(projectile instanceof EntityArrow) {
if (projectile instanceof EntityArrow) {
((EntityArrow) projectile).shootingEntity = player;
// the inverse is done when the event is cancelled in arrows etc.
@@ -291,110 +250,95 @@ public class TinkerToolEvents
projectile.motionX /= -0.10000000149011612D;
projectile.motionY /= -0.10000000149011612D;
projectile.motionZ /= -0.10000000149011612D;
// projectile.rotationYaw -= 180.0F;
// projectile.prevRotationYaw -= 180.0F;
// projectile.rotationYaw -= 180.0F;
// projectile.prevRotationYaw -= 180.0F;
// not needed at the client since it gets the absolute values sent
// tinker projectiles don't check for stuff hit to prevent weird behaviour.
// we have to de-defuse them so the reflected projectiles can hit stuff again
if(projectile instanceof ProjectileBase)
((ProjectileBase) projectile).defused = false;
if (projectile instanceof ProjectileBase) ((ProjectileBase) projectile).defused = false;
}
}
else
{
} else {
Entity attacker = source.getEntity();
if (attacker != null)
{
if (attacker != null) {
attacker.attackEntityFrom(DamageSource.causeThornsDamage(player), event.ammount);
}
}
// durability--
AbilityHelper.damageTool(stack, (int)Math.ceil(event.ammount/2f), player, false);
AbilityHelper.damageTool(stack, (int) Math.ceil(event.ammount / 2f), player, false);
}
}
}
}
@SubscribeEvent
public void onLivingDrop (LivingDropsEvent event)
{
if (event.entityLiving == null)
return;
public void onLivingDrop(LivingDropsEvent event) {
if (event.entityLiving == null) return;
if (event.recentlyHit)
{
if (event.entityLiving instanceof EntitySkeleton)
{
if (event.recentlyHit) {
if (event.entityLiving instanceof EntitySkeleton) {
EntitySkeleton enemy = (EntitySkeleton) event.entityLiving;
if (event.source.damageType.equals("player"))
{
if (event.source.damageType.equals("player")) {
EntityPlayer player = (EntityPlayer) event.source.getEntity();
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack.getItem() == TinkerTools.cleaver)
beheading += 2;
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 10)
{
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) {
int beheading = stack.getTagCompound()
.getCompoundTag("InfiTool")
.getInteger("Beheading");
if (stack.getItem() == TinkerTools.cleaver) beheading += 2;
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 10) {
ItemHelper.addDrops(event, new ItemStack(Items.skull, 1, enemy.getSkeletonType()));
}
}
}
if (enemy.getSkeletonType() == 1 && TConstruct.random.nextInt(Math.max(1, 5 - event.lootingLevel)) == 0)
{
if (enemy.getSkeletonType() == 1
&& TConstruct.random.nextInt(Math.max(1, 5 - event.lootingLevel)) == 0) {
ItemHelper.addDrops(event, new ItemStack(TinkerTools.materials, 1, 8));
}
}
if (event.entityLiving.getClass() == EntityZombie.class)
{
if (event.entityLiving.getClass() == EntityZombie.class) {
EntityZombie enemy = (EntityZombie) event.entityLiving;
if (event.source.damageType.equals("player"))
{
if (event.source.damageType.equals("player")) {
EntityPlayer player = (EntityPlayer) event.source.getEntity();
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) {
int beheading = stack.getTagCompound()
.getCompoundTag("InfiTool")
.getInteger("Beheading");
if (stack != null && stack.hasTagCompound() && stack.getItem() == TinkerTools.cleaver)
beheading += 2;
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 10)
{
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 10) {
ItemHelper.addDrops(event, new ItemStack(Items.skull, 1, 2));
}
}
if (stack != null && stack.hasTagCompound() && stack.getItem() == TinkerTools.cleaver && TConstruct.random.nextInt(100) < 10)
{
if (stack != null
&& stack.hasTagCompound()
&& stack.getItem() == TinkerTools.cleaver
&& TConstruct.random.nextInt(100) < 10) {
ItemHelper.addDrops(event, new ItemStack(Items.skull, 1, 2));
}
}
}
if (event.entityLiving.getClass() == EntityCreeper.class)
{
if (event.entityLiving.getClass() == EntityCreeper.class) {
EntityCreeper enemy = (EntityCreeper) event.entityLiving;
if (event.source.damageType.equals("player"))
{
if (event.source.damageType.equals("player")) {
EntityPlayer player = (EntityPlayer) event.source.getEntity();
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack.getItem() == TinkerTools.cleaver)
beheading += 2;
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 5)
{
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) {
int beheading = stack.getTagCompound()
.getCompoundTag("InfiTool")
.getInteger("Beheading");
if (stack.getItem() == TinkerTools.cleaver) beheading += 2;
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 5) {
ItemHelper.addDrops(event, new ItemStack(Items.skull, 1, 4));
}
}
@@ -402,30 +346,23 @@ public class TinkerToolEvents
}
}
if (event.entityLiving instanceof EntityPlayer)
{
if (event.entityLiving instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (PHConstruct.dropPlayerHeads)
{
if (PHConstruct.dropPlayerHeads) {
ItemStack dropStack = new ItemStack(Items.skull, 1, 3);
NBTTagCompound nametag = new NBTTagCompound();
nametag.setString("SkullOwner", player.getDisplayName());
dropStack.setTagCompound(nametag);
ItemHelper.addDrops(event, dropStack);
}
else if (event.source.damageType.equals("player"))
{
} else if (event.source.damageType.equals("player")) {
EntityPlayer source = (EntityPlayer) event.source.getEntity();
ItemStack stack = source.getCurrentEquippedItem();
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack.getItem() == TinkerTools.cleaver)
beheading += 2;
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 50)
{
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore) {
int beheading =
stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack.getItem() == TinkerTools.cleaver) beheading += 2;
if (beheading > 0 && TConstruct.random.nextInt(100) < beheading * 50) {
ItemStack dropStack = new ItemStack(Items.skull, 1, 3);
NBTTagCompound nametag = new NBTTagCompound();
nametag.setString("SkullOwner", player.getDisplayName());
@@ -438,53 +375,41 @@ public class TinkerToolEvents
}
@SubscribeEvent
public void registerOre (OreRegisterEvent evt)
{
public void registerOre(OreRegisterEvent evt) {
if (evt.Name.equals("crystalQuartz"))
{
if (evt.Name.equals("crystalQuartz")) {
TinkerTools.modAttack.addStackToMatchList(evt.Ore, 2);
}
else if (evt.Name.equals("crystalCertusQuartz"))
{
} else if (evt.Name.equals("crystalCertusQuartz")) {
TinkerTools.modAttack.addStackToMatchList(evt.Ore, 24);
}
}
@SubscribeEvent
public void damageToolsOnDeath (PlayerDropsEvent event)
{
if(!PHConstruct.deathPenality)
return;
public void damageToolsOnDeath(PlayerDropsEvent event) {
if (!PHConstruct.deathPenality) return;
EnumDifficulty difficulty = event.entityPlayer.worldObj.difficultySetting;
// easy and peaceful don't punish
if(difficulty == EnumDifficulty.PEACEFUL || difficulty == EnumDifficulty.EASY)
return;
if (difficulty == EnumDifficulty.PEACEFUL || difficulty == EnumDifficulty.EASY) return;
int punishment = 20; // normal has 5%
if(difficulty == EnumDifficulty.HARD)
punishment = 10; // hard has 10%
if (difficulty == EnumDifficulty.HARD) punishment = 10; // hard has 10%
// check if we have to reduce it
// did the player live long enough to receive derp-protection?
// (yes, you receive protection every time you log in. we're that nice.)
int derp = 1;
if(event.entityPlayer.ticksExisted < 60*5*20 ) {
if (event.entityPlayer.ticksExisted < 60 * 5 * 20) {
derp = TPlayerStats.get(event.entityPlayer).derpLevel;
if(derp <= 0) derp = 1;
if (derp <= 0) derp = 1;
punishment *= derp;
}
boolean damaged = false;
for(EntityItem drop : event.drops)
{
for (EntityItem drop : event.drops) {
// we're only interested in tools
if(!(drop.getEntityItem().getItem() instanceof ToolCore) || !drop.getEntityItem().hasTagCompound())
continue;
if (!(drop.getEntityItem().getItem() instanceof ToolCore)
|| !drop.getEntityItem().hasTagCompound()) continue;
// damage tools by 10% of their total durability!
NBTTagCompound tags = drop.getEntityItem().getTagCompound().getCompoundTag("InfiTool");
@@ -495,11 +420,11 @@ public class TinkerToolEvents
damaged = true;
}
if(damaged) {
if (damaged) {
derp++;
}
// increase derplevel by 1. Minimal derp level is 1.
TPlayerStats.get(event.entityPlayer).derpLevel = derp+1;
TPlayerStats.get(event.entityPlayer).derpLevel = derp + 1;
}
}
File diff suppressed because it is too large. Load diff
@@ -1,5 +1,7 @@
package tconstruct.tools;
import static tconstruct.tools.TinkerTools.*;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import mantle.client.MProxyClient;
@@ -15,7 +17,6 @@ import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.common.MinecraftForge;
import tconstruct.TConstruct;
import tconstruct.client.FlexibleToolRenderer;
import tconstruct.client.ToolCoreRenderer;
import tconstruct.client.entity.projectile.*;
import tconstruct.client.pages.*;
import tconstruct.common.TProxyCommon;
@@ -31,13 +32,9 @@ import tconstruct.tools.logic.*;
import tconstruct.tools.model.*;
import tconstruct.weaponry.TinkerWeaponry;
import static tconstruct.tools.TinkerTools.*;
public class ToolProxyClient extends ToolProxyCommon
{
public class ToolProxyClient extends ToolProxyCommon {
@Override
public void initialize ()
{
public void initialize() {
MinecraftForge.EVENT_BUS.register(this);
registerRenderer();
registerGuiHandler();
@@ -48,19 +45,19 @@ public class ToolProxyClient extends ToolProxyCommon
addToolButtons();
}
public void registerRenderer ()
{
public void registerRenderer() {
RenderingRegistry.registerBlockHandler(new TableRender());
RenderingRegistry.registerBlockHandler(new FrypanRender());
RenderingRegistry.registerBlockHandler(new BattlesignRender());
RenderingRegistry.registerEntityRenderingHandler(LaunchedPotion.class, new LaunchedItemRender(Items.potionitem, 16384));
RenderingRegistry.registerEntityRenderingHandler(
LaunchedPotion.class, new LaunchedItemRender(Items.potionitem, 16384));
RenderingRegistry.registerEntityRenderingHandler(DaggerEntity.class, new DaggerEntityRenderer());
//RenderingRegistry.registerEntityRenderingHandler(DaggerEntity.class, new DaggerRenderCustom());
//RenderingRegistry.registerEntityRenderingHandler(ArrowEntity.class, new ArrowRenderCustom());
// RenderingRegistry.registerEntityRenderingHandler(DaggerEntity.class, new DaggerRenderCustom());
// RenderingRegistry.registerEntityRenderingHandler(ArrowEntity.class, new ArrowRenderCustom());
RenderingRegistry.registerEntityRenderingHandler(FancyEntityItem.class, new FancyItemRender());
//MinecraftForgeClient.registerItemRenderer(TinkerTools.shortbow, new CustomBowRenderer());
// MinecraftForgeClient.registerItemRenderer(TinkerTools.shortbow, new CustomBowRenderer());
FlexibleToolRenderer renderer = new FlexibleToolRenderer();
MinecraftForgeClient.registerItemRenderer(TinkerTools.pickaxe, renderer);
MinecraftForgeClient.registerItemRenderer(TinkerTools.shovel, renderer);
@@ -80,36 +77,147 @@ public class ToolProxyClient extends ToolProxyCommon
MinecraftForgeClient.registerItemRenderer(TinkerTools.rapier, renderer);
MinecraftForgeClient.registerItemRenderer(TinkerTools.scythe, renderer);
MinecraftForgeClient.registerItemRenderer(TinkerTools.dagger, renderer);
//ToolCoreRenderer daggerRenderer = new ToolCoreRenderer(true);
//MinecraftForgeClient.registerItemRenderer(TinkerTools.dagger, daggerRenderer); // todo proper renderer
// ToolCoreRenderer daggerRenderer = new ToolCoreRenderer(true);
// MinecraftForgeClient.registerItemRenderer(TinkerTools.dagger, daggerRenderer); // todo proper renderer
TileEntityRendererDispatcher.instance.mapSpecialRenderers.put(BattlesignLogic.class, new BattlesignTesr());
}
public void registerManualIcons ()
{
public void registerManualIcons() {
// ToolIcons
MantleClientRegistry.registerManualIcon("pickicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.pickaxeHead, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), new ItemStack(TinkerTools.binding, 1, 12), ""));
MantleClientRegistry.registerManualIcon("shovelicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.shovelHead, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), null, ""));
MantleClientRegistry.registerManualIcon("axeicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.hatchetHead, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), null, ""));
MantleClientRegistry.registerManualIcon("mattockicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.hatchetHead, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), new ItemStack(TinkerTools.shovelHead, 1, 12), ""));
MantleClientRegistry.registerManualIcon("swordicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.swordBlade, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), new ItemStack(TinkerTools.wideGuard, 1, 12), ""));
MantleClientRegistry.registerManualIcon("longswordicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.swordBlade, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), new ItemStack(TinkerTools.handGuard, 1, 12), ""));
MantleClientRegistry.registerManualIcon("rapiericon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.swordBlade, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), new ItemStack(TinkerTools.crossbar, 1, 12), ""));
MantleClientRegistry.registerManualIcon("daggerIcon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.knifeBlade, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), new ItemStack(TinkerTools.crossbar, 1, 12), ""));
MantleClientRegistry.registerManualIcon("frypanicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.frypanHead, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), null, ""));
MantleClientRegistry.registerManualIcon("battlesignicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.signHead, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), null, ""));
MantleClientRegistry.registerManualIcon("chiselicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.chiselHead, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), null, ""));
//MantleClientRegistry.registerManualIcon("shortbowIcon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.toolRod, 1, 10), new ItemStack(TinkerWeaponry.bowstring, 1, 0), new ItemStack(TinkerTools.toolRod, 1, 12), ""));
//MantleClientRegistry.registerManualIcon("arrowIcon", ToolBuilder.instance.buildTool(new ItemStack(TinkerWeaponry.arrowhead, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), new ItemStack(TinkerWeaponry.fletching, 1, 0), ""));
MantleClientRegistry.registerManualIcon(
"pickicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.pickaxeHead, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
new ItemStack(TinkerTools.binding, 1, 12),
""));
MantleClientRegistry.registerManualIcon(
"shovelicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.shovelHead, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
null,
""));
MantleClientRegistry.registerManualIcon(
"axeicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.hatchetHead, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
null,
""));
MantleClientRegistry.registerManualIcon(
"mattockicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.hatchetHead, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
new ItemStack(TinkerTools.shovelHead, 1, 12),
""));
MantleClientRegistry.registerManualIcon(
"swordicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.swordBlade, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
new ItemStack(TinkerTools.wideGuard, 1, 12),
""));
MantleClientRegistry.registerManualIcon(
"longswordicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.swordBlade, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
new ItemStack(TinkerTools.handGuard, 1, 12),
""));
MantleClientRegistry.registerManualIcon(
"rapiericon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.swordBlade, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
new ItemStack(TinkerTools.crossbar, 1, 12),
""));
MantleClientRegistry.registerManualIcon(
"daggerIcon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.knifeBlade, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
new ItemStack(TinkerTools.crossbar, 1, 12),
""));
MantleClientRegistry.registerManualIcon(
"frypanicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.frypanHead, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
null,
""));
MantleClientRegistry.registerManualIcon(
"battlesignicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.signHead, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
null,
""));
MantleClientRegistry.registerManualIcon(
"chiselicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.chiselHead, 1, 10),
new ItemStack(TinkerTools.toolRod, 1, 11),
null,
""));
// MantleClientRegistry.registerManualIcon("shortbowIcon", ToolBuilder.instance.buildTool(new
// ItemStack(TinkerTools.toolRod, 1, 10), new ItemStack(TinkerWeaponry.bowstring, 1, 0), new
// ItemStack(TinkerTools.toolRod, 1, 12), ""));
// MantleClientRegistry.registerManualIcon("arrowIcon", ToolBuilder.instance.buildTool(new
// ItemStack(TinkerWeaponry.arrowhead, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 11), new
// ItemStack(TinkerWeaponry.fletching, 1, 0), ""));
MantleClientRegistry.registerManualIcon("hammericon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.hammerHead, 1, 10), new ItemStack(TinkerTools.toughRod, 1, 11), new ItemStack(TinkerTools.largePlate, 1, 12), new ItemStack(TinkerTools.largePlate, 8), ""));
MantleClientRegistry.registerManualIcon("lumbericon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.broadAxeHead, 1, 10), new ItemStack(TinkerTools.toughRod, 1, 11), new ItemStack(TinkerTools.largePlate, 1, 12), new ItemStack(TinkerTools.toughBinding, 8), ""));
MantleClientRegistry.registerManualIcon("excavatoricon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.excavatorHead, 1, 10), new ItemStack(TinkerTools.toughRod, 1, 11), new ItemStack(TinkerTools.largePlate, 1, 12), new ItemStack(TinkerTools.toughBinding, 8), ""));
MantleClientRegistry.registerManualIcon("scytheicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.scytheBlade, 1, 10), new ItemStack(TinkerTools.toughRod, 1, 11), new ItemStack(TinkerTools.toughBinding, 1, 12), new ItemStack(TinkerTools.toughRod, 8), ""));
MantleClientRegistry.registerManualIcon("cleavericon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.largeSwordBlade, 1, 10), new ItemStack(TinkerTools.toughRod, 1, 11), new ItemStack(TinkerTools.largePlate, 1, 12), new ItemStack(TinkerTools.toughRod, 8), ""));
MantleClientRegistry.registerManualIcon("battleaxeicon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.broadAxeHead, 1, 10), new ItemStack(TinkerTools.toughRod, 1, 11), new ItemStack(TinkerTools.broadAxeHead, 1, 12), new ItemStack(TinkerTools.toughBinding, 8), ""));
MantleClientRegistry.registerManualIcon(
"hammericon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.hammerHead, 1, 10),
new ItemStack(TinkerTools.toughRod, 1, 11),
new ItemStack(TinkerTools.largePlate, 1, 12),
new ItemStack(TinkerTools.largePlate, 8),
""));
MantleClientRegistry.registerManualIcon(
"lumbericon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.broadAxeHead, 1, 10),
new ItemStack(TinkerTools.toughRod, 1, 11),
new ItemStack(TinkerTools.largePlate, 1, 12),
new ItemStack(TinkerTools.toughBinding, 8),
""));
MantleClientRegistry.registerManualIcon(
"excavatoricon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.excavatorHead, 1, 10),
new ItemStack(TinkerTools.toughRod, 1, 11),
new ItemStack(TinkerTools.largePlate, 1, 12),
new ItemStack(TinkerTools.toughBinding, 8),
""));
MantleClientRegistry.registerManualIcon(
"scytheicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.scytheBlade, 1, 10),
new ItemStack(TinkerTools.toughRod, 1, 11),
new ItemStack(TinkerTools.toughBinding, 1, 12),
new ItemStack(TinkerTools.toughRod, 8),
""));
MantleClientRegistry.registerManualIcon(
"cleavericon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.largeSwordBlade, 1, 10),
new ItemStack(TinkerTools.toughRod, 1, 11),
new ItemStack(TinkerTools.largePlate, 1, 12),
new ItemStack(TinkerTools.toughRod, 8),
""));
MantleClientRegistry.registerManualIcon(
"battleaxeicon",
ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.broadAxeHead, 1, 10),
new ItemStack(TinkerTools.toughRod, 1, 11),
new ItemStack(TinkerTools.broadAxeHead, 1, 12),
new ItemStack(TinkerTools.toughBinding, 8),
""));
// Tool parts
MantleClientRegistry.registerManualIcon("pickhead", new ItemStack(TinkerTools.pickaxeHead, 1, 2));
@@ -142,14 +250,14 @@ public class ToolProxyClient extends ToolProxyCommon
MantleClientRegistry.registerManualIcon("arrowhead", new ItemStack(TinkerWeaponry.arrowhead, 1, 2));
MantleClientRegistry.registerManualIcon("fletching", new ItemStack(TinkerWeaponry.fletching, 1, 0));
//Tables
// Tables
MantleClientRegistry.registerManualIcon("blankpattern", new ItemStack(TinkerTools.blankPattern, 1, 0));
MantleClientRegistry.registerManualIcon("toolstation", new ItemStack(TinkerTools.toolStationWood, 1, 0));
MantleClientRegistry.registerManualIcon("partcrafter", new ItemStack(TinkerTools.toolStationWood, 1, 1));
MantleClientRegistry.registerManualIcon("patternchest", new ItemStack(TinkerTools.toolStationWood, 1, 5));
MantleClientRegistry.registerManualIcon("stenciltable", new ItemStack(TinkerTools.toolStationWood, 1, 10));
//TODO: Untwine this
// TODO: Untwine this
MantleClientRegistry.registerManualIcon("blueslimecrystal", new ItemStack(TinkerTools.materials, 1, 17));
MantleClientRegistry.registerManualIcon("slimecrystal", new ItemStack(TinkerTools.materials, 1, 1));
MantleClientRegistry.registerManualIcon("paperstack", new ItemStack(TinkerTools.materials, 1, 0));
@@ -170,8 +278,7 @@ public class ToolProxyClient extends ToolProxyCommon
MProxyClient.registerManualPage("modifier", ModifierPage.class);
}
void registerManualRecipes ()
{
void registerManualRecipes() {
ItemStack pattern = new ItemStack(TinkerTools.blankPattern, 1, 0);
ItemStack silkyCloth = new ItemStack(TinkerTools.materials, 1, 25);
@@ -193,67 +300,204 @@ public class ToolProxyClient extends ToolProxyCommon
ItemStack sand = new ItemStack(Blocks.sand, 1, 0);
ItemStack searedbrickBlock = new ItemStack(TinkerSmeltery.smeltery, 1, 2);
MantleClientRegistry.registerManualLargeRecipe("alternatebook", new ItemStack(Items.book), paper, paper, paper, string, pattern, pattern, null, null, null);
MantleClientRegistry.registerManualSmallRecipe("patternbook1", new ItemStack(TinkerTools.manualBook, 1, 0), new ItemStack(Items.paper), pattern, null, null);
MantleClientRegistry.registerManualSmallRecipe("patternbook2", new ItemStack(TinkerTools.manualBook, 1, 1), new ItemStack(TinkerTools.manualBook, 1, 0), null, null, null);
MantleClientRegistry.registerManualSmallRecipe("patternbook3", new ItemStack(TinkerTools.manualBook, 1, 2), new ItemStack(TinkerTools.manualBook, 1, 1), null, null, null);
MantleClientRegistry.registerManualLargeRecipe(
"alternatebook",
new ItemStack(Items.book),
paper,
paper,
paper,
string,
pattern,
pattern,
null,
null,
null);
MantleClientRegistry.registerManualSmallRecipe(
"patternbook1",
new ItemStack(TinkerTools.manualBook, 1, 0),
new ItemStack(Items.paper),
pattern,
null,
null);
MantleClientRegistry.registerManualSmallRecipe(
"patternbook2",
new ItemStack(TinkerTools.manualBook, 1, 1),
new ItemStack(TinkerTools.manualBook, 1, 0),
null,
null,
null);
MantleClientRegistry.registerManualSmallRecipe(
"patternbook3",
new ItemStack(TinkerTools.manualBook, 1, 2),
new ItemStack(TinkerTools.manualBook, 1, 1),
null,
null,
null);
MantleClientRegistry.registerManualSmallRecipe("blankpattern", pattern, plank, stick, stick, plank);
MantleClientRegistry.registerManualSmallRecipe("toolstation", new ItemStack(TinkerTools.toolStationWood, 1, 0), null, pattern, null, workbench);
MantleClientRegistry.registerManualSmallRecipe("partcrafter", new ItemStack(TinkerTools.toolStationWood, 1, 1), null, pattern, null, log);
MantleClientRegistry.registerManualSmallRecipe("patternchest", new ItemStack(TinkerTools.toolStationWood, 1, 5), null, pattern, null, chest);
MantleClientRegistry.registerManualSmallRecipe("stenciltable", new ItemStack(TinkerTools.toolStationWood, 1, 10), null, pattern, null, plank);
MantleClientRegistry.registerManualSmallRecipe(
"toolstation", new ItemStack(TinkerTools.toolStationWood, 1, 0), null, pattern, null, workbench);
MantleClientRegistry.registerManualSmallRecipe(
"partcrafter", new ItemStack(TinkerTools.toolStationWood, 1, 1), null, pattern, null, log);
MantleClientRegistry.registerManualSmallRecipe(
"patternchest", new ItemStack(TinkerTools.toolStationWood, 1, 5), null, pattern, null, chest);
MantleClientRegistry.registerManualSmallRecipe(
"stenciltable", new ItemStack(TinkerTools.toolStationWood, 1, 10), null, pattern, null, plank);
MantleClientRegistry.registerManualLargeRecipe("toolforge", new ItemStack(TinkerTools.toolForge, 1, 0), searedbrickBlock, searedbrickBlock, searedbrickBlock, ironblock, new ItemStack(TinkerTools.toolStationWood, 1, 0), ironblock, ironblock, null, ironblock); //TODO: Alternate recipe for Smeltery disabled
MantleClientRegistry.registerManualLargeRecipe(
"toolforge",
new ItemStack(TinkerTools.toolForge, 1, 0),
searedbrickBlock,
searedbrickBlock,
searedbrickBlock,
ironblock,
new ItemStack(TinkerTools.toolStationWood, 1, 0),
ironblock,
ironblock,
null,
ironblock); // TODO: Alternate recipe for Smeltery disabled
MantleClientRegistry.registerManualLargeRecipe("slimymud", slimyMud, null, slimeball, slimeball, null, slimeball, slimeball, null, dirt, sand);
MantleClientRegistry.registerManualFurnaceRecipe("slimecrystal", new ItemStack(TinkerTools.materials, 1, 1), slimyMud);
MantleClientRegistry.registerManualSmallRecipe("paperstack", new ItemStack(TinkerTools.materials, 1, 0), paper, paper, paper, paper);
MantleClientRegistry.registerManualLargeRecipe("mossball", new ItemStack(TinkerTools.materials, 1, 6), mossycobble, mossycobble, mossycobble, mossycobble, mossycobble, mossycobble, mossycobble, mossycobble, mossycobble);
MantleClientRegistry.registerManualLargeRecipe("lavacrystal", new ItemStack(TinkerTools.materials, 1, 7), blazerod, firecharge, blazerod, firecharge, new ItemStack(Items.lava_bucket), firecharge, blazerod, firecharge, blazerod);
MantleClientRegistry.registerManualLargeRecipe("silkycloth", silkyCloth, string, string, string, string, new ItemStack(TinkerTools.materials, 1, 24), string, string, string, string);
MantleClientRegistry.registerManualLargeRecipe("silkyjewel", new ItemStack(TinkerTools.materials, 1, 26), null, silkyCloth, null, silkyCloth, new ItemStack(Items.emerald), silkyCloth, null, silkyCloth, null);
MantleClientRegistry.registerManualLargeRecipe(
"slimymud", slimyMud, null, slimeball, slimeball, null, slimeball, slimeball, null, dirt, sand);
MantleClientRegistry.registerManualFurnaceRecipe(
"slimecrystal", new ItemStack(TinkerTools.materials, 1, 1), slimyMud);
MantleClientRegistry.registerManualSmallRecipe(
"paperstack", new ItemStack(TinkerTools.materials, 1, 0), paper, paper, paper, paper);
MantleClientRegistry.registerManualLargeRecipe(
"mossball",
new ItemStack(TinkerTools.materials, 1, 6),
mossycobble,
mossycobble,
mossycobble,
mossycobble,
mossycobble,
mossycobble,
mossycobble,
mossycobble,
mossycobble);
MantleClientRegistry.registerManualLargeRecipe(
"lavacrystal",
new ItemStack(TinkerTools.materials, 1, 7),
blazerod,
firecharge,
blazerod,
firecharge,
new ItemStack(Items.lava_bucket),
firecharge,
blazerod,
firecharge,
blazerod);
MantleClientRegistry.registerManualLargeRecipe(
"silkycloth",
silkyCloth,
string,
string,
string,
string,
new ItemStack(TinkerTools.materials, 1, 24),
string,
string,
string,
string);
MantleClientRegistry.registerManualLargeRecipe(
"silkyjewel",
new ItemStack(TinkerTools.materials, 1, 26),
null,
silkyCloth,
null,
silkyCloth,
new ItemStack(Items.emerald),
silkyCloth,
null,
silkyCloth,
null);
// Modifier recipes
ItemStack ironpick = ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.pickaxeHead, 1, 6), new ItemStack(TinkerTools.toolRod, 1, 2), new ItemStack(TinkerTools.binding, 1, 6), "");
ItemStack ironpick = ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.pickaxeHead, 1, 6),
new ItemStack(TinkerTools.toolRod, 1, 2),
new ItemStack(TinkerTools.binding, 1, 6),
"");
MantleClientRegistry.registerManualIcon("ironpick", ironpick);
ItemStack ironlongsword = ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.swordBlade, 1, 6), new ItemStack(TinkerTools.toolRod, 1, 2), new ItemStack(TinkerTools.handGuard, 1, 10), "");
ItemStack ironlongsword = ToolBuilder.instance.buildTool(
new ItemStack(TinkerTools.swordBlade, 1, 6),
new ItemStack(TinkerTools.toolRod, 1, 2),
new ItemStack(TinkerTools.handGuard, 1, 10),
"");
MantleClientRegistry.registerManualIcon("ironlongsword", ironlongsword);
TConstructClientRegistry.registerManualModifier("diamondmod", ironpick.copy(), new ItemStack(Items.diamond));
TConstructClientRegistry.registerManualModifier("emeraldmod", ironpick.copy(), new ItemStack(Items.emerald));
TConstructClientRegistry.registerManualModifier("redstonemod", ironpick.copy(), new ItemStack(Items.redstone), new ItemStack(Blocks.redstone_block));
TConstructClientRegistry.registerManualModifier("lavacrystalmod", ironpick.copy(), new ItemStack(TinkerTools.materials, 1, 7));
TConstructClientRegistry.registerManualModifier("lapismod", ironpick.copy(), new ItemStack(Items.dye, 1, 4), new ItemStack(Blocks.lapis_block));
TConstructClientRegistry.registerManualModifier("mossmod", ironpick.copy(), new ItemStack(TinkerTools.materials, 1, 6));
TConstructClientRegistry.registerManualModifier("quartzmod", ironlongsword.copy(), new ItemStack(Items.quartz), new ItemStack(Blocks.quartz_block));
TConstructClientRegistry.registerManualModifier("blazemod", ironlongsword.copy(), new ItemStack(Items.blaze_powder));
TConstructClientRegistry.registerManualModifier("necroticmod", ironlongsword.copy(), new ItemStack(TinkerTools.materials, 1, 8));
TConstructClientRegistry.registerManualModifier("silkymod", ironpick.copy(), new ItemStack(TinkerTools.materials, 1, 26));
TConstructClientRegistry.registerManualModifier("reinforcedmod", ironpick.copy(), new ItemStack(TinkerTools.largePlate, 1, 6));
TConstructClientRegistry.registerManualModifier(
"redstonemod", ironpick.copy(), new ItemStack(Items.redstone), new ItemStack(Blocks.redstone_block));
TConstructClientRegistry.registerManualModifier(
"lavacrystalmod", ironpick.copy(), new ItemStack(TinkerTools.materials, 1, 7));
TConstructClientRegistry.registerManualModifier(
"lapismod", ironpick.copy(), new ItemStack(Items.dye, 1, 4), new ItemStack(Blocks.lapis_block));
TConstructClientRegistry.registerManualModifier(
"mossmod", ironpick.copy(), new ItemStack(TinkerTools.materials, 1, 6));
TConstructClientRegistry.registerManualModifier(
"quartzmod", ironlongsword.copy(), new ItemStack(Items.quartz), new ItemStack(Blocks.quartz_block));
TConstructClientRegistry.registerManualModifier(
"blazemod", ironlongsword.copy(), new ItemStack(Items.blaze_powder));
TConstructClientRegistry.registerManualModifier(
"necroticmod", ironlongsword.copy(), new ItemStack(TinkerTools.materials, 1, 8));
TConstructClientRegistry.registerManualModifier(
"silkymod", ironpick.copy(), new ItemStack(TinkerTools.materials, 1, 26));
TConstructClientRegistry.registerManualModifier(
"reinforcedmod", ironpick.copy(), new ItemStack(TinkerTools.largePlate, 1, 6));
TConstructClientRegistry.registerManualModifier("pistonmod", ironlongsword.copy(), new ItemStack(Blocks.piston));
TConstructClientRegistry.registerManualModifier("beheadingmod", ironlongsword.copy(), new ItemStack(Items.ender_pearl), new ItemStack(Blocks.obsidian));
TConstructClientRegistry.registerManualModifier("spidermod", ironlongsword.copy(), new ItemStack(Items.fermented_spider_eye));
TConstructClientRegistry.registerManualModifier("smitemod", ironlongsword.copy(), new ItemStack(TinkerTools.craftedSoil, 1, 4));
TConstructClientRegistry.registerManualModifier(
"pistonmod", ironlongsword.copy(), new ItemStack(Blocks.piston));
TConstructClientRegistry.registerManualModifier(
"beheadingmod", ironlongsword.copy(), new ItemStack(Items.ender_pearl), new ItemStack(Blocks.obsidian));
TConstructClientRegistry.registerManualModifier(
"spidermod", ironlongsword.copy(), new ItemStack(Items.fermented_spider_eye));
TConstructClientRegistry.registerManualModifier(
"smitemod", ironlongsword.copy(), new ItemStack(TinkerTools.craftedSoil, 1, 4));
TConstructClientRegistry.registerManualModifier("fluxmod", ironpick.copy(), new ItemStack(Blocks.dirt));
TConstructClientRegistry.registerManualModifier("fluxmod2", ironpick.copy(), new ItemStack(Blocks.dirt));
TConstructClientRegistry.registerManualModifier("tier1free", ironpick.copy(), new ItemStack(Items.diamond), new ItemStack(Blocks.gold_block));
TConstructClientRegistry.registerManualModifier("tier1.5free", ironpick.copy(), new ItemStack(Items.golden_apple, 1, 1), new ItemStack(Blocks.diamond_block));
TConstructClientRegistry.registerManualModifier(
"tier1free", ironpick.copy(), new ItemStack(Items.diamond), new ItemStack(Blocks.gold_block));
TConstructClientRegistry.registerManualModifier(
"tier1.5free",
ironpick.copy(),
new ItemStack(Items.golden_apple, 1, 1),
new ItemStack(Blocks.diamond_block));
TConstructClientRegistry.registerManualModifier("tier2free", ironpick.copy(), new ItemStack(Items.nether_star));
TConstructClientRegistry.registerManualModifier("creativefree", ironpick.copy(), new ItemStack(TinkerTools.creativeModifier));
TConstructClientRegistry.registerManualModifier(
"creativefree", ironpick.copy(), new ItemStack(TinkerTools.creativeModifier));
TConstructClientRegistry.registerManualSmeltery("brownstone", new ItemStack(TinkerSmeltery.speedBlock), new ItemStack(TinkerSmeltery.moltenTin, 1), new ItemStack(Blocks.gravel));
TConstructClientRegistry.registerManualSmeltery("clearglass", new ItemStack(TinkerSmeltery.clearGlass), new ItemStack(TinkerSmeltery.moltenGlass, 1), null);
TConstructClientRegistry.registerManualSmeltery("searedstone", new ItemStack(TinkerSmeltery.smeltery, 1, 4), new ItemStack(TinkerSmeltery.moltenStone, 1), null);
TConstructClientRegistry.registerManualSmeltery("endstone", new ItemStack(Blocks.end_stone), new ItemStack(TinkerSmeltery.moltenEnder, 1), new ItemStack(Blocks.obsidian));
TConstructClientRegistry.registerManualSmeltery("glueball", new ItemStack(TinkerTools.materials, 1, 36), new ItemStack(TinkerSmeltery.glueFluidBlock, 1), null);
TConstructClientRegistry.registerManualSmeltery(
"brownstone",
new ItemStack(TinkerSmeltery.speedBlock),
new ItemStack(TinkerSmeltery.moltenTin, 1),
new ItemStack(Blocks.gravel));
TConstructClientRegistry.registerManualSmeltery(
"clearglass",
new ItemStack(TinkerSmeltery.clearGlass),
new ItemStack(TinkerSmeltery.moltenGlass, 1),
null);
TConstructClientRegistry.registerManualSmeltery(
"searedstone",
new ItemStack(TinkerSmeltery.smeltery, 1, 4),
new ItemStack(TinkerSmeltery.moltenStone, 1),
null);
TConstructClientRegistry.registerManualSmeltery(
"endstone",
new ItemStack(Blocks.end_stone),
new ItemStack(TinkerSmeltery.moltenEnder, 1),
new ItemStack(Blocks.obsidian));
TConstructClientRegistry.registerManualSmeltery(
"glueball",
new ItemStack(TinkerTools.materials, 1, 36),
new ItemStack(TinkerSmeltery.glueFluidBlock, 1),
null);
}
@Override
protected void registerGuiHandler ()
{
protected void registerGuiHandler() {
super.registerGuiHandler();
TProxyCommon.registerClientGuiHandler(toolStationID, this);
TProxyCommon.registerClientGuiHandler(partBuilderID, this);
@@ -267,25 +511,29 @@ public class ToolProxyClient extends ToolProxyCommon
}
@Override
public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == ToolProxyCommon.toolStationID)
return new ToolStationGui(player.inventory, (ToolStationLogic) world.getTileEntity(x, y, z), world, x, y, z);
return new ToolStationGui(
player.inventory, (ToolStationLogic) world.getTileEntity(x, y, z), world, x, y, z);
if (ID == ToolProxyCommon.partBuilderID)
return new PartCrafterGui(player.inventory, (PartBuilderLogic) world.getTileEntity(x, y, z), world, x, y, z);
return new PartCrafterGui(
player.inventory, (PartBuilderLogic) world.getTileEntity(x, y, z), world, x, y, z);
if (ID == ToolProxyCommon.patternChestID)
return new PatternChestGui(player.inventory, (PatternChestLogic) world.getTileEntity(x, y, z), world, x, y, z);
return new PatternChestGui(
player.inventory, (PatternChestLogic) world.getTileEntity(x, y, z), world, x, y, z);
if (ID == ToolProxyCommon.frypanGuiID)
return new FrypanGui(player.inventory, (FrypanLogic) world.getTileEntity(x, y, z), world, x, y, z);
if (ID == ToolProxyCommon.battlesignTextID)
return new BattlesignGui((BattlesignLogic) world.getTileEntity(x, y, z));
if (ID == ToolProxyCommon.stencilTableID)
return new StencilTableGui(player.inventory, (StencilTableLogic) world.getTileEntity(x, y, z), world, x, y, z);
return new StencilTableGui(
player.inventory, (StencilTableLogic) world.getTileEntity(x, y, z), world, x, y, z);
if (ID == ToolProxyCommon.toolForgeID)
return new ToolForgeGui(player.inventory, (ToolForgeLogic) world.getTileEntity(x, y, z), world, x, y, z);
if (ID == ToolProxyCommon.craftingStationID)
return new CraftingStationGui(player.inventory, (CraftingStationLogic) world.getTileEntity(x, y, z), world, x, y, z);
return new CraftingStationGui(
player.inventory, (CraftingStationLogic) world.getTileEntity(x, y, z), world, x, y, z);
if (ID == ToolProxyCommon.furnaceID)
return new FurnaceGui(player.inventory, (FurnaceLogic) world.getTileEntity(x, y, z));
@@ -294,10 +542,8 @@ public class ToolProxyClient extends ToolProxyCommon
}
@SubscribeEvent
public void onSound (SoundLoadEvent event)
{
try
{
public void onSound(SoundLoadEvent event) {
try {
/*
* SoundManager soundmanager = event.manager;
* soundmanager.addSound("tinker:frypan_hit.ogg");
@@ -305,163 +551,220 @@ public class ToolProxyClient extends ToolProxyCommon
* soundmanager.addSound("tinker:launcher_clank.ogg");
* TConstruct.logger.info("Successfully loaded sounds.");
*/
}
catch (Exception e)
{
} catch (Exception e) {
TConstruct.logger.error("Failed to register one or more sounds");
}
MinecraftForge.EVENT_BUS.unregister(this);
}
void addStencilButtons ()
{
int[][] icons = { { 0, 3 }, // tool rod
{ 1, 3 }, // binding
{ 8, 3 }, // large tool rod
{ 9, 3 }, // large binding
{ 0, 2 }, // pickaxe head
{ 3, 2 }, // shovel head
{ 2, 2 }, // hatchet head
{ 8, 2 }, // scythe
{ 11, 2 }, // hammer head
{ 10, 2 }, // excavator head
{ 6, 2 }, // lumberaxe head
{ 9, 2 }, // large plate
{}, { 4, 2 }, // frying pan
{ 5, 2 }, // battlesign
{ 7, 3 }, // chisel
{}, { 7, 2 }, // knifeblade
{ 1, 2 }, // swordblade
{ 6, 3 }, // cleaver blade
{}, { 4, 3 }, // crossbar
{ 3, 3 }, // small guard
{ 2, 3 }, // wide guard
void addStencilButtons() {
int[][] icons = {
{0, 3}, // tool rod
{1, 3}, // binding
{8, 3}, // large tool rod
{9, 3}, // large binding
{0, 2}, // pickaxe head
{3, 2}, // shovel head
{2, 2}, // hatchet head
{8, 2}, // scythe
{11, 2}, // hammer head
{10, 2}, // excavator head
{6, 2}, // lumberaxe head
{9, 2}, // large plate
{}, {4, 2}, // frying pan
{5, 2}, // battlesign
{7, 3}, // chisel
{}, {7, 2}, // knifeblade
{1, 2}, // swordblade
{6, 3}, // cleaver blade
{}, {4, 3}, // crossbar
{3, 3}, // small guard
{2, 3}, // wide guard
};
int i = 0;
for (int[] icon : icons)
{
for (int[] icon : icons) {
// spacer
if(icon.length == 0)
{
if (icon.length == 0) {
addStencilButton(0, 0, -1);
}
else
addStencilButton(icon[0], icon[1], i++);
} else addStencilButton(icon[0], icon[1], i++);
}
}
void addStencilButton (int xButton, int yButton, int index)
{
void addStencilButton(int xButton, int yButton, int index) {
TConstructClientRegistry.addStencilButton(xButton, yButton, index, "tinker", "textures/gui/icons.png");
}
static int[][] itemIconsT1 = {
new int[] { 1, 4, 0 }, // Pickaxe
new int[] { 2, 5, 0 }, // Shovel
new int[] { 2, 6, 0 }, // Hatchet
new int[] { 3, 8, 0 }, // Mattock
new int[] { 1, 0, 1 }, // Broadsword
new int[] { 1, 1, 1 }, // Longsword
new int[] { 1, 2, 1 }, // Rapier
new int[] { 1, 5, 1 }, // Dagger
new int[] { 2, 3, 1 }, // Frying pan
new int[] { 2, 4, 1 }, // Battlesign
new int[] { 2, 6, 1 } // Chisel
new int[] {1, 4, 0}, // Pickaxe
new int[] {2, 5, 0}, // Shovel
new int[] {2, 6, 0}, // Hatchet
new int[] {3, 8, 0}, // Mattock
new int[] {1, 0, 1}, // Broadsword
new int[] {1, 1, 1}, // Longsword
new int[] {1, 2, 1}, // Rapier
new int[] {1, 5, 1}, // Dagger
new int[] {2, 3, 1}, // Frying pan
new int[] {2, 4, 1}, // Battlesign
new int[] {2, 6, 1} // Chisel
};
static int[][] iconCoordsT1 = {
new int[] { 0, 0, 1, 13 }, new int[] { 2, 3, 3, 13 }, // Pickaxe
new int[] { 3, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, // Shovel
new int[] { 2, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, // Hatchet
new int[] { 2, 0, 3, 13 }, new int[] { 2, 3, 2, 13 }, // Mattock
new int[] { 1, 0, 2, 13 }, new int[] { 2, 3, 3, 13 }, // Broadsword
new int[] { 1, 0, 3, 13 }, new int[] { 2, 3, 3, 13 }, // Longsword
new int[] { 1, 0, 4, 13 }, new int[] { 2, 3, 3, 13 }, // Rapier
new int[] { 7, 0, 4, 13 }, new int[] { 2, 3, 3, 13 }, // Dagger
new int[] { 4, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, // Frying Pan
new int[] { 5, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, // Battlesign
new int[] { 7, 0, 13, 13 }, new int[] { 3, 3, 13, 13 } // Chisel
new int[] {0, 0, 1, 13}, new int[] {2, 3, 3, 13}, // Pickaxe
new int[] {3, 0, 13, 13}, new int[] {2, 3, 13, 13}, // Shovel
new int[] {2, 0, 13, 13}, new int[] {2, 3, 13, 13}, // Hatchet
new int[] {2, 0, 3, 13}, new int[] {2, 3, 2, 13}, // Mattock
new int[] {1, 0, 2, 13}, new int[] {2, 3, 3, 13}, // Broadsword
new int[] {1, 0, 3, 13}, new int[] {2, 3, 3, 13}, // Longsword
new int[] {1, 0, 4, 13}, new int[] {2, 3, 3, 13}, // Rapier
new int[] {7, 0, 4, 13}, new int[] {2, 3, 3, 13}, // Dagger
new int[] {4, 0, 13, 13}, new int[] {2, 3, 13, 13}, // Frying Pan
new int[] {5, 0, 13, 13}, new int[] {2, 3, 13, 13}, // Battlesign
new int[] {7, 0, 13, 13}, new int[] {3, 3, 13, 13} // Chisel
};
static int[][] itemIconsT2 = {
new int[] { 6, 13, 0, }, // Hammer
new int[] { 5, 11, 0, }, // Lumberaxe
new int[] { 5, 12, 0, }, // Excavator
new int[] { 4, 10, 0, }, // Scythe
new int[] { 5, 7, 1, }, // Cleaver
new int[] { 5, 8, 1, }, // Battleaxe
new int[] {
6, 13, 0,
}, // Hammer
new int[] {
5, 11, 0,
}, // Lumberaxe
new int[] {
5, 12, 0,
}, // Excavator
new int[] {
4, 10, 0,
}, // Scythe
new int[] {
5, 7, 1,
}, // Cleaver
new int[] {
5, 8, 1,
}, // Battleaxe
};
static int[][] iconCoordsT2 = {
new int[] { 11, 8, 9, 9 }, new int[] { 2, 3, 2, 2 }, // Hammer
new int[] { 6, 8, 9, 9 }, new int[] { 2, 3, 2, 3 }, // Lumberaxe
new int[] { 10, 8, 9, 9 }, new int[] { 2, 3, 2, 3 }, // Excavator
new int[] { 8, 8, 9, 8 }, new int[] { 2, 3, 3, 3 }, // Scythe
new int[] { 6, 8, 9, 8 }, new int[] { 3, 3, 2, 3 }, // Cleaver
new int[] { 6, 8, 6, 9 }, new int[] { 2, 3, 2, 3 }, // Battleaxe
new int[] {11, 8, 9, 9}, new int[] {2, 3, 2, 2}, // Hammer
new int[] {6, 8, 9, 9}, new int[] {2, 3, 2, 3}, // Lumberaxe
new int[] {10, 8, 9, 9}, new int[] {2, 3, 2, 3}, // Excavator
new int[] {8, 8, 9, 8}, new int[] {2, 3, 3, 3}, // Scythe
new int[] {6, 8, 9, 8}, new int[] {3, 3, 2, 3}, // Cleaver
new int[] {6, 8, 6, 9}, new int[] {2, 3, 2, 3}, // Battleaxe
};
void addToolButtons ()
{
final ToolCore[] tier1Tools = {pickaxe, shovel, hatchet, mattock, broadsword, longsword, rapier, dagger, frypan, battlesign, chisel};
void addToolButtons() {
final ToolCore[] tier1Tools = {
pickaxe, shovel, hatchet, mattock, broadsword, longsword, rapier, dagger, frypan, battlesign, chisel
};
final ToolCore[] tier2Tools = {hammer, lumberaxe, excavator, scythe, cleaver, battleaxe};
// repair
addToolButton(0, 3, 0, new int[] { 0, 1, 2, 13 }, new int[] { 13, 13, 13, 13 }, StatCollector.translateToLocal("gui.toolforge1"), "gui.toolforge2");
addToolButton(
0,
3,
0,
new int[] {0, 1, 2, 13},
new int[] {13, 13, 13, 13},
StatCollector.translateToLocal("gui.toolforge1"),
"gui.toolforge2");
// tier 1 tools
for (int i = 0; i < tier1Tools.length; i++)
{
String locString = String.format("gui.toolstation.%s.desc", tier1Tools[i].getToolName().toLowerCase());
addToolButton(itemIconsT1[i][0], itemIconsT1[i][1], itemIconsT1[i][2], iconCoordsT1[i * 2], iconCoordsT1[i * 2 + 1], tier1Tools[i].getLocalizedToolName(), locString);
for (int i = 0; i < tier1Tools.length; i++) {
String locString = String.format(
"gui.toolstation.%s.desc", tier1Tools[i].getToolName().toLowerCase());
addToolButton(
itemIconsT1[i][0],
itemIconsT1[i][1],
itemIconsT1[i][2],
iconCoordsT1[i * 2],
iconCoordsT1[i * 2 + 1],
tier1Tools[i].getLocalizedToolName(),
locString);
}
// tier 2 tools
for (int i = 0; i < tier2Tools.length; i++)
{
String locString = String.format("gui.toolstation.%s.desc", tier2Tools[i].getToolName().toLowerCase());
addTierTwoButton(itemIconsT2[i][0], itemIconsT2[i][1], itemIconsT2[i][2], iconCoordsT2[i * 2], iconCoordsT2[i * 2 + 1], tier2Tools[i].getLocalizedToolName(), locString);
for (int i = 0; i < tier2Tools.length; i++) {
String locString = String.format(
"gui.toolstation.%s.desc", tier2Tools[i].getToolName().toLowerCase());
addTierTwoButton(
itemIconsT2[i][0],
itemIconsT2[i][1],
itemIconsT2[i][2],
iconCoordsT2[i * 2],
iconCoordsT2[i * 2 + 1],
tier2Tools[i].getLocalizedToolName(),
locString);
}
}
void addToolButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body)
{
TConstructClientRegistry.addToolButton(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, "tinker", "textures/gui/icons.png"));
void addToolButton(int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body) {
TConstructClientRegistry.addToolButton(new ToolGuiElement(
slotType, xButton, yButton, xIcons, yIcons, title, body, "tinker", "textures/gui/icons.png"));
}
void addTierTwoButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body)
{
TConstructClientRegistry.addTierTwoButton(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, "tinker", "textures/gui/icons.png"));
void addTierTwoButton(
int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body) {
TConstructClientRegistry.addTierTwoButton(new ToolGuiElement(
slotType, xButton, yButton, xIcons, yIcons, title, body, "tinker", "textures/gui/icons.png"));
}
void addToolRenderMappings ()
{
String[] partTypes = { "wood", "stone", "iron", "flint", "cactus", "bone", "obsidian", "netherrack", "slime", "paper", "cobalt", "ardite", "manyullyn", "copper", "bronze", "alumite", "steel", "blueslime", "pigiron" };
String[] effectTypes = { "diamond", "emerald", "redstone", "piston", "moss", "ice", "lava", "blaze", "necrotic", "flux", "lapis", "quartz", "silk", "beheading", "smite", "spider", "reinforced", "flux" };
int[] universalEffects = { 0, 1, 4, 9, 16 };
int[] weaponEffects = { 3, 5, 7, 13, 14, 15 };
int[] harvestEffects = { 2 };
int[] nonUtility = { 6, 8, 10, 11, 12 };
void addToolRenderMappings() {
String[] partTypes = {
"wood",
"stone",
"iron",
"flint",
"cactus",
"bone",
"obsidian",
"netherrack",
"slime",
"paper",
"cobalt",
"ardite",
"manyullyn",
"copper",
"bronze",
"alumite",
"steel",
"blueslime",
"pigiron"
};
String[] effectTypes = {
"diamond",
"emerald",
"redstone",
"piston",
"moss",
"ice",
"lava",
"blaze",
"necrotic",
"flux",
"lapis",
"quartz",
"silk",
"beheading",
"smite",
"spider",
"reinforced",
"flux"
};
int[] universalEffects = {0, 1, 4, 9, 16};
int[] weaponEffects = {3, 5, 7, 13, 14, 15};
int[] harvestEffects = {2};
int[] nonUtility = {6, 8, 10, 11, 12};
for (int partIter = 0; partIter < partTypes.length; partIter++)
{
for (int partIter = 0; partIter < partTypes.length; partIter++) {
TConstructClientRegistry.addMaterialRenderMapping(partIter, "tinker", partTypes[partIter], true);
}
for (ToolCore tool : TConstructRegistry.getToolMapping())
{
for (int i = 0; i < effectTypes.length; i++)
{
for (ToolCore tool : TConstructRegistry.getToolMapping()) {
for (int i = 0; i < effectTypes.length; i++) {
TConstructClientRegistry.addEffectRenderMapping(tool, i, "tinker", effectTypes[i], true);
}
}
}
}
@@ -7,8 +7,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import tconstruct.common.TProxyCommon;
public class ToolProxyCommon implements IGuiHandler
{
public class ToolProxyCommon implements IGuiHandler {
public static final int toolStationID = 0;
public static final int partBuilderID = 1;
public static final int patternChestID = 2;
@@ -19,17 +18,13 @@ public class ToolProxyCommon implements IGuiHandler
public static final int craftingStationID = 11;
public static final int battlesignTextID = 12;
public ToolProxyCommon()
{
}
public ToolProxyCommon() {}
public void initialize ()
{
public void initialize() {
registerGuiHandler();
}
protected void registerGuiHandler ()
{
protected void registerGuiHandler() {
TProxyCommon.registerServerGuiHandler(toolStationID, this);
TProxyCommon.registerServerGuiHandler(partBuilderID, this);
TProxyCommon.registerServerGuiHandler(patternChestID, this);
@@ -41,19 +36,16 @@ public class ToolProxyCommon implements IGuiHandler
}
@Override
public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof InventoryLogic)
{
if (tile != null && tile instanceof InventoryLogic) {
return ((InventoryLogic) tile).getGuiContainer(player.inventory, world, x, y, z);
}
return null;
}
@Override
public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
}
@@ -12,84 +12,102 @@ import net.minecraft.world.*;
import tconstruct.tools.logic.BattlesignLogic;
import tconstruct.tools.model.BattlesignRender;
public class BattlesignBlock extends EquipBlock
{
public class BattlesignBlock extends EquipBlock {
public BattlesignBlock(Material material)
{
public BattlesignBlock(Material material) {
super(material);
this.setBlockBounds(0.45F, 0F, 0.45F, 0.55F, 1.125F, 0.55F);
}
@Override
public int getRenderType ()
{
public int getRenderType() {
return BattlesignRender.battlesignModelID;
}
@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered (IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_)
{
return p_149646_5_ == 0 && this.minY > 0.0D ? true : (p_149646_5_ == 1 && this.maxY < 1.0D ? true : (p_149646_5_ == 2 && this.minZ > 0.0D ? true : (p_149646_5_ == 3 && this.maxZ < 1.0D ? true : (p_149646_5_ == 4 && this.minX > 0.0D ? true : (p_149646_5_ == 5 && this.maxX < 1.0D ? true : !(p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_).isOpaqueCube() && p_149646_1_.getBlock(p_149646_2_, p_149646_3_ + 1, p_149646_4_).isOpaqueCube()))))));
public boolean shouldSideBeRendered(
IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) {
return p_149646_5_ == 0 && this.minY > 0.0D
? true
: (p_149646_5_ == 1 && this.maxY < 1.0D
? true
: (p_149646_5_ == 2 && this.minZ > 0.0D
? true
: (p_149646_5_ == 3 && this.maxZ < 1.0D
? true
: (p_149646_5_ == 4 && this.minX > 0.0D
? true
: (p_149646_5_ == 5 && this.maxX < 1.0D
? true
: !(p_149646_1_
.getBlock(p_149646_2_, p_149646_3_, p_149646_4_)
.isOpaqueCube()
&& p_149646_1_
.getBlock(
p_149646_2_,
p_149646_3_ + 1,
p_149646_4_)
.isOpaqueCube()))))));
}
@Override
public TileEntity createNewTileEntity (World world, int metadata)
{
public TileEntity createNewTileEntity(World world, int metadata) {
return new BattlesignLogic();
}
@Override
public void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
public void onBlockPlacedBy(
World par1World,
int par2,
int par3,
int par4,
EntityLivingBase par5EntityLivingBase,
ItemStack par6ItemStack) {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int newMeta = 0;
switch (i3)
{
case 3:
newMeta = 0;
break;
case 0:
newMeta = 3;
break;
case 1:
newMeta = 1;
break;
case 2:
newMeta = 2;
break;
switch (i3) {
case 3:
newMeta = 0;
break;
case 0:
newMeta = 3;
break;
case 1:
newMeta = 1;
break;
case 2:
newMeta = 2;
break;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2);
}
@Override
public void setBlockBoundsBasedOnState (IBlockAccess blockAccess, int x, int y, int z)
{
switch (blockAccess.getBlockMetadata(x, y, z))
{
case 0:
setBlockBounds(0.42F, 0.5F, 0F, 0.50F, 1.1F, 1F);
break;
case 1:
setBlockBounds(0.50F, 0.5F, 0F, 0.58F, 1.1F, 1F);
break;
case 2:
setBlockBounds(0F, 0.5F, 0.50F, 1F, 1.1F, 0.58F);
break;
case 3:
setBlockBounds(0F, 0.5F, 0.42F, 1F, 1.1F, 0.50F);
break;
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
switch (blockAccess.getBlockMetadata(x, y, z)) {
case 0:
setBlockBounds(0.42F, 0.5F, 0F, 0.50F, 1.1F, 1F);
break;
case 1:
setBlockBounds(0.50F, 0.5F, 0F, 0.58F, 1.1F, 1F);
break;
case 2:
setBlockBounds(0F, 0.5F, 0.50F, 1F, 1.1F, 0.58F);
break;
case 3:
setBlockBounds(0F, 0.5F, 0.42F, 1F, 1.1F, 0.50F);
break;
}
}
@Override
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity)
{
public void addCollisionBoxesToList(
World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) {
setBlockBoundsBasedOnState(world, x, y, z);
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
@@ -100,15 +118,12 @@ public class BattlesignBlock extends EquipBlock
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
public TileEntity createTileEntity(World world, int metadata) {
return new BattlesignLogic();
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
return null;
}
}
@@ -20,10 +20,8 @@ import tconstruct.tools.*;
import tconstruct.tools.logic.*;
import tconstruct.util.config.PHConstruct;
public class CraftingSlab extends InventorySlab
{
public CraftingSlab(Material material)
{
public class CraftingSlab extends InventorySlab {
public CraftingSlab(Material material) {
super(material);
this.setCreativeTab(TConstructRegistry.blockTab);
this.setHardness(2f);
@@ -32,115 +30,129 @@ public class CraftingSlab extends InventorySlab
/* Rendering */
@Override
public String[] getTextureNames ()
{
String[] textureNames = { "craftingstation_top", "craftingstation_slab_side", "craftingstation_bottom", "toolstation_top", "toolstation_slab_side", "toolstation_bottom", "partbuilder_oak_top", "partbuilder_slab_side", "partbuilder_oak_bottom", "stenciltable_oak_top", "stenciltable_slab_side", "stenciltable_oak_bottom", "patternchest_top", "patternchest_slab_side", "patternchest_bottom", "toolforge_top", "toolforge_slab_side", "toolforge_top" };
public String[] getTextureNames() {
String[] textureNames = {
"craftingstation_top",
"craftingstation_slab_side",
"craftingstation_bottom",
"toolstation_top",
"toolstation_slab_side",
"toolstation_bottom",
"partbuilder_oak_top",
"partbuilder_slab_side",
"partbuilder_oak_bottom",
"stenciltable_oak_top",
"stenciltable_slab_side",
"stenciltable_oak_bottom",
"patternchest_top",
"patternchest_slab_side",
"patternchest_bottom",
"toolforge_top",
"toolforge_slab_side",
"toolforge_top"
};
return textureNames;
}
@Override
public String getTextureDomain (int textureNameIndex)
{
public String getTextureDomain(int textureNameIndex) {
return "tinker";
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
public IIcon getIcon(int side, int meta) {
return icons[(meta % 8) * 3 + getTextureIndex(side)];
}
public int getTextureIndex (int side)
{
if (side == 0)
return 2;
if (side == 1)
return 0;
public int getTextureIndex(int side) {
if (side == 0) return 2;
if (side == 1) return 0;
return 1;
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
{
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 5)
return AxisAlignedBB.getBoundingBox((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125, (double) z + this.maxZ);
return AxisAlignedBB.getBoundingBox((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
return AxisAlignedBB.getBoundingBox(
(double) x + this.minX,
(double) y + this.minY,
(double) z + this.minZ,
(double) x + this.maxX,
(double) y + this.maxY - 0.125,
(double) z + this.maxZ);
return AxisAlignedBB.getBoundingBox(
(double) x + this.minX,
(double) y + this.minY,
(double) z + this.minZ,
(double) x + this.maxX,
(double) y + this.maxY,
(double) z + this.maxZ);
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
switch (metadata % 8)
{
case 0:
return new CraftingStationLogic();
case 1:
return new ToolStationLogic();
case 2:
return new PartBuilderLogic();
case 3:
return new StencilTableLogic();
case 4:
return new PatternChestLogic();
case 5:
return new ToolForgeLogic();
default:
return null;
public TileEntity createTileEntity(World world, int metadata) {
switch (metadata % 8) {
case 0:
return new CraftingStationLogic();
case 1:
return new ToolStationLogic();
case 2:
return new PartBuilderLogic();
case 3:
return new StencilTableLogic();
case 4:
return new PatternChestLogic();
case 5:
return new ToolForgeLogic();
default:
return null;
}
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
int meta = world.getBlockMetadata(x, y, z) % 8;
switch (meta)
{
case 0:
return ToolProxyCommon.craftingStationID;
case 1:
return ToolProxyCommon.toolStationID;
case 2:
return ToolProxyCommon.partBuilderID;
case 3:
return ToolProxyCommon.stencilTableID;
case 4:
return ToolProxyCommon.patternChestID;
case 5:
return ToolProxyCommon.toolForgeID;
switch (meta) {
case 0:
return ToolProxyCommon.craftingStationID;
case 1:
return ToolProxyCommon.toolStationID;
case 2:
return ToolProxyCommon.partBuilderID;
case 3:
return ToolProxyCommon.stencilTableID;
case 4:
return ToolProxyCommon.patternChestID;
case 5:
return ToolProxyCommon.toolForgeID;
}
return -1;
}
@Override
public Object getModInstance ()
{
public Object getModInstance() {
return TConstruct.instance;
}
@Override
public void getSubBlocks (Item b, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 6; iter++)
{
public void getSubBlocks(Item b, CreativeTabs tab, List list) {
for (int iter = 0; iter < 6; iter++) {
list.add(new ItemStack(b, 1, iter));
}
}
@Override
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
{
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) {
boolean keptInventory = false;
if (stack.hasTagCompound())
{
if (stack.hasTagCompound()) {
NBTTagCompound inventory = stack.getTagCompound().getCompoundTag("Inventory");
TileEntity te = world.getTileEntity(x, y, z);
if (inventory != null && te instanceof PatternChestLogic)
{
if (inventory != null && te instanceof PatternChestLogic) {
PatternChestLogic logic = (PatternChestLogic) te;
logic.readInventoryFromNBT(inventory);
logic.xCoord = x;
@@ -149,14 +161,11 @@ public class CraftingSlab extends InventorySlab
keptInventory = true;
}
}
if (!keptInventory && PHConstruct.freePatterns)
{
if (!keptInventory && PHConstruct.freePatterns) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 4)
{
if (meta == 4) {
PatternChestLogic logic = (PatternChestLogic) world.getTileEntity(x, y, z);
for (int i = 1; i <= 13; i++)
{
for (int i = 1; i <= 13; i++) {
logic.setInventorySlotContents(i - 1, new ItemStack(TinkerTools.woodPattern, 1, i));
}
logic.setInventorySlotContents(13, new ItemStack(TinkerTools.woodPattern, 1, 22));
@@ -166,38 +175,33 @@ public class CraftingSlab extends InventorySlab
}
@Override
public TileEntity createNewTileEntity (World var1, int metadata)
{
switch (metadata % 8)
{
case 0:
return new CraftingStationLogic();
case 1:
return new ToolStationLogic();
case 2:
return new PartBuilderLogic();
case 3:
return new StencilTableLogic();
case 4:
return new PatternChestLogic();
case 5:
return new ToolForgeLogic();
default:
return null;
public TileEntity createNewTileEntity(World var1, int metadata) {
switch (metadata % 8) {
case 0:
return new CraftingStationLogic();
case 1:
return new ToolStationLogic();
case 2:
return new PartBuilderLogic();
case 3:
return new StencilTableLogic();
case 4:
return new PatternChestLogic();
case 5:
return new ToolForgeLogic();
default:
return null;
}
}
/* Keep pattern chest inventory */
@Override
public boolean removedByPlayer (World world, EntityPlayer player, int x, int y, int z, boolean willHarvest)
{
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
player.addExhaustion(0.025F);
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops"))
{
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 4)
{
if (meta == 4) {
ItemStack chest = new ItemStack(this, 1, 4);
NBTTagCompound inventory = new NBTTagCompound();
PatternChestLogic logic = (PatternChestLogic) world.getTileEntity(x, y, z);
@@ -208,17 +212,16 @@ public class CraftingSlab extends InventorySlab
// remove content. This is necessary because otherwise the patterns would also spill into the world
// we don't want to prevent that since that's the intended behaviour for explosions.
for(int i = 0; i < logic.getSizeInventory(); i++)
logic.setInventorySlotContents(i, null);
for (int i = 0; i < logic.getSizeInventory(); i++) logic.setInventorySlotContents(i, null);
//Spawn item
if (!player.capabilities.isCreativeMode || player.isSneaking())
{
// Spawn item
if (!player.capabilities.isCreativeMode || player.isSneaking()) {
float f = 0.7F;
double d0 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d2 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, (double) x + d0, (double) y + d1, (double) z + d2, chest);
EntityItem entityitem =
new EntityItem(world, (double) x + d0, (double) y + d1, (double) z + d2, chest);
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
}
@@ -228,10 +231,8 @@ public class CraftingSlab extends InventorySlab
}
@Override
public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta)
{
if (meta != 4)
super.harvestBlock(world, player, x, y, z, meta);
//Do nothing
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
if (meta != 4) super.harvestBlock(world, player, x, y, z, meta);
// Do nothing
}
}
@@ -17,98 +17,81 @@ import tconstruct.tools.ToolProxyCommon;
import tconstruct.tools.logic.CraftingStationLogic;
import tconstruct.tools.model.TableRender;
public class CraftingStationBlock extends InventoryBlock
{
public CraftingStationBlock(Material material)
{
public class CraftingStationBlock extends InventoryBlock {
public CraftingStationBlock(Material material) {
super(material);
this.setCreativeTab(TConstructRegistry.blockTab);
this.setHardness(2f);
this.setStepSound(Block.soundTypeWood);
}
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
// Block.hasComparatorInputOverride and Block.getComparatorInputOverride
/* Rendering */
@Override
public String[] getTextureNames ()
{
String[] textureNames = { "craftingstation_top", "craftingstation_side", "craftingstation_bottom" };
public String[] getTextureNames() {
String[] textureNames = {"craftingstation_top", "craftingstation_side", "craftingstation_bottom"};
return textureNames;
}
@Override
public String getTextureDomain (int textureNameIndex)
{
public String getTextureDomain(int textureNameIndex) {
return "tinker";
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
public IIcon getIcon(int side, int meta) {
return icons[getTextureIndex(side)];
}
public int getTextureIndex (int side)
{
if (side == 0)
return 2;
if (side == 1)
return 0;
public int getTextureIndex(int side) {
if (side == 0) return 2;
if (side == 1) return 0;
return 1;
}
@Override
public boolean renderAsNormalBlock ()
{
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube ()
{
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType ()
{
public int getRenderType() {
return TableRender.model;
}
@Override
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
return true;
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
return ToolProxyCommon.craftingStationID;
}
@Override
public Object getModInstance ()
{
public Object getModInstance() {
return TConstruct.instance;
}
@Override
public void getSubBlocks (Item id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 1; iter++)
{
public void getSubBlocks(Item id, CreativeTabs tab, List list) {
for (int iter = 0; iter < 1; iter++) {
list.add(new ItemStack(id, 1, iter));
}
}
@Override
public TileEntity createNewTileEntity (World arg0, int arg1)
{
public TileEntity createNewTileEntity(World arg0, int arg1) {
return new CraftingStationLogic();
}
}
}
@@ -21,11 +21,9 @@ import tconstruct.tools.ToolProxyCommon;
import tconstruct.tools.logic.*;
import tconstruct.tools.model.FrypanRender;
public class EquipBlock extends InventoryBlock
{
public class EquipBlock extends InventoryBlock {
public EquipBlock(Material material)
{
public EquipBlock(Material material) {
super(material);
this.setHardness(0.3f);
this.setBlockBounds(0, 0, 0, 1, 0.25f, 1);
@@ -33,67 +31,56 @@ public class EquipBlock extends InventoryBlock
}
@Override
public String[] getTextureNames ()
{
return new String[] { "toolstation_top" };
public String[] getTextureNames() {
return new String[] {"toolstation_top"};
}
@Override
public String getTextureDomain (int textureNameIndex)
{
public String getTextureDomain(int textureNameIndex) {
return "tinker";
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
public IIcon getIcon(int side, int meta) {
return Blocks.iron_block.getIcon(side, meta);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister par1IconRegister)
{
public void registerBlockIcons(IIconRegister par1IconRegister) {
// this.blockIcon =
// par1iconRegister.registerIcon(Block.blockIron.getUnlocalizedName());
}
@Override
public boolean renderAsNormalBlock ()
{
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube ()
{
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType ()
{
public int getRenderType() {
return FrypanRender.frypanModelID;
}
@Override
public Item getItemDropped (int par1, Random par2Random, int par3)
{
public Item getItemDropped(int par1, Random par2Random, int par3) {
return null;
}
@Override
public TileEntity createNewTileEntity (World world, int metadata)
{
public TileEntity createNewTileEntity(World world, int metadata) {
return new FrypanLogic();
}
@Override
public void randomDisplayTick (World world, int x, int y, int z, Random random)
{
if (isActive(world, x, y, z))
{
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (isActive(world, x, y, z)) {
float f = (float) x + 0.5F;
float f1 = (float) y + 0.25F + (random.nextFloat() * 6F) / 16F;
float f2 = (float) z + 0.5F;
@@ -104,64 +91,67 @@ public class EquipBlock extends InventoryBlock
}
@Override
public void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
public void onBlockPlacedBy(
World par1World,
int par2,
int par3,
int par4,
EntityLivingBase par5EntityLivingBase,
ItemStack par6ItemStack) {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int newMeta = 0;
switch (i3)
{
case 3:
newMeta = 0;
break;
case 0:
newMeta = 3;
break;
case 1:
newMeta = 1;
break;
case 2:
newMeta = 2;
break;
switch (i3) {
case 3:
newMeta = 0;
break;
case 0:
newMeta = 3;
break;
case 1:
newMeta = 1;
break;
case 2:
newMeta = 2;
break;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2);
}
@Override
public void breakBlock (World par1World, int x, int y, int z, Block par5, int meta)
{
public void breakBlock(World par1World, int x, int y, int z, Block par5, int meta) {
TileEntity te = par1World.getTileEntity(x, y, z);
if (te != null && te instanceof EquipLogic)
{
if (te != null && te instanceof EquipLogic) {
EquipLogic logic = (EquipLogic) te;
for (int iter = 0; iter < logic.getSizeInventory(); ++iter)
{
for (int iter = 0; iter < logic.getSizeInventory(); ++iter) {
ItemStack stack = iter == 0 ? logic.getEquipmentItem() : logic.getStackInSlot(iter);
if (stack != null && logic.canDropInventorySlot(iter))
{
if (stack != null && logic.canDropInventorySlot(iter)) {
float jumpX = rand.nextFloat() * 0.8F + 0.1F;
float jumpY = rand.nextFloat() * 0.8F + 0.1F;
float jumpZ = rand.nextFloat() * 0.8F + 0.1F;
while (stack.stackSize > 0)
{
while (stack.stackSize > 0) {
int itemSize = rand.nextInt(21) + 10;
if (itemSize > stack.stackSize)
{
if (itemSize > stack.stackSize) {
itemSize = stack.stackSize;
}
stack.stackSize -= itemSize;
EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ), new ItemStack(stack.getItem(), itemSize, stack.getItemDamage()));
EntityItem entityitem = new EntityItem(
par1World,
(double) ((float) x + jumpX),
(double) ((float) y + jumpY),
(double) ((float) z + jumpZ),
new ItemStack(stack.getItem(), itemSize, stack.getItemDamage()));
if (stack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
if (stack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound)
stack.getTagCompound().copy());
}
float offset = 0.05F;
@@ -178,39 +168,34 @@ public class EquipBlock extends InventoryBlock
}
@Override
public int getLightValue (IBlockAccess world, int x, int y, int z)
{
public int getLightValue(IBlockAccess world, int x, int y, int z) {
return !isActive(world, x, y, z) ? 0 : 9;
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
return ToolProxyCommon.frypanGuiID;
}
@Override
public Object getModInstance ()
{
public Object getModInstance() {
return TConstruct.instance;
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier (IBlockAccess blockAccess, int x, int y, int z)
{
public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) {
TileEntity te = blockAccess.getTileEntity(x, y, z);
if (te instanceof EquipLogic)
{
if (te instanceof EquipLogic) {
EquipLogic logic = (EquipLogic) te;
ItemStack stack = logic.getEquipmentItem();
if (stack != null && stack.hasTagCompound() && stack.getTagCompound().hasKey("InfiTool"))
{
if (stack != null
&& stack.hasTagCompound()
&& stack.getTagCompound().hasKey("InfiTool")) {
NBTTagCompound tag = stack.getTagCompound().getCompoundTag("InfiTool");
if (tag != null)
{
if (tag != null) {
int head = tag.getInteger("Head");
return TConstructRegistry.getMaterial(head).primaryColor();
@@ -222,9 +207,7 @@ public class EquipBlock extends InventoryBlock
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
public TileEntity createTileEntity(World world, int metadata) {
return new FrypanLogic();
}
}
@@ -15,73 +15,58 @@ import tconstruct.library.TConstructRegistry;
import tconstruct.tools.ToolProxyCommon;
import tconstruct.tools.logic.FurnaceLogic;
public class FurnaceSlab extends InventorySlab
{
public class FurnaceSlab extends InventorySlab {
public FurnaceSlab(Material material)
{
public FurnaceSlab(Material material) {
super(material);
this.setCreativeTab(TConstructRegistry.blockTab);
this.setHardness(3.5f);
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
switch (metadata % 8)
{
case 0:
return new FurnaceLogic();
public TileEntity createTileEntity(World world, int metadata) {
switch (metadata % 8) {
case 0:
return new FurnaceLogic();
}
return null;
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
return ToolProxyCommon.furnaceID;
}
@Override
public Object getModInstance ()
{
public Object getModInstance() {
return TConstruct.instance;
}
@Override
public String[] getTextureNames ()
{
String[] textureNames = { "furnaceslab_front", "furnaceslab_front_active", "furnaceslab_side", "furnace_top" };
public String[] getTextureNames() {
String[] textureNames = {"furnaceslab_front", "furnaceslab_front_active", "furnaceslab_side", "furnace_top"};
return textureNames;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
public IIcon getIcon(int side, int meta) {
return icons[(meta % 8) * 3 + getTextureIndex(side)];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (IBlockAccess world, int x, int y, int z, int side)
{
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntity logic = world.getTileEntity(x, y, z);
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
int meta = world.getBlockMetadata(x, y, z) % 8;
if (meta == 0)
{
if (side == direction)
{
if (((IActiveLogic) logic).getActive())
return icons[1];
else
return icons[0];
}
else if (side > 1)
{
if (meta == 0) {
if (side == direction) {
if (((IActiveLogic) logic).getActive()) return icons[1];
else return icons[0];
} else if (side > 1) {
return icons[2];
}
return icons[3];
@@ -89,87 +74,66 @@ public class FurnaceSlab extends InventorySlab
return icons[0];
}
public int getTextureIndex (int side)
{
if (side == 0 || side == 1)
return 3;
if (side == 3)
return 0;
public int getTextureIndex(int side) {
if (side == 0 || side == 1) return 3;
if (side == 3) return 0;
return 2;
}
@Override
public String getTextureDomain (int textureNameIndex)
{
public String getTextureDomain(int textureNameIndex) {
return "tinker";
}
@Override
public void registerBlockIcons (IIconRegister iconRegister)
{
public void registerBlockIcons(IIconRegister iconRegister) {
String[] textureNames = getTextureNames();
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
if (i == 3)
this.icons[i] = iconRegister.registerIcon("minecraft:" + textureNames[i]);
else
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
for (int i = 0; i < this.icons.length; ++i) {
if (i == 3) this.icons[i] = iconRegister.registerIcon("minecraft:" + textureNames[i]);
else this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
}
}
@Override
public TileEntity createNewTileEntity (World var1, int metadata)
{
switch (metadata % 8)
{
case 0:
return new FurnaceLogic();
public TileEntity createNewTileEntity(World var1, int metadata) {
switch (metadata % 8) {
case 0:
return new FurnaceLogic();
}
return null;
}
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick (World world, int x, int y, int z, Random random)
{
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
TileEntity logic = world.getTileEntity(x, y, z);
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
int meta = world.getBlockMetadata(x, y, z);
int metaType = meta % 8;
int metaPos = meta / 8;
if (metaType == 0)
{
if (((IActiveLogic) logic).getActive())
{
if (metaType == 0) {
if (((IActiveLogic) logic).getActive()) {
float offset = random.nextFloat() * 0.6F - 0.3F;
float offsetY = random.nextFloat() * 6.0F / 16.0F;
if (metaPos == 1)
{
if (metaPos == 1) {
offsetY += 0.5F;
}
if (direction == 4)
{
if (direction == 4) {
world.spawnParticle("smoke", x - 0.02F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x - 0.02F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
}
else if (direction == 5)
{
} else if (direction == 5) {
world.spawnParticle("smoke", x + 1.02F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 1.02F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
}
else if (direction == 2)
{
} else if (direction == 2) {
world.spawnParticle("smoke", x + offset + 0.5F, y + offsetY, z - 0.02F, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + offset + 0.5F, y + offsetY, z - 0.02F, 0.0D, 0.0D, 0.0D);
}
else if (direction == 3)
{
} else if (direction == 3) {
world.spawnParticle("smoke", x + offset + 0.5F, y + offsetY, z + 1.02F, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + offset + 0.5F, y + offsetY, z + 1.02F, 0.0D, 0.0D, 0.0D);
}
@@ -9,109 +9,126 @@ import net.minecraft.util.*;
import net.minecraft.world.*;
import tconstruct.blocks.TConstructBlock;
public class MultiBrick extends TConstructBlock
{
static String blockTextures[] = { "brick_obsidian", "brick_sandstone", "brick_netherrack", "brick_stone_refined", "brick_iron", "brick_gold", "brick_lapis", "brick_diamond", "brick_redstone", "brick_bone", "brick_slime", "brick_blueslime", "brick_endstone", "brick_obsidian_ingot" };
public class MultiBrick extends TConstructBlock {
static String blockTextures[] = {
"brick_obsidian",
"brick_sandstone",
"brick_netherrack",
"brick_stone_refined",
"brick_iron",
"brick_gold",
"brick_lapis",
"brick_diamond",
"brick_redstone",
"brick_bone",
"brick_slime",
"brick_blueslime",
"brick_endstone",
"brick_obsidian_ingot"
};
public MultiBrick()
{
public MultiBrick() {
super(Material.rock, 3f, blockTextures);
}
@Override
public float getBlockHardness (World world, int x, int y, int z)
{
public float getBlockHardness(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
case 1:
return Blocks.sandstone.getBlockHardness(world, x, y, z);
case 2:
return Blocks.netherrack.getBlockHardness(world, x, y, z);
case 3:
return Blocks.stone.getBlockHardness(world, x, y, z);
case 4:
return Blocks.iron_block.getBlockHardness(world, x, y, z);
case 5:
return Blocks.gold_block.getBlockHardness(world, x, y, z);
case 6:
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
case 7:
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
case 8:
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getBlockHardness(world, x, y, z);
case 13:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
default:
return blockHardness;
switch (meta) {
case 0:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
case 1:
return Blocks.sandstone.getBlockHardness(world, x, y, z);
case 2:
return Blocks.netherrack.getBlockHardness(world, x, y, z);
case 3:
return Blocks.stone.getBlockHardness(world, x, y, z);
case 4:
return Blocks.iron_block.getBlockHardness(world, x, y, z);
case 5:
return Blocks.gold_block.getBlockHardness(world, x, y, z);
case 6:
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
case 7:
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
case 8:
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getBlockHardness(world, x, y, z);
case 13:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
default:
return blockHardness;
}
}
@Override
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
{
public float getExplosionResistance(
Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) {
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 1:
return Blocks.sandstone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 2:
return Blocks.netherrack.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 3:
return Blocks.stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 4:
return Blocks.iron_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 5:
return Blocks.gold_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 6:
return Blocks.lapis_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 7:
return Blocks.diamond_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 8:
return Blocks.redstone_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 13:
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
default:
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
switch (meta) {
case 0:
return Blocks.obsidian.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 1:
return Blocks.sandstone.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 2:
return Blocks.netherrack.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 3:
return Blocks.stone.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 4:
return Blocks.iron_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 5:
return Blocks.gold_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 6:
return Blocks.lapis_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 7:
return Blocks.diamond_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 8:
return Blocks.redstone_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 13:
return Blocks.obsidian.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
default:
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
}
}
@Override
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
{
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 10 || meta == 11)
{
if (entity.motionY < 0)
entity.motionY *= -1.2F;
if (meta == 10 || meta == 11) {
if (entity.motionY < 0) entity.motionY *= -1.2F;
entity.fallDistance = 0;
}
}
// TODO getCollisionBoundingBoxFromPool
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
{
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 10 || meta == 11)
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
@@ -123,37 +140,30 @@ public class MultiBrick extends TConstructBlock
*/
@Override
public boolean canProvidePower ()
{
public boolean canProvidePower() {
return true;
}
@Override
public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side)
{
if (world.getBlockMetadata(x, y, z) == 8)
return 4;
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
if (world.getBlockMetadata(x, y, z) == 8) return 4;
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister iconRegister)
{
public void registerBlockIcons(IIconRegister iconRegister) {
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
for (int i = 0; i < this.icons.length; ++i) {
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
}
}
@Override
public boolean isNormalCube (IBlockAccess world, int x, int y, int z)
{
public boolean isNormalCube(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if (meta != 8)
{
if (meta != 8) {
return true;
}
return super.isNormalCube(world, x, y, z);
@@ -9,114 +9,133 @@ import net.minecraft.util.*;
import net.minecraft.world.*;
import tconstruct.blocks.TConstructBlock;
public class MultiBrickFancy extends TConstructBlock
{
static String blockTextures[] = { "fancybrick_obsidian", "fancybrick_sandstone", "fancybrick_netherrack", "fancybrick_stone_refined", "fancybrick_iron", "fancybrick_gold", "fancybrick_lapis", "fancybrick_diamond", "fancybrick_redstone", "fancybrick_bone", "fancybrick_slime", "fancybrick_blueslime", "fancybrick_endstone", "fancybrick_obsidian_ingot", "fancybrick_stone", "road_stone" };
public class MultiBrickFancy extends TConstructBlock {
static String blockTextures[] = {
"fancybrick_obsidian",
"fancybrick_sandstone",
"fancybrick_netherrack",
"fancybrick_stone_refined",
"fancybrick_iron",
"fancybrick_gold",
"fancybrick_lapis",
"fancybrick_diamond",
"fancybrick_redstone",
"fancybrick_bone",
"fancybrick_slime",
"fancybrick_blueslime",
"fancybrick_endstone",
"fancybrick_obsidian_ingot",
"fancybrick_stone",
"road_stone"
};
public MultiBrickFancy()
{
public MultiBrickFancy() {
super(Material.rock, 3f, blockTextures);
}
// TODO getBlockHardness
@Override
public float getBlockHardness (World world, int x, int y, int z)
{
public float getBlockHardness(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
case 1:
return Blocks.sandstone.getBlockHardness(world, x, y, z);
case 2:
return Blocks.netherrack.getBlockHardness(world, x, y, z);
case 4:
return Blocks.iron_block.getBlockHardness(world, x, y, z);
case 5:
return Blocks.gold_block.getBlockHardness(world, x, y, z);
case 6:
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
case 7:
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
case 8:
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getBlockHardness(world, x, y, z);
case 13:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
case 3:
case 14:
case 15:
return Blocks.stone.getBlockHardness(world, x, y, z);
default:
return blockHardness;
switch (meta) {
case 0:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
case 1:
return Blocks.sandstone.getBlockHardness(world, x, y, z);
case 2:
return Blocks.netherrack.getBlockHardness(world, x, y, z);
case 4:
return Blocks.iron_block.getBlockHardness(world, x, y, z);
case 5:
return Blocks.gold_block.getBlockHardness(world, x, y, z);
case 6:
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
case 7:
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
case 8:
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getBlockHardness(world, x, y, z);
case 13:
return Blocks.obsidian.getBlockHardness(world, x, y, z);
case 3:
case 14:
case 15:
return Blocks.stone.getBlockHardness(world, x, y, z);
default:
return blockHardness;
}
}
@Override
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
{
public float getExplosionResistance(
Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) {
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 1:
return Blocks.sandstone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 2:
return Blocks.netherrack.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 4:
return Blocks.iron_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 5:
return Blocks.gold_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 6:
return Blocks.lapis_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 7:
return Blocks.diamond_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 8:
return Blocks.redstone_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 13:
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 3:
case 14:
case 15:
return Blocks.stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
default:
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
switch (meta) {
case 0:
return Blocks.obsidian.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 1:
return Blocks.sandstone.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 2:
return Blocks.netherrack.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 4:
return Blocks.iron_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 5:
return Blocks.gold_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 6:
return Blocks.lapis_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 7:
return Blocks.diamond_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 8:
return Blocks.redstone_block.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Blocks.end_stone.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 13:
return Blocks.obsidian.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
case 3:
case 14:
case 15:
return Blocks.stone.getExplosionResistance(
entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
default:
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
}
}
// TODO onEntityCollidedWithBlock
@Override
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
{
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 10 || meta == 11)
{
if (entity.motionY < 0)
entity.motionY *= -1.2F;
if (meta == 10 || meta == 11) {
if (entity.motionY < 0) entity.motionY *= -1.2F;
entity.fallDistance = 0;
}
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
{
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 10 || meta == 11)
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
@@ -128,37 +147,30 @@ public class MultiBrickFancy extends TConstructBlock
*/
@Override
public boolean canProvidePower ()
{
public boolean canProvidePower() {
return true;
}
@Override
public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side)
{
if (world.getBlockMetadata(x, y, z) == 8)
return 4;
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
if (world.getBlockMetadata(x, y, z) == 8) return 4;
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister iconRegister)
{
public void registerBlockIcons(IIconRegister iconRegister) {
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
for (int i = 0; i < this.icons.length; ++i) {
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
}
}
@Override
public boolean isNormalCube (IBlockAccess world, int x, int y, int z)
{
public boolean isNormalCube(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if (meta != 8)
{
if (meta != 8) {
return true;
}
return super.isNormalCube(world, x, y, z);
@@ -9,22 +9,28 @@ import net.minecraft.util.IIcon;
import tconstruct.blocks.TConstructBlock;
public class MultiBrickMetal extends TConstructBlock {
static String blockTextures[] = { "brick_alumite", "brick_ardite", "brick_cobalt", "brick_manyullyn", "fancybrick_alumite", "fancybrick_ardite", "fancybrick_cobalt", "fancybrick_manyullyn"};
static String blockTextures[] = {
"brick_alumite",
"brick_ardite",
"brick_cobalt",
"brick_manyullyn",
"fancybrick_alumite",
"fancybrick_ardite",
"fancybrick_cobalt",
"fancybrick_manyullyn"
};
public MultiBrickMetal()
{
public MultiBrickMetal() {
super(Material.iron, 10f, blockTextures);
this.setStepSound(Block.soundTypeMetal);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister iconRegister)
{
public void registerBlockIcons(IIconRegister iconRegister) {
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
for (int i = 0; i < this.icons.length; ++i) {
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
}
}
@@ -21,63 +21,69 @@ import tconstruct.tools.logic.ToolForgeLogic;
import tconstruct.tools.model.TableRender;
import tconstruct.world.TinkerWorld;
public class ToolForgeBlock extends InventoryBlock
{
public class ToolForgeBlock extends InventoryBlock {
public ToolForgeBlock(Material material)
{
public ToolForgeBlock(Material material) {
super(material);
this.setCreativeTab(TConstructRegistry.blockTab);
this.setHardness(2f);
this.setStepSound(Block.soundTypeMetal);
}
String[] textureNames = { "toolforge_iron", "toolforge_gold", "toolforge_diamond", "toolforge_emerald", "toolforge_cobalt", "toolforge_ardite", "toolforge_manyullyn", "toolforge_copper", "toolforge_bronze", "toolforge_tin", "toolforge_aluminum", "toolforge_alubrass", "toolforge_alumite", "toolforge_steel" };
String[] textureNames = {
"toolforge_iron",
"toolforge_gold",
"toolforge_diamond",
"toolforge_emerald",
"toolforge_cobalt",
"toolforge_ardite",
"toolforge_manyullyn",
"toolforge_copper",
"toolforge_bronze",
"toolforge_tin",
"toolforge_aluminum",
"toolforge_alubrass",
"toolforge_alumite",
"toolforge_steel"
};
/* Rendering */
@Override
public String[] getTextureNames ()
{
public String[] getTextureNames() {
return textureNames;
}
@Override
public String getTextureDomain (int textureNameIndex)
{
public String getTextureDomain(int textureNameIndex) {
return "tinker";
}
IIcon textureTop;
@Override
public void registerBlockIcons (IIconRegister iconRegister)
{
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
textureTop = iconRegister.registerIcon("tinker:toolforge_top");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
if (side == 1)
{
public IIcon getIcon(int side, int meta) {
if (side == 1) {
return textureTop;
}
if (side == 0)
{
switch (meta)
{
case 0:
return Blocks.iron_block.getIcon(side, 0);
case 1:
return Blocks.gold_block.getIcon(side, 0);
case 2:
return Blocks.diamond_block.getIcon(side, 0);
case 3:
return Blocks.emerald_block.getIcon(side, 0);
default:
return TinkerWorld.metalBlock.getIcon(side, meta - 4);
if (side == 0) {
switch (meta) {
case 0:
return Blocks.iron_block.getIcon(side, 0);
case 1:
return Blocks.gold_block.getIcon(side, 0);
case 2:
return Blocks.diamond_block.getIcon(side, 0);
case 3:
return Blocks.emerald_block.getIcon(side, 0);
default:
return TinkerWorld.metalBlock.getIcon(side, meta - 4);
}
}
@@ -85,58 +91,48 @@ public class ToolForgeBlock extends InventoryBlock
}
@Override
public boolean renderAsNormalBlock ()
{
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube ()
{
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side)
{
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
return side == ForgeDirection.UP;
}
@Override
public int getRenderType ()
{
public int getRenderType() {
return TableRender.model;
}
@Override
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
return true;
}
@Override
public TileEntity createNewTileEntity (World world, int metadata)
{
public TileEntity createNewTileEntity(World world, int metadata) {
return new ToolForgeLogic();
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
return ToolProxyCommon.toolForgeID;
}
@Override
public Object getModInstance ()
{
public Object getModInstance() {
return TConstruct.instance;
}
@Override
public void getSubBlocks (Item b, CreativeTabs tab, List list)
{
for (int iter = 0; iter < textureNames.length; iter++)
{
public void getSubBlocks(Item b, CreativeTabs tab, List list) {
for (int iter = 0; iter < textureNames.length; iter++) {
list.add(new ItemStack(b, 1, iter));
}
}
@@ -22,166 +22,180 @@ import tconstruct.tools.logic.*;
import tconstruct.tools.model.TableRender;
import tconstruct.util.config.PHConstruct;
public class ToolStationBlock extends InventoryBlock
{
public ToolStationBlock(Material material)
{
public class ToolStationBlock extends InventoryBlock {
public ToolStationBlock(Material material) {
super(material);
this.setCreativeTab(TConstructRegistry.blockTab);
this.setHardness(2f);
this.setStepSound(Block.soundTypeWood);
}
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
// Block.hasComparatorInputOverride and Block.getComparatorInputOverride
/* Rendering */
@Override
public String[] getTextureNames ()
{
String[] textureNames = { "toolstation_top", "toolstation_side", "toolstation_bottom", "partbuilder_oak_top", "partbuilder_oak_side", "partbuilder_oak_bottom", "partbuilder_spruce_top", "partbuilder_spruce_side", "partbuilder_spruce_bottom", "partbuilder_birch_top", "partbuilder_birch_side", "partbuilder_birch_bottom", "partbuilder_jungle_top", "partbuilder_jungle_side", "partbuilder_jungle_bottom", "patternchest_top", "patternchest_side", "patternchest_bottom", "stenciltable_oak_top", "stenciltable_oak_side", "stenciltable_oak_bottom", "stenciltable_spruce_top", "stenciltable_spruce_side", "stenciltable_spruce_bottom", "stenciltable_birch_top", "stenciltable_birch_side", "stenciltable_birch_bottom", "stenciltable_jungle_top", "stenciltable_jungle_side", "stenciltable_jungle_bottom" };
public String[] getTextureNames() {
String[] textureNames = {
"toolstation_top",
"toolstation_side",
"toolstation_bottom",
"partbuilder_oak_top",
"partbuilder_oak_side",
"partbuilder_oak_bottom",
"partbuilder_spruce_top",
"partbuilder_spruce_side",
"partbuilder_spruce_bottom",
"partbuilder_birch_top",
"partbuilder_birch_side",
"partbuilder_birch_bottom",
"partbuilder_jungle_top",
"partbuilder_jungle_side",
"partbuilder_jungle_bottom",
"patternchest_top",
"patternchest_side",
"patternchest_bottom",
"stenciltable_oak_top",
"stenciltable_oak_side",
"stenciltable_oak_bottom",
"stenciltable_spruce_top",
"stenciltable_spruce_side",
"stenciltable_spruce_bottom",
"stenciltable_birch_top",
"stenciltable_birch_side",
"stenciltable_birch_bottom",
"stenciltable_jungle_top",
"stenciltable_jungle_side",
"stenciltable_jungle_bottom"
};
return textureNames;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
if (meta <= 4)
{
public IIcon getIcon(int side, int meta) {
if (meta <= 4) {
return icons[meta * 3 + getTextureIndex(side)];
}
else if (meta <= 9)
{
} else if (meta <= 9) {
return icons[15 + getTextureIndex(side)];
}
else
{
} else {
return icons[meta * 3 + getTextureIndex(side) - 12];
}
}
public int getTextureIndex (int side)
{
if (side == 0)
return 2;
if (side == 1)
return 0;
public int getTextureIndex(int side) {
if (side == 0) return 2;
if (side == 1) return 0;
return 1;
}
@Override
public boolean renderAsNormalBlock ()
{
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube ()
{
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side)
{
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
return side == ForgeDirection.UP;
}
@Override
public int getRenderType ()
{
public int getRenderType() {
return TableRender.model;
}
@Override
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
return true;
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
{
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 5)
return AxisAlignedBB.getBoundingBox((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125, (double) z + this.maxZ);
return AxisAlignedBB.getBoundingBox((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
return AxisAlignedBB.getBoundingBox(
(double) x + this.minX,
(double) y + this.minY,
(double) z + this.minZ,
(double) x + this.maxX,
(double) y + this.maxY - 0.125,
(double) z + this.maxZ);
return AxisAlignedBB.getBoundingBox(
(double) x + this.minX,
(double) y + this.minY,
(double) z + this.minZ,
(double) x + this.maxX,
(double) y + this.maxY,
(double) z + this.maxZ);
}
@Override
public TileEntity createNewTileEntity (World world, int metadata)
{
switch (metadata)
{
case 0:
return new ToolStationLogic();
case 1:
return new PartBuilderLogic();
case 2:
return new PartBuilderLogic();
case 3:
return new PartBuilderLogic();
case 4:
return new PartBuilderLogic();
case 5:
return new PatternChestLogic();
case 6:
return new PatternChestLogic();
case 7:
return new PatternChestLogic();
case 8:
return new PatternChestLogic();
case 9:
return new PatternChestLogic();
case 10:
return new StencilTableLogic();
case 11:
return new StencilTableLogic();
case 12:
return new StencilTableLogic();
case 13:
return new StencilTableLogic();
/*case 14:
return new CastingTableLogic();*/
default:
return null;
public TileEntity createNewTileEntity(World world, int metadata) {
switch (metadata) {
case 0:
return new ToolStationLogic();
case 1:
return new PartBuilderLogic();
case 2:
return new PartBuilderLogic();
case 3:
return new PartBuilderLogic();
case 4:
return new PartBuilderLogic();
case 5:
return new PatternChestLogic();
case 6:
return new PatternChestLogic();
case 7:
return new PatternChestLogic();
case 8:
return new PatternChestLogic();
case 9:
return new PatternChestLogic();
case 10:
return new StencilTableLogic();
case 11:
return new StencilTableLogic();
case 12:
return new StencilTableLogic();
case 13:
return new StencilTableLogic();
/*case 14:
return new CastingTableLogic();*/
default:
return null;
}
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
int md = world.getBlockMetadata(x, y, z);
if (md == 0)
return 0;
else if (md < 5)
return 1;
else if (md < 10)
return 2;
else
return 3;
if (md == 0) return 0;
else if (md < 5) return 1;
else if (md < 10) return 2;
else return 3;
//return -1;
// return -1;
}
@Override
public Object getModInstance ()
{
public Object getModInstance() {
return TConstruct.instance;
}
@Override
public void getSubBlocks (Item id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 6; iter++)
{
public void getSubBlocks(Item id, CreativeTabs tab, List list) {
for (int iter = 0; iter < 6; iter++) {
list.add(new ItemStack(id, 1, iter));
}
for (int iter = 10; iter < 14; iter++)
{
for (int iter = 10; iter < 14; iter++) {
list.add(new ItemStack(id, 1, iter));
}
}
@@ -206,22 +220,18 @@ public class ToolStationBlock extends InventoryBlock
}*/
@Override
public String getTextureDomain (int textureNameIndex)
{
public String getTextureDomain(int textureNameIndex) {
return "tinker";
}
/* Keep pattern chest inventory */
@Override
public boolean removedByPlayer (World world, EntityPlayer player, int x, int y, int z, boolean willHarvest)
{
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
player.addExhaustion(0.025F);
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops"))
{
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 5 && meta <= 9)
{
if (meta >= 5 && meta <= 9) {
ItemStack chest = new ItemStack(this, 1, 5);
NBTTagCompound inventory = new NBTTagCompound();
PatternChestLogic logic = (PatternChestLogic) world.getTileEntity(x, y, z);
@@ -232,17 +242,16 @@ public class ToolStationBlock extends InventoryBlock
// remove content. This is necessary because otherwise the patterns would also spill into the world
// we don't want to prevent that since that's the intended behaviour for explosions.
for(int i = 0; i < logic.getSizeInventory(); i++)
logic.setInventorySlotContents(i, null);
for (int i = 0; i < logic.getSizeInventory(); i++) logic.setInventorySlotContents(i, null);
//Spawn item
if (!player.capabilities.isCreativeMode || player.isSneaking())
{
// Spawn item
if (!player.capabilities.isCreativeMode || player.isSneaking()) {
float f = 0.7F;
double d0 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d2 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, (double) x + d0, (double) y + d1, (double) z + d2, chest);
EntityItem entityitem =
new EntityItem(world, (double) x + d0, (double) y + d1, (double) z + d2, chest);
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
}
@@ -252,23 +261,18 @@ public class ToolStationBlock extends InventoryBlock
}
@Override
public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta)
{
if (meta < 5 || meta > 9)
super.harvestBlock(world, player, x, y, z, meta);
//Do nothing
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
if (meta < 5 || meta > 9) super.harvestBlock(world, player, x, y, z, meta);
// Do nothing
}
@Override
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
{
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) {
boolean keptInventory = false;
if (stack.hasTagCompound())
{
if (stack.hasTagCompound()) {
NBTTagCompound inventory = stack.getTagCompound().getCompoundTag("Inventory");
TileEntity te = world.getTileEntity(x, y, z);
if (inventory != null && te instanceof PatternChestLogic)
{
if (inventory != null && te instanceof PatternChestLogic) {
PatternChestLogic logic = (PatternChestLogic) te;
logic.readInventoryFromNBT(inventory);
logic.xCoord = x;
@@ -277,14 +281,11 @@ public class ToolStationBlock extends InventoryBlock
keptInventory = true;
}
}
if (!keptInventory && PHConstruct.freePatterns)
{
if (!keptInventory && PHConstruct.freePatterns) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 5)
{
if (meta == 5) {
PatternChestLogic logic = (PatternChestLogic) world.getTileEntity(x, y, z);
for (int i = 1; i <= 13; i++)
{
for (int i = 1; i <= 13; i++) {
logic.setInventorySlotContents(i - 1, new ItemStack(TinkerTools.woodPattern, 1, i));
}
logic.setInventorySlotContents(13, new ItemStack(TinkerTools.woodPattern, 1, 22));
@@ -292,4 +293,4 @@ public class ToolStationBlock extends InventoryBlock
}
super.onBlockPlacedBy(world, x, y, z, living, stack);
}
}
}
@@ -18,8 +18,7 @@ public class DaggerEntityRenderer extends ProjectileBaseRenderer<DaggerEntity> {
// it rotates!
GL11.glRotatef(entity.roll, 0f, 0f, 1f);
// also make it a bit thicker
toolCoreRenderer.setDepth(1/20f);
toolCoreRenderer.setDepth(1 / 20f);
}
}
@@ -18,21 +18,18 @@ import net.minecraft.util.*;
import net.minecraft.world.World;
@Deprecated
public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnData
{
public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnData {
public ItemStack returnStack;
public float mass;
public int baseDamage;
private float knockbackStrengthMod;
Random random = new Random();
public ArrowEntity(World par1World)
{
public ArrowEntity(World par1World) {
super(par1World);
}
public ArrowEntity(World world, EntityLivingBase living, float baseSpeed, ItemStack stack)
{
public ArrowEntity(World world, EntityLivingBase living, float baseSpeed, ItemStack stack) {
super(world, living, baseSpeed);
this.returnStack = stack;
NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool");
@@ -40,8 +37,7 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.baseDamage = toolTag.getInteger("Attack");
}
public ArrowEntity(World world, double x, double y, double z, ItemStack stack)
{
public ArrowEntity(World world, double x, double y, double z, ItemStack stack) {
super(world, x, y, z);
this.returnStack = stack;
NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool");
@@ -50,76 +46,66 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
@Override
public void onCollideWithPlayer (EntityPlayer par1EntityPlayer)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode;
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) {
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) {
boolean flag =
this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(returnStack))
{
if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(returnStack)) {
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
if (flag) {
this.playSound(
"random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
par1EntityPlayer.onItemPickup(this, 1);
if(returnStack.stackSize <= 0 || this.canBePickedUp == 2)
this.setDead();
if (returnStack.stackSize <= 0 || this.canBePickedUp == 2) this.setDead();
}
}
}
@Override
public void onUpdate ()
{
public void onUpdate() {
this.onEntityUpdate();
if (returnStack == null || returnStack.stackSize < 1)
{
if (returnStack == null || returnStack.stackSize < 1) {
this.setDead();
}
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
this.prevRotationYaw =
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch =
this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
}
Block i = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
i.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
AxisAlignedBB axisalignedbb = i.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
AxisAlignedBB axisalignedbb = i.getCollisionBoundingBoxFromPool(
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
{
if (axisalignedbb != null
&& axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) {
this.inGround = true;
}
if (this.arrowShake > 0)
{
if (this.arrowShake > 0) {
--this.arrowShake;
}
if (this.inGround)
{
if (!worldObj.isRemote)
{
if (this.inGround) {
if (!worldObj.isRemote) {
Block j = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
int k = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (j == this.field_145790_g && k == this.inData)
{
if (j == this.field_145790_g && k == this.inData) {
++this.ticksInGround;
if (this.ticksInGround == 120000)
{
if (this.ticksInGround == 120000) {
this.setDead();
}
}
else
{
} else {
this.inGround = false;
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
@@ -128,43 +114,46 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.ticksInAir = 0;
}
}
}
else
{
} else {
++this.ticksInAir;
Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
Vec3 vec31 = Vec3.createVectorHelper(
this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec3, vec31, false, true, false);
vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
vec31 = Vec3.createVectorHelper(
this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec31 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
if (movingobjectposition != null) {
vec31 = Vec3.createVectorHelper(
movingobjectposition.hitVec.xCoord,
movingobjectposition.hitVec.yCoord,
movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(
this,
this.boundingBox
.addCoord(this.motionX, this.motionY, this.motionZ)
.expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int l;
float ySpeed;
for (l = 0; l < list.size(); ++l)
{
for (l = 0; l < list.size(); ++l) {
Entity entity1 = (Entity) list.get(l);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
{
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
ySpeed = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) ySpeed, (double) ySpeed, (double) ySpeed);
AxisAlignedBB axisalignedbb1 =
entity1.boundingBox.expand((double) ySpeed, (double) ySpeed, (double) ySpeed);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31);
if (movingobjectposition1 != null)
{
if (movingobjectposition1 != null) {
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
if (d1 < d0 || d0 == 0.0D) {
entity = entity1;
d0 = d1;
}
@@ -172,17 +161,18 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
}
if (entity != null)
{
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
if (movingobjectposition != null
&& movingobjectposition.entityHit != null
&& movingobjectposition.entityHit instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer))
{
if (entityplayer.capabilities.disableDamage
|| this.shootingEntity instanceof EntityPlayer
&& !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
movingobjectposition = null;
}
}
@@ -190,50 +180,40 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
float speed;
float f3;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
if (movingobjectposition != null) {
if (movingobjectposition.entityHit != null) {
speed = MathHelper.sqrt_double(
this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
double damageSpeed = (double) speed * this.getDamage();
damageSpeed *= baseDamage;
damageSpeed /= 5D;
int damageInflicted = MathHelper.ceiling_double_int(damageSpeed);
if (this.getIsCritical())
{
if (this.getIsCritical()) {
damageInflicted += this.rand.nextInt(damageInflicted / 2 + 2);
}
DamageSource damagesource = null;
if (this.shootingEntity == null)
{
if (this.shootingEntity == null) {
damagesource = DamageSource.causeArrowDamage(this, this);
}
else
{
} else {
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
}
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
{
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) {
movingobjectposition.entityHit.setFire(5);
}
if (returnStack.hasTagCompound())
{
if (returnStack.hasTagCompound()) {
int fireAspect = 0;
NBTTagCompound toolTags = returnStack.getTagCompound().getCompoundTag("InfiTool");
if (toolTags.hasKey("Fiery") || toolTags.hasKey("Lava"))
{
if (toolTags.hasKey("Fiery") || toolTags.hasKey("Lava")) {
fireAspect *= 4;
if (toolTags.hasKey("Fiery"))
{
if (toolTags.hasKey("Fiery")) {
fireAspect += toolTags.getInteger("Fiery") / 5 + 1;
}
if (toolTags.getBoolean("Lava"))
{
if (toolTags.getBoolean("Lava")) {
fireAspect += 3;
}
entity.setFire(fireAspect);
@@ -244,40 +224,41 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
((EntityLiving) shootingEntity).heal(random.nextInt(drain + 1));
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, damageInflicted))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, damageInflicted)) {
if (movingobjectposition.entityHit instanceof EntityLivingBase) {
EntityLivingBase entityliving = (EntityLivingBase) movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
if (!this.worldObj.isRemote) {
entityliving.setArrowCountInEntity(entityliving.getArrowCountInEntity() + 1);
}
if (this.knockbackStrength > 0 || this.knockbackStrengthMod > 0)
{
if (this.knockbackStrength > 0 || this.knockbackStrengthMod > 0) {
f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f3 > 0.0F)
{
if (f3 > 0.0F) {
float knockback = knockbackStrength + knockbackStrengthMod;
movingobjectposition.entityHit.addVelocity(this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f3, 0.1D, this.motionZ * (double) knockback * 0.6000000238418579D / (double) f3);
movingobjectposition.entityHit.addVelocity(
this.motionX
* (double) this.knockbackStrength
* 0.6000000238418579D
/ (double) f3,
0.1D,
this.motionZ * (double) knockback * 0.6000000238418579D / (double) f3);
}
}
if (this.shootingEntity != null)
{
if (this.shootingEntity != null) {
damagesource = DamageSource.causeArrowDamage(this, this);
}
else
{
} else {
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0));
if (this.shootingEntity != null
&& movingobjectposition.entityHit != this.shootingEntity
&& movingobjectposition.entityHit instanceof EntityPlayer
&& this.shootingEntity instanceof EntityPlayerMP) {
((EntityPlayerMP) this.shootingEntity)
.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0));
// TConstruct.packetPipeline.sendTo(new
// S2BPacketChangeGameState(6, 0),
// (EntityPlayerMP) this.shootingEntity);
@@ -286,26 +267,19 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
{
if (!(movingobjectposition.entityHit instanceof EntityEnderman)) {
this.motionX = 0;
this.motionZ = 0;
if (movingobjectposition.entityHit instanceof EntityPlayer)
{
if (movingobjectposition.entityHit instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) movingobjectposition.entityHit;
if (canBePickedUp == 2 || player.inventory.addItemStackToInventory(returnStack))
this.setDead();
}
else if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
} else if (movingobjectposition.entityHit instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) movingobjectposition.entityHit;
if (canBePickedUp == 2 || addItemStackToInventory(returnStack, living))
this.setDead();
if (canBePickedUp == 2 || addItemStackToInventory(returnStack, living)) this.setDead();
}
}
}
else
{
} else {
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
@@ -313,18 +287,19 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
}
else
{
} else {
this.field_145791_d = movingobjectposition.blockX;
this.field_145792_e = movingobjectposition.blockY;
this.field_145789_f = movingobjectposition.blockZ;
this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.field_145790_g =
this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.inData = this.worldObj.getBlockMetadata(
this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX));
this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY));
this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ));
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
speed = MathHelper.sqrt_double(
this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double) speed * 0.05000000074505806D;
this.posY -= this.motionY / (double) speed * 0.05000000074505806D;
this.posZ -= this.motionZ / (double) speed * 0.05000000074505806D;
@@ -333,18 +308,23 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.arrowShake = 0;
this.setIsCritical(false);
if (this.field_145790_g != Blocks.air)
{
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
if (this.field_145790_g != Blocks.air) {
this.field_145790_g.onEntityCollidedWithBlock(
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
}
}
}
if (this.getIsCritical())
{
for (l = 0; l < 4; ++l)
{
this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double) l / 4.0D, this.posY + this.motionY * (double) l / 4.0D, this.posZ + this.motionZ * (double) l / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ);
if (this.getIsCritical()) {
for (l = 0; l < 4; ++l) {
this.worldObj.spawnParticle(
"crit",
this.posX + this.motionX * (double) l / 4.0D,
this.posY + this.motionY * (double) l / 4.0D,
this.posZ + this.motionZ * (double) l / 4.0D,
-this.motionX,
-this.motionY + 0.2D,
-this.motionZ);
}
}
@@ -354,23 +334,21 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) speed) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) speed) * 180.0D / Math.PI);
this.rotationPitch - this.prevRotationPitch < -180.0F;
this.prevRotationPitch -= 360.0F) {
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
this.prevRotationYaw += 360.0F;
}
@@ -380,12 +358,17 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
float speedMod = 1.05f + (mass / 1.26F) / 6F;
ySpeed = 0.05F * speedMod;
if (this.isInWater())
{
for (int j1 = 0; j1 < 4; ++j1)
{
if (this.isInWater()) {
for (int j1 = 0; j1 < 4; ++j1) {
f3 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f3, this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX, this.motionY, this.motionZ);
this.worldObj.spawnParticle(
"bubble",
this.posX - this.motionX * (double) f3,
this.posY - this.motionY * (double) f3,
this.posZ - this.motionZ * (double) f3,
this.motionX,
this.motionY,
this.motionZ);
}
dropSpeed = 0.8F;
@@ -400,28 +383,20 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
}
public boolean addItemStackToInventory (ItemStack par1ItemStack, EntityLivingBase living)
{
if (par1ItemStack == null)
{
public boolean addItemStackToInventory(ItemStack par1ItemStack, EntityLivingBase living) {
if (par1ItemStack == null) {
return false;
}
else
{
try
{
} else {
try {
int stackSize;
do
{
do {
stackSize = par1ItemStack.stackSize;
par1ItemStack.stackSize = this.storePartialItemStack(par1ItemStack, living);
} while (par1ItemStack.stackSize > 0 && par1ItemStack.stackSize < stackSize);
return par1ItemStack.stackSize < stackSize;
}
catch (Throwable throwable)
{
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding item to inventory");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added");
// TODO is this needed???
@@ -435,12 +410,9 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
}
public int getFirstEmptyStack (EntityLivingBase living)
{
for (int i = 0; i < 5; ++i)
{
if (living.getEquipmentInSlot(i) == null)
{
public int getFirstEmptyStack(EntityLivingBase living) {
for (int i = 0; i < 5; ++i) {
if (living.getEquipmentInSlot(i) == null) {
return i;
}
}
@@ -448,72 +420,51 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
return -1;
}
private int storePartialItemStack (ItemStack par1ItemStack, EntityLivingBase living)
{
private int storePartialItemStack(ItemStack par1ItemStack, EntityLivingBase living) {
int stackSize = par1ItemStack.stackSize;
int slotID;
if (!par1ItemStack.isStackable())
{
if (!par1ItemStack.isStackable()) {
slotID = this.getFirstEmptyStack(living);
if (slotID < 0)
{
if (slotID < 0) {
return stackSize;
}
else
{
} else {
living.setCurrentItemOrArmor(slotID, par1ItemStack.copy());
if (living instanceof EntityLiving)
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
if (living instanceof EntityLiving) ((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
return 0;
}
}
else
{
} else {
slotID = this.storeItemStack(par1ItemStack, living);
if (slotID < 0)
{
if (slotID < 0) {
slotID = this.getFirstEmptyStack(living);
}
if (slotID < 0)
{
if (slotID < 0) {
return stackSize;
}
else
{
} else {
ItemStack stack = living.getEquipmentInSlot(slotID);
if (stack == null)
{
if (stack == null) {
living.setCurrentItemOrArmor(slotID, par1ItemStack.copy());
if (living instanceof EntityLiving)
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
if (living instanceof EntityLiving) ((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
return 0;
}
else
{
} else {
int l = stackSize;
if (stackSize > stack.getMaxStackSize() - stack.stackSize)
{
if (stackSize > stack.getMaxStackSize() - stack.stackSize) {
l = stack.getMaxStackSize() - stack.stackSize;
}
if (l > 64 - stack.stackSize)
{
if (l > 64 - stack.stackSize) {
l = 64 - stack.stackSize;
}
if (l == 0)
{
if (l == 0) {
return stackSize;
}
else
{
} else {
stackSize -= l;
stack.stackSize += l;
living.setCurrentItemOrArmor(slotID, stack);
@@ -527,13 +478,14 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
}
private int storeItemStack (ItemStack par1ItemStack, EntityLivingBase living)
{
for (int slotID = 0; slotID < 5; ++slotID)
{
private int storeItemStack(ItemStack par1ItemStack, EntityLivingBase living) {
for (int slotID = 0; slotID < 5; ++slotID) {
ItemStack stack = living.getEquipmentInSlot(slotID);
if (stack != null && stack.isItemEqual(par1ItemStack) && ItemStack.areItemStackTagsEqual(stack, par1ItemStack) && stack.isStackable() && stack.stackSize < stack.getMaxStackSize())
{
if (stack != null
&& stack.isItemEqual(par1ItemStack)
&& ItemStack.areItemStackTagsEqual(stack, par1ItemStack)
&& stack.isStackable()
&& stack.stackSize < stack.getMaxStackSize()) {
return slotID;
}
}
@@ -541,30 +493,25 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
return -1;
}
public void setKnockbackModStrength (float par1)
{
public void setKnockbackModStrength(float par1) {
this.knockbackStrengthMod = par1;
}
@Override
public void writeEntityToNBT (NBTTagCompound tags)
{
public void writeEntityToNBT(NBTTagCompound tags) {
super.writeEntityToNBT(tags);
tags.setTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
}
@Override
public void readEntityFromNBT (NBTTagCompound tags)
{
public void readEntityFromNBT(NBTTagCompound tags) {
super.readEntityFromNBT(tags);
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
}
@Override
public void writeSpawnData (ByteBuf data)
{
if (!returnStack.hasTagCompound())
this.kill();
public void writeSpawnData(ByteBuf data) {
if (!returnStack.hasTagCompound()) this.kill();
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
ByteBufUtils.writeItemStack(data, returnStack);
data.writeFloat(rotationYaw);
@@ -574,40 +521,32 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
data.writeInt(tags.getInteger("RenderAccessory"));
int effects = 0;
if (tags.hasKey("Effect1"))
effects++;
if (tags.hasKey("Effect2"))
effects++;
if (tags.hasKey("Effect3"))
effects++;
if (tags.hasKey("Effect4"))
effects++;
if (tags.hasKey("Effect5"))
effects++;
if (tags.hasKey("Effect6"))
effects++;
if (tags.hasKey("Effect1")) effects++;
if (tags.hasKey("Effect2")) effects++;
if (tags.hasKey("Effect3")) effects++;
if (tags.hasKey("Effect4")) effects++;
if (tags.hasKey("Effect5")) effects++;
if (tags.hasKey("Effect6")) effects++;
data.writeInt(effects);
switch (effects)
{
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
switch (effects) {
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
}
}
@Override
public void readSpawnData (ByteBuf data)
{
public void readSpawnData(ByteBuf data) {
returnStack = ByteBufUtils.readItemStack(data);
rotationYaw = data.readFloat();
mass = data.readFloat();
@@ -616,27 +555,25 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
toolTag.setInteger("RenderHandle", data.readInt());
toolTag.setInteger("RenderHead", data.readInt());
toolTag.setInteger("RenderAccessory", data.readInt());
switch (data.readInt())
{
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
switch (data.readInt()) {
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
}
compound.setTag("InfiTool", toolTag);
returnStack.setTagCompound(compound);
}
public ItemStack getEntityItem ()
{
public ItemStack getEntityItem() {
return returnStack;
}
}
@@ -1,16 +1,13 @@
package tconstruct.tools.entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.world.World;
import tconstruct.items.tools.Dagger;
import tconstruct.library.entity.ProjectileBase;
import tconstruct.library.tools.*;
public class DaggerEntity extends ProjectileBase
{
public class DaggerEntity extends ProjectileBase {
public int roll;
public DaggerEntity(World world) {
@@ -26,31 +23,35 @@ public class DaggerEntity extends ProjectileBase
float pitch = Math.max(-90f, player.rotationPitch - 20f);
// same as in the others, but with pitch upped
this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, pitch);
this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;
this.setLocationAndAngles(
player.posX, player.posY + (double) player.getEyeHeight(), player.posZ, player.rotationYaw, pitch);
this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.posY -= 0.10000000149011612D;
this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;
this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);
this.motionZ = +MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);
this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI);
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI)
* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
this.motionZ = +MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI)
* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI);
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed, accuracy);
}
@Override
public void onUpdate() {
// you turn me right round baby
if(this.ticksInGround == 0)
roll = (roll + 20) % 360;
if (this.ticksInGround == 0) roll = (roll + 20) % 360;
super.onUpdate();
}
@Override
public void onHitEntity(MovingObjectPosition movingobjectposition) {
AbilityHelper.onLeftClickEntity(returnStack, (EntityPlayer)shootingEntity, movingobjectposition.entityHit, (ToolCore)returnStack.getItem());
//super.onHitEntity(movingobjectposition);
AbilityHelper.onLeftClickEntity(
returnStack, (EntityPlayer) shootingEntity, movingobjectposition.entityHit, (ToolCore)
returnStack.getItem());
// super.onHitEntity(movingobjectposition);
}
@Override
@@ -6,31 +6,28 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class FancyEntityItem extends EntityItem
{
public FancyEntityItem(World par1World, double par2, double par4, double par6)
{
public class FancyEntityItem extends EntityItem {
public FancyEntityItem(World par1World, double par2, double par4, double par6) {
super(par1World, par2, par4, par6);
this.isImmuneToFire = true;
this.lifespan = 72000;
}
public FancyEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
{
public FancyEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) {
this(par1World, par2, par4, par6);
this.setEntityItemStack(par8ItemStack);
this.lifespan = (par8ItemStack.getItem() == null ? 6000 : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World));
this.lifespan = (par8ItemStack.getItem() == null
? 6000
: par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World));
}
public FancyEntityItem(World par1World)
{
public FancyEntityItem(World par1World) {
super(par1World);
this.isImmuneToFire = true;
this.lifespan = 72000;
}
public FancyEntityItem(World world, Entity original, ItemStack stack)
{
public FancyEntityItem(World world, Entity original, ItemStack stack) {
this(world, original.posX, original.posY, original.posZ);
this.delayBeforeCanPickup = 20;
this.motionX = original.motionX;
@@ -39,10 +36,8 @@ public class FancyEntityItem extends EntityItem
this.setEntityItemStack(stack);
}
public boolean attackEntityFrom (DamageSource par1DamageSource, float par2)
{
if (par1DamageSource.getDamageType().equals("outOfWorld"))
return true;
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
if (par1DamageSource.getDamageType().equals("outOfWorld")) return true;
return false;
}
}
@@ -11,37 +11,31 @@ import net.minecraft.potion.*;
import net.minecraft.util.*;
import net.minecraft.world.World;
public class LaunchedPotion extends EntityThrowable
{
public class LaunchedPotion extends EntityThrowable {
/**
* The damage value of the thrown potion that this EntityPotion represents.
*/
private ItemStack potionDamage;
public LaunchedPotion(World par1World)
{
public LaunchedPotion(World par1World) {
super(par1World);
}
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, int par3)
{
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, int par3) {
this(par1World, par2EntityLiving, new ItemStack(Items.potionitem, 1, par3));
}
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, ItemStack par3ItemStack)
{
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, ItemStack par3ItemStack) {
super(par1World, par2EntityLiving);
this.potionDamage = par3ItemStack;
}
@SideOnly(Side.CLIENT)
public LaunchedPotion(World par1World, double par2, double par4, double par6, int par8)
{
public LaunchedPotion(World par1World, double par2, double par4, double par6, int par8) {
this(par1World, par2, par4, par6, new ItemStack(Items.potionitem, 1, par8));
}
public LaunchedPotion(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
{
public LaunchedPotion(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) {
super(par1World, par2, par4, par6);
this.potionDamage = par8ItemStack;
}
@@ -50,27 +44,22 @@ public class LaunchedPotion extends EntityThrowable
* Gets the amount of gravity to apply to the thrown entity with each tick.
*/
@Override
protected float getGravityVelocity ()
{
protected float getGravityVelocity() {
return 0.05F;
}
@Override
protected float func_70182_d ()
{
protected float func_70182_d() {
return 1.0F;
}
@Override
protected float func_70183_g ()
{
protected float func_70183_g() {
return -10.0F;
}
public void setPotionDamage (int par1)
{
if (this.potionDamage == null)
{
public void setPotionDamage(int par1) {
if (this.potionDamage == null) {
this.potionDamage = new ItemStack(Items.potionitem, 1, 0);
}
@@ -81,10 +70,8 @@ public class LaunchedPotion extends EntityThrowable
* Returns the damage value of the thrown potion that this EntityPotion
* represents.
*/
public int getPotionDamage ()
{
if (this.potionDamage == null)
{
public int getPotionDamage() {
if (this.potionDamage == null) {
this.potionDamage = new ItemStack(Items.potionitem, 1, 0);
}
@@ -95,53 +82,43 @@ public class LaunchedPotion extends EntityThrowable
* Called when this EntityThrowable hits a block or entity.
*/
@Override
protected void onImpact (MovingObjectPosition par1MovingObjectPosition)
{
if (!this.worldObj.isRemote)
{
protected void onImpact(MovingObjectPosition par1MovingObjectPosition) {
if (!this.worldObj.isRemote) {
List list = Items.potionitem.getEffects(this.potionDamage);
if (list != null && !list.isEmpty())
{
if (list != null && !list.isEmpty()) {
AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D);
List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
if (list1 != null && !list1.isEmpty())
{
if (list1 != null && !list1.isEmpty()) {
Iterator iterator = list1.iterator();
while (iterator.hasNext())
{
while (iterator.hasNext()) {
EntityLivingBase entityliving = (EntityLivingBase) iterator.next();
double d0 = this.getDistanceSqToEntity(entityliving);
if (d0 < 16.0D)
{
if (d0 < 16.0D) {
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
if (entityliving == par1MovingObjectPosition.entityHit)
{
if (entityliving == par1MovingObjectPosition.entityHit) {
d1 = 1.0D;
}
Iterator iterator1 = list.iterator();
while (iterator1.hasNext())
{
while (iterator1.hasNext()) {
PotionEffect potioneffect = (PotionEffect) iterator1.next();
int i = potioneffect.getPotionID();
if (Potion.potionTypes[i].isInstant())
{
Potion.potionTypes[i].affectEntity(this.getThrower(), entityliving, potioneffect.getAmplifier(), d1);
}
else
{
if (Potion.potionTypes[i].isInstant()) {
Potion.potionTypes[i].affectEntity(
this.getThrower(), entityliving, potioneffect.getAmplifier(), d1);
} else {
int j = (int) (d1 * (double) potioneffect.getDuration() + 0.5D);
if (j > 20)
{
entityliving.addPotionEffect(new PotionEffect(i, j, potioneffect.getAmplifier()));
if (j > 20) {
entityliving.addPotionEffect(
new PotionEffect(i, j, potioneffect.getAmplifier()));
}
}
}
@@ -150,7 +127,12 @@ public class LaunchedPotion extends EntityThrowable
}
}
this.worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), this.getPotionDamage());
this.worldObj.playAuxSFX(
2002,
(int) Math.round(this.posX),
(int) Math.round(this.posY),
(int) Math.round(this.posZ),
this.getPotionDamage());
this.setDead();
}
}
@@ -159,21 +141,16 @@ public class LaunchedPotion extends EntityThrowable
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
{
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
super.readEntityFromNBT(par1NBTTagCompound);
if (par1NBTTagCompound.hasKey("Potion"))
{
if (par1NBTTagCompound.hasKey("Potion")) {
this.potionDamage = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Potion"));
}
else
{
} else {
this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue"));
}
if (this.potionDamage == null)
{
if (this.potionDamage == null) {
this.setDead();
}
}
@@ -182,12 +159,10 @@ public class LaunchedPotion extends EntityThrowable
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
{
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
super.writeEntityToNBT(par1NBTTagCompound);
if (this.potionDamage != null)
{
if (this.potionDamage != null) {
par1NBTTagCompound.setTag("Potion", this.potionDamage.writeToNBT(new NBTTagCompound()));
}
}
@@ -15,11 +15,9 @@ import net.minecraft.world.World;
import tconstruct.library.tools.AbilityHelper;
@Deprecated
public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
{
public class RotatingBase extends Entity implements IEntityAdditionalSpawnData {
public RotatingBase(World world)
{
public RotatingBase(World world) {
super(world);
texID = 0;
tex2ID = 16 * 3;
@@ -38,24 +36,28 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
setSize(0.5F, 0.5F);
}
public RotatingBase(World world, double d, double d1, double d2)
{
public RotatingBase(World world, double d, double d1, double d2) {
this(world);
setPosition(d, d1, d2);
yOffset = 0.0F;
}
public RotatingBase(World world, EntityPlayer entityliving, float f, float f1)
{
public RotatingBase(World world, EntityPlayer entityliving, float f, float f1) {
this(world);
owner = entityliving;
setLocationAndAngles(entityliving.posX, entityliving.posY + (double) entityliving.getEyeHeight(), entityliving.posZ, entityliving.rotationYaw, entityliving.rotationPitch);
setLocationAndAngles(
entityliving.posX,
entityliving.posY + (double) entityliving.getEyeHeight(),
entityliving.posZ,
entityliving.rotationYaw,
entityliving.rotationPitch);
posX -= MathHelper.cos((rotationYaw / 180F) * 3.141593F) * 0.16F;
posY -= 0.10000000149011612D;
posZ -= MathHelper.sin((rotationYaw / 180F) * 3.141593F) * 0.16F;
setPosition(posX, posY, posZ);
yOffset = 0.0F;
motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
motionX =
-MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F - 0.2f);
setArrowHeading(motionX, motionY, motionZ, f, f1);
@@ -65,26 +67,20 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
* public void setOnGround(boolean flag) { onGround = flag;
* this.dataWatcher.updateObject(6, Byte.valueOf((byte) (flag == true ? 1 :
* 0))); }
*
*
* public boolean getOnGround() { return
* this.dataWatcher.getWatchableObjectByte(0) == 1 ? true : false; }
*/
@Override
protected void entityInit ()
{
}
protected void entityInit() {}
public void damageItem (int i, boolean flag)
{
if (!flag)
{
public void damageItem(int i, boolean flag) {
if (!flag) {
return;
}
if (returnStack.stackSize < 1)
{
for (int j = 0; j < 8; j++)
{
if (returnStack.stackSize < 1) {
for (int j = 0; j < 8; j++) {
worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
}
@@ -100,19 +96,15 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
* mod_Infi2x2.addToInv((EntityPlayer)returnsTo, returnStack, true); } }
*/
public void determineRotation ()
{
public void determineRotation() {
rotationPitch = -57.29578F * (float) Math.atan2(motionY, motionX);
double d = Math.sqrt((double) (rotationYaw * rotationYaw) + motionY * motionY);
prevRotationYaw = -57.29578F * (float) Math.atan2(motionZ, d);
}
public void onHit (MovingObjectPosition movingobjectposition)
{
}
public void onHit(MovingObjectPosition movingobjectposition) {}
public void setArrowHeading (double d, double d1, double d2, float f, float f1)
{
public void setArrowHeading(double d, double d1, double d2, float f, float f1) {
float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2);
d /= f2;
d1 /= f2;
@@ -133,13 +125,11 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
}
@Override
public void setVelocity (double d, double d1, double d2)
{
public void setVelocity(double d, double d1, double d2) {
motionX = d;
motionY = d1;
motionZ = d2;
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(d * d + d2 * d2);
prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f) * 180D) / 3.1415927410125732D);
@@ -147,33 +137,26 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
}
@Override
public void onUpdate ()
{
public void onUpdate() {
super.onUpdate();
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI);
prevRotationPitch = rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI);
}
if (arrowShake > 0)
{
if (arrowShake > 0) {
arrowShake--;
}
if (onGround)
{
if (onGround) {
Block i = worldObj.getBlock(xTile, yTile, zTile);
if (i != inTile)
{
if (i != inTile) {
onGround = false;
motionX *= rand.nextFloat() * 0.2F;
motionY *= rand.nextFloat() * 0.2F;
motionZ *= rand.nextFloat() * 0.2F;
ticksInGround = 0;
ticksInAir = 0;
}
else
{
} else {
/*
* this.motionX = 0; this.motionY = 0; this.motionZ = 0;
*/
@@ -181,17 +164,14 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
* ticksInGround++; if (ticksInGround == 1200) { setDead(); } if
* (ticksInGround == maxGroundTicks) { setDead(); }
*/
if (!hasHitGround)
{
if (!hasHitGround) {
hasHitGround = true;
damageItem(1, true);
}
return;
}
return;
}
else
{
} else {
ticksInAir++;
}
Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
@@ -199,42 +179,39 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
vec3d = Vec3.createVectorHelper(posX, posY, posZ);
vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (movingobjectposition != null)
{
vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
if (movingobjectposition != null) {
vec3d1 = Vec3.createVectorHelper(
movingobjectposition.hitVec.xCoord,
movingobjectposition.hitVec.yCoord,
movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
List list = worldObj.getEntitiesWithinAABBExcludingEntity(
this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d = 0.0D;
for (int j = 0; j < list.size(); j++)
{
for (int j = 0; j < list.size(); j++) {
Entity entity1 = (Entity) list.get(j);
if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5)
{
if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5) {
continue;
}
float f3 = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f3, f3, f3);
MovingObjectPosition movingobjectposition2 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (movingobjectposition2 == null)
{
if (movingobjectposition2 == null) {
continue;
}
double d1 = vec3d.distanceTo(movingobjectposition2.hitVec);
if (d1 < d || d == 0.0D)
{
if (d1 < d || d == 0.0D) {
entity = entity1;
d = d1;
}
}
if (entity != null)
{
if (entity != null) {
MovingObjectPosition movingobjectposition1 = new MovingObjectPosition(entity);
onHit(movingobjectposition1);
}
if (movingobjectposition != null)
{
if (movingobjectposition != null) {
onHit(movingobjectposition);
}
posX += motionX;
@@ -242,28 +219,27 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
posZ += motionZ;
float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F)
{
}
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F)
{
}
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F)
{
}
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F)
{
}
for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D);
rotationPitch - prevRotationPitch < -180F;
prevRotationPitch -= 360F) {}
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f2 = 0.99F;
float f4 = 0.03F;
if (isInWater())
{
for (int k = 0; k < 4; k++)
{
if (isInWater()) {
for (int k = 0; k < 4; k++) {
float f5 = 0.25F;
worldObj.spawnParticle("bubble", posX - motionX * (double) f5, posY - motionY * (double) f5, posZ - motionZ * (double) f5, motionX, motionY, motionZ);
worldObj.spawnParticle(
"bubble",
posX - motionX * (double) f5,
posY - motionY * (double) f5,
posZ - motionZ * (double) f5,
motionX,
motionY,
motionZ);
}
f2 = 0.8F;
@@ -273,37 +249,33 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
motionZ *= f2;
motionY -= f4;
setPosition(posX, posY, posZ);
if (!onGround)
{
if (!onGround) {
prevBoomerangRotation = boomerangRotation;
for (boomerangRotation += 36F; boomerangRotation > 360F; boomerangRotation -= 360F)
{
}
for (boomerangRotation += 36F; boomerangRotation > 360F; boomerangRotation -= 360F) {}
}
}
/*
* public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
* super.readEntityFromNBT(par1NBTTagCompound);
*
*
* if (par1NBTTagCompound.hasKey("Potion")) { this.potionDamage =
* ItemStack.loadItemStackFromNBT
* (par1NBTTagCompound.getCompoundTag("Potion")); } else {
* this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue")); }
*
*
* if (this.potionDamage == null) { this.setDead(); } }
*
*
* public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
* super.writeEntityToNBT(par1NBTTagCompound);
*
*
* if (this.potionDamage != null) {
*
*
* } }
*/
@Override
public void writeEntityToNBT (NBTTagCompound tags)
{
public void writeEntityToNBT(NBTTagCompound tags) {
tags.setTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
tags.setShort("xTile", (short) xTile);
tags.setShort("yTile", (short) yTile);
@@ -315,8 +287,7 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
}
@Override
public void readEntityFromNBT (NBTTagCompound tags)
{
public void readEntityFromNBT(NBTTagCompound tags) {
// super.readEntityFromNBT(tags);
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
@@ -331,39 +302,32 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
}
@Override
public void onCollideWithPlayer (EntityPlayer entityplayer)
{
public void onCollideWithPlayer(EntityPlayer entityplayer) {
onCollideWithPlayer(entityplayer, true);
}
public void onCollideWithPlayer (EntityPlayer entityplayer, boolean flag)
{
if (returnStack == null || returnStack.stackSize == 0 || worldObj.isRemote)
{
public void onCollideWithPlayer(EntityPlayer entityplayer, boolean flag) {
if (returnStack == null || returnStack.stackSize == 0 || worldObj.isRemote) {
return;
}
if (!flag || onGround && arrowShake <= 0)
{
if (!flag || returnsTo != null && !returnsTo.isDead && returnsTo != entityplayer)
{
if (!flag || onGround && arrowShake <= 0) {
if (!flag || returnsTo != null && !returnsTo.isDead && returnsTo != entityplayer) {
return;
}
if (!doNotRetrieve)
AbilityHelper.addToInv(entityplayer, returnStack, true);
worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
if (!doNotRetrieve) AbilityHelper.addToInv(entityplayer, returnStack, true);
worldObj.playSoundAtEntity(
this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityplayer.onItemPickup(this, 1);
kill();
}
}
@Override
public float getShadowSize ()
{
public float getShadowSize() {
return 0.0F;
}
public ItemStack getEntityItem ()
{
public ItemStack getEntityItem() {
return returnStack;
}
@@ -391,8 +355,7 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
public boolean doNotRetrieve;
@Override
public void writeSpawnData (ByteBuf data)
{
public void writeSpawnData(ByteBuf data) {
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
ByteBufUtils.writeItemStack(data, returnStack);
data.writeFloat(rotationYaw);
@@ -402,40 +365,32 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
data.writeInt(tags.getInteger("RenderExtra"));
int effects = 0;
if (tags.hasKey("Effect1"))
effects++;
if (tags.hasKey("Effect2"))
effects++;
if (tags.hasKey("Effect3"))
effects++;
if (tags.hasKey("Effect4"))
effects++;
if (tags.hasKey("Effect5"))
effects++;
if (tags.hasKey("Effect6"))
effects++;
if (tags.hasKey("Effect1")) effects++;
if (tags.hasKey("Effect2")) effects++;
if (tags.hasKey("Effect3")) effects++;
if (tags.hasKey("Effect4")) effects++;
if (tags.hasKey("Effect5")) effects++;
if (tags.hasKey("Effect6")) effects++;
data.writeInt(effects);
switch (effects)
{
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
switch (effects) {
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
}
}
@Override
public void readSpawnData (ByteBuf data)
{
public void readSpawnData(ByteBuf data) {
returnStack = ByteBufUtils.readItemStack(data);
rotationYaw = data.readFloat();
NBTTagCompound compound = new NBTTagCompound();
@@ -445,20 +400,19 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
toolTag.setInteger("RenderAccessory", data.readInt());
toolTag.setInteger("RenderExtra", data.readInt());
switch (data.readInt())
{
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
switch (data.readInt()) {
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
}
compound.setTag("InfiTool", toolTag);
returnStack.setTagCompound(compound);
@@ -12,28 +12,24 @@ import tconstruct.library.TConstructRegistry;
import tconstruct.tools.logic.BattlesignLogic;
import tconstruct.util.network.SignDataPacket;
public class BattlesignGui extends GuiScreen
{
public class BattlesignGui extends GuiScreen {
private BattlesignLogic battlesign;
private float bgColR = 1F;
private float bgColG = 1F;
private float bgColB = 1F;
private static ResourceLocation background = new ResourceLocation("tinker:textures/gui/battlesignText.png");
private String[] text = { "", "", "", "", "" };
private String[] text = {"", "", "", "", ""};
int currentLine = 0;
public BattlesignGui(BattlesignLogic logic)
{
public BattlesignGui(BattlesignLogic logic) {
this.battlesign = logic;
ItemStack stack = logic.getEquipmentItem();
if (stack != null)
{
if (stack != null) {
NBTTagCompound tag = stack.getTagCompound().getCompoundTag("InfiTool");
if (tag != null)
{
if (tag != null) {
int head = tag.getInteger("Head");
int bgCol = TConstructRegistry.getMaterial(head).primaryColor();
@@ -46,8 +42,7 @@ public class BattlesignGui extends GuiScreen
}
@Override
public void initGui ()
{
public void initGui() {
buttonList.clear();
super.initGui();
@@ -61,8 +56,7 @@ public class BattlesignGui extends GuiScreen
}
@Override
public void drawScreen (int mouseX, int mouseY, float something)
{
public void drawScreen(int mouseX, int mouseY, float something) {
Tessellator t = Tessellator.instance;
GL11.glColor4f(bgColR, bgColG, bgColB, 1F);
@@ -77,100 +71,103 @@ public class BattlesignGui extends GuiScreen
GL11.glPushMatrix();
float lum = calcLuminance(bgColR, bgColG, bgColB);
for (int i = 0; i < text.length; i++)
{
fontRendererObj.drawString((lum >= 35F ? EnumChatFormatting.BLACK : lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE) + (i == currentLine ? "> " : "") + text[i] + (i == currentLine ? " \u00A7r" + (lum >= 35F ? EnumChatFormatting.BLACK : lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE) + "<" : ""), k - fontRendererObj.getStringWidth((i == currentLine ? "> " : "") + text[i] + (i == currentLine ? " <" : "")) / 2 + 51, l + 4 + 10 * i, 0);
for (int i = 0; i < text.length; i++) {
fontRendererObj.drawString(
(lum >= 35F
? EnumChatFormatting.BLACK
: lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE)
+ (i == currentLine ? "> " : "")
+ text[i]
+ (i == currentLine
? " \u00A7r"
+ (lum >= 35F
? EnumChatFormatting.BLACK
: lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE)
+ "<"
: ""),
k
- fontRendererObj.getStringWidth(
(i == currentLine ? "> " : "") + text[i] + (i == currentLine ? " <" : ""))
/ 2
+ 51,
l + 4 + 10 * i,
0);
}
GL11.glPopMatrix();
}
@Override
protected void keyTyped (char c, int i)
{
protected void keyTyped(char c, int i) {
super.keyTyped(c, i);
if (fontRendererObj.getStringWidth(text[currentLine]) < 90 && ChatAllowedCharacters.isAllowedCharacter(c))
{
if (Keyboard.isKeyDown(56) && c == 'f' && (text[currentLine].length() == 0 || text[currentLine].charAt(text[currentLine].length() - 1) != '\u00A7'))
{
if (fontRendererObj.getStringWidth(text[currentLine]) < 90 && ChatAllowedCharacters.isAllowedCharacter(c)) {
if (Keyboard.isKeyDown(56)
&& c == 'f'
&& (text[currentLine].length() == 0
|| text[currentLine].charAt(text[currentLine].length() - 1) != '\u00A7')) {
text[currentLine] += "\u00A7";
}
else
{
} else {
text[currentLine] += c;
}
}
else
{
switch (i)
{
case 14:
if (text[currentLine].length() > 0)
{
text[currentLine] = text[currentLine].substring(0, text[currentLine].length() - 1);
}
} else {
switch (i) {
case 14:
if (text[currentLine].length() > 0) {
text[currentLine] = text[currentLine].substring(0, text[currentLine].length() - 1);
}
break;
case 28:
moveLine(1);
break;
case 200:
moveLine(-1);
break;
case 208:
moveLine(1);
break;
break;
case 28:
moveLine(1);
break;
case 200:
moveLine(-1);
break;
case 208:
moveLine(1);
break;
}
}
}
private void moveLine (int i)
{
if (i < 0)
{
if (currentLine <= 0)
{
private void moveLine(int i) {
if (i < 0) {
if (currentLine <= 0) {
currentLine = text.length - 1;
}
else
{
} else {
currentLine--;
}
}
else
{
if (currentLine >= text.length - 1)
{
} else {
if (currentLine >= text.length - 1) {
currentLine = 0;
}
else
{
} else {
currentLine++;
}
}
}
@Override
public void onGuiClosed ()
{
public void onGuiClosed() {
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
TConstruct.packetPipeline.sendToServer(new SignDataPacket(battlesign.getWorldObj().provider.dimensionId, battlesign.xCoord, battlesign.yCoord, battlesign.zCoord, text));
TConstruct.packetPipeline.sendToServer(new SignDataPacket(
battlesign.getWorldObj().provider.dimensionId,
battlesign.xCoord,
battlesign.yCoord,
battlesign.zCoord,
text));
}
private float calcLuminance (float r, float g, float b)
{
private float calcLuminance(float r, float g, float b) {
return (r * 255 * 0.299f + g * 255 * 0.587f + b * 255 * 0.114f) / 3;
}
@Override
protected void actionPerformed (GuiButton button)
{
if (button.id == 0)
{
protected void actionPerformed(GuiButton button) {
if (button.id == 0) {
this.mc.displayGuiScreen((GuiScreen) null);
this.mc.setIngameFocus();
}
@@ -24,7 +24,7 @@ public class ChestSlot extends Slot {
@SideOnly(Side.CLIENT)
@Override
public boolean func_111238_b/*isEnabled*/() {
public boolean func_111238_b /*isEnabled*/() {
return enabled;
}
@@ -57,4 +57,10 @@ public class ChestSlot extends Slot {
}
return super.canTakeStack(player);
}
@Override
public ItemStack getStack() {
ItemStack stack = super.getStack();
return (stack != null && stack.stackSize > 0) ? stack : null;
}
}
@@ -4,6 +4,9 @@ import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import cpw.mods.fml.common.Optional;
import java.awt.Rectangle;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -22,17 +25,13 @@ import tconstruct.library.tools.ToolMaterial;
import tconstruct.library.util.HarvestLevels;
import tconstruct.tools.logic.CraftingStationLogic;
import java.awt.Rectangle;
import java.util.Collections;
import java.util.List;
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
/*
* Slider/slots related. Taken & adapted from Tinkers Construct 1.12 under the MIT License
*/
private static final ResourceLocation gui_inventory = new ResourceLocation("tinker", "textures/gui/generic.png");
public static final GuiElementScalable slotElement = new GuiElementScalable(7, 7, 18, 18, 64, 64);
public static final GuiElementScalable slotEmptyElement = new GuiElementScalable(7 + 18, 7, 18, 18, 64, 64);
@@ -44,7 +43,8 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
private static final GuiElementScalable sliderBackground = new GuiElementScalable(43, 8, 12, 30, 64, 64);
private static final GuiElementScalable textBackground = new GuiElementScalable(7 + 18, 7, 18, 10, 64, 64);
private final GuiSliderWidget slider = new GuiSliderWidget(sliderNormal, sliderHigh, sliderLow, sliderTop, sliderBottom, sliderBackground);
private final GuiSliderWidget slider =
new GuiSliderWidget(sliderNormal, sliderHigh, sliderLow, sliderTop, sliderBottom, sliderBackground);
private final GuiBorderWidget border = new GuiBorderWidget();
private int firstSlotId;
@@ -52,7 +52,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
private int chestSlotCount;
/* end slider/slots */
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/tinkertable.png");
private static final ResourceLocation description = new ResourceLocation("tinker", "textures/gui/description.png");
private static final ResourceLocation icons = new ResourceLocation("tinker", "textures/gui/icons.png");
@@ -64,19 +64,19 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
public GuiTextField text;
public String title, body = "";
CraftingStationLogic logic;
private int craftingLeft = 0;
private int craftingTop = 0;
private int craftingTextLeft = 0;
private int descLeft = 0;
private int descTop = 0;
private int descTextLeft = 0;
private int chestLeft = 0;
private int chestTop = 0;
private int chestWidth = 0;
private int chestHeight = 0;
public CraftingStationGui(InventoryPlayer inventory, CraftingStationLogic logic, World world, int x, int y, int z) {
super(logic.getGuiContainer(inventory, world, x, y, z));
this.logic = logic;
@@ -119,43 +119,52 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
if (logic.chest != null) {
if (logic.chest.get() instanceof TileEntity) {
TileEntity te = (TileEntity) logic.chest.get();
if (te == null || te.getWorldObj().getTileEntity(te.xCoord, te.yCoord, te.zCoord) == null && te.getWorldObj().isRemote) {
if (te == null
|| te.getWorldObj().getTileEntity(te.xCoord, te.yCoord, te.zCoord) == null
&& te.getWorldObj().isRemote) {
mc.thePlayer.closeScreen();
return;
}
}
this.fontRendererObj.drawString(StatCollector.translateToLocal(logic.chest.get().getInventoryName()), 8, 6, 0x202020);
this.fontRendererObj.drawString(
StatCollector.translateToLocal(logic.chest.get().getInventoryName()), 8, 6, 0x202020);
}
this.fontRendererObj.drawString(StatCollector.translateToLocal(logic.tinkerTable ? "crafters.TinkerTable" : logic.getInvName()), craftingTextLeft + 8, 6, 0x202020);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), craftingTextLeft + 8, 72, 0x202020);
this.fontRendererObj.drawString(
StatCollector.translateToLocal(logic.tinkerTable ? "crafters.TinkerTable" : logic.getInvName()),
craftingTextLeft + 8,
6,
0x202020);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"), craftingTextLeft + 8, 72, 0x202020);
if (logic.tinkerTable) {
if (logic.isStackInSlot(0)) // output slot = modified item
drawToolStats(logic.getStackInSlot(0));
drawToolStats(logic.getStackInSlot(0));
else if (logic.isStackInSlot(5)) { // center slot if no output item
// other slots empty?
if (!logic.isStackInSlot(1) && !logic.isStackInSlot(2) && !logic.isStackInSlot(3) && !logic.isStackInSlot(4)
&& !logic.isStackInSlot(6) && !logic.isStackInSlot(7) && !logic.isStackInSlot(8) && !logic.isStackInSlot(9))
drawToolStats(logic.getStackInSlot(5));
else
drawToolInformation();
} else
drawToolInformation();
if (!logic.isStackInSlot(1)
&& !logic.isStackInSlot(2)
&& !logic.isStackInSlot(3)
&& !logic.isStackInSlot(4)
&& !logic.isStackInSlot(6)
&& !logic.isStackInSlot(7)
&& !logic.isStackInSlot(8)
&& !logic.isStackInSlot(9)) drawToolStats(logic.getStackInSlot(5));
else drawToolInformation();
} else drawToolInformation();
}
}
void drawToolStats(ItemStack stack) {
if (stack.getItem() instanceof IModifyable)
ToolStationGuiHelper.drawToolStats(stack, descTextLeft + 10, 0);
if (stack.getItem() instanceof IModifyable) ToolStationGuiHelper.drawToolStats(stack, descTextLeft + 10, 0);
int matID = PatternBuilder.instance.getPartID(stack);
if (matID != Short.MAX_VALUE && matID > 0) {
ToolMaterial material = TConstructRegistry.getMaterial(matID);
if (material != null)
drawMaterialStats(material);
if (material != null) drawMaterialStats(material);
}
}
@@ -174,17 +183,44 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
drawCenteredString(this.fontRendererObj, centerTitle, baseX + 55, baseY, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter4") + materialEnum.durability(), baseX, baseY + 16, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter5") + materialEnum.handleDurability() + "x", baseX, baseY + 27, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter6") + materialEnum.toolSpeed() / 100f, baseX, baseY + 38, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter7") + HarvestLevels.getHarvestLevelName(materialEnum.harvestLevel()), baseX, baseY + 49, 16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter4") + materialEnum.durability(),
baseX,
baseY + 16,
16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter5") + materialEnum.handleDurability() + "x",
baseX,
baseY + 27,
16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter6") + materialEnum.toolSpeed() / 100f,
baseX,
baseY + 38,
16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter7")
+ HarvestLevels.getHarvestLevelName(materialEnum.harvestLevel()),
baseX,
baseY + 49,
16777215);
int attack = materialEnum.attack();
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
String heart = attack == 2
? StatCollector.translateToLocal("gui.partcrafter8")
: StatCollector.translateToLocal("gui.partcrafter9");
if (attack % 2 == 0)
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart, baseX, baseY + 60, 0xffffff);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart,
baseX,
baseY + 60,
0xffffff);
else
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart, baseX, baseY + 60, 0xffffff);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart,
baseX,
baseY + 60,
0xffffff);
}
@Override
@@ -207,9 +243,8 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(gui_inventory);
if(hasChest()) {
if (hasChest()) {
chestLeft += border.w;
chestTop += border.h;
@@ -243,7 +278,6 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
this.mc.getTextureManager().bindTexture(description);
this.drawTexturedModalRect(this.descLeft, this.descTop, 0, 0, 126, 172);
}
}
@Override
@@ -275,19 +309,19 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
final int cw = (logic.chest != null ? chestWidth : 0);
if(logic.chest != null) {
if (logic.chest != null) {
final Rectangle blah = new Rectangle(x, y, w, h);
final Rectangle chestRectangle = new Rectangle(
chestLeft, chestTop, chestWidth, chestHeight + (shouldDrawName() ? textBackground.y : 0) + (border.h * 2)
);
if(chestRectangle.intersects(blah))
return true;
chestLeft,
chestTop,
chestWidth,
chestHeight + (shouldDrawName() ? textBackground.y : 0) + (border.h * 2));
if (chestRectangle.intersects(blah)) return true;
}
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize)
return false;
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize) return false;
return x - w - 4 >= guiLeft + cw && x + 4 <= guiLeft + xSize + cw + (logic.tinkerTable ? 126 : 0);
}
@@ -298,14 +332,16 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
public boolean isMouseInChest(int mouseX, int mouseY) {
final int xMod = (slider.isEnabled() ? slider.width : 0) + border.w;
final int yMod = (shouldDrawName() ? textBackground.y : 0) + (border.h * 2);
return mouseX >= (this.chestLeft - xMod) && mouseX < (chestLeft + chestWidth + xMod) &&
mouseY >= (this.chestTop - yMod) && mouseY < (chestTop + chestHeight + yMod);
return mouseX >= (this.chestLeft - xMod)
&& mouseX < (chestLeft + chestWidth + xMod)
&& mouseY >= (this.chestTop - yMod)
&& mouseY < (chestTop + chestHeight + yMod);
}
public boolean isMouseOverFullSlot(int mouseX, int mouseY) {
for(final Object slot : inventorySlots.inventorySlots) {
if(isMouseOverSlot((Slot)slot, mouseX, mouseY) && ((Slot)slot).getHasStack()) {
for (final Object slot : inventorySlots.inventorySlots) {
if (isMouseOverSlot((Slot) slot, mouseX, mouseY) && ((Slot) slot).getHasStack()) {
return true;
}
}
@@ -313,22 +349,24 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
}
protected boolean shouldDrawName() {
return this.logic.chest != null && this.logic.chest.get().getInventoryName() != null && !this.logic.chest.get().getInventoryName().isEmpty();
return this.logic.chest != null
&& this.logic.chest.get().getInventoryName() != null
&& !this.logic.chest.get().getInventoryName().isEmpty();
}
@Override
public void func_146977_a/*drawSlot*/(Slot slot) {
if(!slot.func_111238_b/*isEnabled*/()) return;
public void func_146977_a /*drawSlot*/(Slot slot) {
if (!slot.func_111238_b /*isEnabled*/()) return;
super.func_146977_a(slot);
}
public boolean shouldDrawSlot(Slot slot) {
if(!(slot instanceof ChestSlot)) return true;
if (!(slot instanceof ChestSlot)) return true;
ChestSlot chestSlot = (ChestSlot) slot;
// all visible
if(!slider.isEnabled()) return true;
if (!slider.isEnabled()) return true;
return firstSlotId <= chestSlot.getVisualIndex() && lastSlotId > chestSlot.getVisualIndex();
}
@@ -337,7 +375,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
public boolean isMouseOverSlot(Slot slotIn, int mouseX, int mouseY) {
return super.isMouseOverSlot(slotIn, mouseX, mouseY) && shouldDrawSlot(slotIn);
}
private int getDisplayedRows() {
return chestHeight / slotElement.h;
}
@@ -346,7 +384,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
int h = slotElement.h * logic.invRows;
// not higher than the max
while(h > max) {
while (h > max) {
h -= slotElement.h;
}
return h;
@@ -362,28 +400,32 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
chestSlotCount = logic.slotCount;
// slider needed?
if(getDisplayedRows() < logic.invRows) {
if (getDisplayedRows() < logic.invRows) {
slider.enable();
}
else {
} else {
slider.disable();
}
chestWidth = logic.invColumns * CraftingStationGui.slotElement.w + 2 * border.w + (slider.isEnabled() ? slider.width : 0);
chestWidth = logic.invColumns * CraftingStationGui.slotElement.w
+ 2 * border.w
+ (slider.isEnabled() ? slider.width : 0);
chestLeft = guiLeft - chestWidth;
chestTop = guiTop;
// Leaving out the xSize increase by chestSize and adjusting where it's used, because otherwise it shifts both the bookmarks and item panel
// Leaving out the xSize increase by chestSize and adjusting where it's used, because otherwise it shifts both
// the bookmarks and item panel
// way too far out. If anything (mouseClick, for example) relies on xSize, you'll need to hack it like below.
// xSize += guiLeft - chestLeft;
// xSize += guiLeft - chestLeft;
guiLeft = chestLeft;
border.setPosition(chestLeft, chestTop);
border.setSize(chestWidth, chestHeight + (shouldDrawName() ? textBackground.h : 0) + 2 * border.h);
slider.show();
slider.setPosition(chestLeft + logic.invColumns * slotElement.w + border.w, chestTop + (shouldDrawName() ? textBackground.h : 0) + border.h);
slider.setPosition(
chestLeft + logic.invColumns * slotElement.w + border.w,
chestTop + (shouldDrawName() ? textBackground.h : 0) + border.h);
slider.setSize(chestHeight);
slider.setSliderParameters(0, logic.invRows - getDisplayedRows(), 1);
@@ -393,7 +435,7 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
@Override
protected void mouseClicked(int x, int y, int button) {
// Hacks
final int height = ySize;
final int height = ySize;
if (logic.chest != null && x >= guiLeft && x <= guiLeft + chestWidth) {
ySize = border.height;
@@ -404,11 +446,11 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
xSize -= chestWidth;
ySize = height;
}
@Override
protected void mouseMovedOrUp(int x, int y, int button) {
// Hacks
final int height = ySize;
final int height = ySize;
if (logic.chest != null && x >= guiLeft && x <= guiLeft + chestWidth) {
ySize = border.height;
@@ -419,29 +461,29 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
xSize -= chestWidth;
ySize = height;
}
// updates slot visibility
protected void updateChestSlots() {
if(!hasChest()) return;
if (!hasChest()) return;
final IInventory secondInventory = logic.getSecondInventory();
int xOffset = border.w;
int yOffset = border.h;
if(shouldDrawName()) {
if (shouldDrawName()) {
yOffset += textBackground.h;
}
firstSlotId = slider.getValue() * logic.invColumns;
lastSlotId = Math.min(chestSlotCount, firstSlotId + getDisplayedRows() * logic.invColumns);
for(Object o : inventorySlots.inventorySlots) {
if(!(o instanceof ChestSlot)) continue;
final ChestSlot slot = (ChestSlot)o;
if(shouldDrawSlot(slot)) {
for (Object o : inventorySlots.inventorySlots) {
if (!(o instanceof ChestSlot)) continue;
final ChestSlot slot = (ChestSlot) o;
if (shouldDrawSlot(slot)) {
slot.enable();
// calc position of the slot
final int offset = slot.getVisualIndex() - firstSlotId;
@@ -450,39 +492,36 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
slot.xDisplayPosition = x + xOffset + 1 /*- this.chestWidth*/;
slot.yDisplayPosition = y + yOffset + 1;
}
else {
} else {
slot.disable();
slot.xDisplayPosition = 0;
slot.yDisplayPosition = 0;
}
}
}
// drawSlots
protected void drawChestSlots(int xPos, int yPos) {
if(!hasChest()) return;
if (!hasChest()) return;
int width = logic.invColumns * slotElement.w;
int height = chestHeight - border.h * 2;
int fullRows = (lastSlotId - firstSlotId) / logic.invColumns;
int slotsLeft = (lastSlotId - firstSlotId) % logic.invColumns;
int y; // We use it after the loop
for(y = 0; y < fullRows * slotElement.h && y < height; y += slotElement.h) {
for (y = 0; y < fullRows * slotElement.h && y < height; y += slotElement.h) {
slotElement.drawScaledX(xPos, yPos + y, width);
}
// draw partial row and unused slots
if(slotsLeft > 0) {
if (slotsLeft > 0) {
slotElement.drawScaledX(xPos, yPos + y, slotsLeft * slotElement.w);
// empty slots that don't exist
slotEmptyElement.drawScaledX(xPos + slotsLeft * slotElement.w, yPos + y, width - slotsLeft * slotElement.w);
}
}
/*
* Hide the deprecated stuff at the bottom
@@ -7,35 +7,31 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import tconstruct.tools.logic.FrypanLogic;
public class FrypanGui extends GuiContainer
{
public class FrypanGui extends GuiContainer {
public FrypanLogic logic;
public FrypanGui(InventoryPlayer inventoryplayer, FrypanLogic frypan, World world, int x, int y, int z)
{
public FrypanGui(InventoryPlayer inventoryplayer, FrypanLogic frypan, World world, int x, int y, int z) {
super(frypan.getGuiContainer(inventoryplayer, world, x, y, z));
logic = frypan;
}
@Override
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRendererObj.drawString(StatCollector.translateToLocal("crafters.Frypan"), 60, 6, 0x404040);
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/frypan.png");
@Override
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
{
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(background);
int cornerX = (width - xSize) / 2;
int cornerY = (height - ySize) / 2;
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
if (logic.fuel > 0)
{
if (logic.fuel > 0) {
int fuel = logic.gaugeFuelScaled(12);
drawTexturedModalRect(cornerX + 27, (cornerY + 40) - fuel, 176, 12 - fuel, 14, fuel + 2);
}
@@ -10,13 +10,12 @@ import tconstruct.tools.inventory.FurnaceContainer;
import tconstruct.tools.logic.FurnaceLogic;
@SideOnly(Side.CLIENT)
public class FurnaceGui extends GuiContainer
{
private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/furnace.png");
public class FurnaceGui extends GuiContainer {
private static final ResourceLocation furnaceGuiTextures =
new ResourceLocation("textures/gui/container/furnace.png");
private FurnaceLogic logic;
public FurnaceGui(InventoryPlayer inventory, FurnaceLogic furnace)
{
public FurnaceGui(InventoryPlayer inventory, FurnaceLogic furnace) {
super(new FurnaceContainer(inventory, furnace));
this.logic = furnace;
}
@@ -26,8 +25,7 @@ public class FurnaceGui extends GuiContainer
* the items)
*/
@Override
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String s = this.logic.isInvNameLocalized() ? this.logic.getInvName() : I18n.format(this.logic.getInvName());
this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
@@ -38,8 +36,7 @@ public class FurnaceGui extends GuiContainer
* items)
*/
@Override
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
{
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
int k = (this.width - this.xSize) / 2;
@@ -47,8 +44,7 @@ public class FurnaceGui extends GuiContainer
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int i1;
if (this.logic.isBurning())
{
if (this.logic.isBurning()) {
i1 = this.logic.gaugeFuelScaled(12);
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
}
@@ -1,20 +1,20 @@
package tconstruct.tools.gui;
/*
* Taken from Tinker's Construct 1.12 under the MIT License
*
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Taken from Tinker's Construct 1.12 under the MIT License
*
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
public class GuiBorderWidget {
// all elements based on generic gui
@@ -44,7 +44,7 @@ public class GuiBorderWidget {
this.width = width;
this.height = height;
}
/** Sets the size so that the given point is the upper left corner of the inside */
public void setPosInner(int x, int y) {
setPosition(x - cornerTopLeft.w, y - cornerTopLeft.h);
@@ -6,20 +6,20 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import tconstruct.library.client.StencilGuiElement;
public class GuiButtonStencil extends GuiButton
{
public class GuiButtonStencil extends GuiButton {
/**
* True for pointing right (next page), false for pointing left (previous
* page).
*/
int textureX;
int textureY;
public String texture;
public StencilGuiElement element;
private static ResourceLocation background;
public GuiButtonStencil(int id, int posX, int posY, int texX, int texY, String domain, String tex, StencilGuiElement e)
{
public GuiButtonStencil(
int id, int posX, int posY, int texX, int texY, String domain, String tex, StencilGuiElement e) {
super(id, posX, posY, 18, 18, "");
textureX = texX;
textureY = texY;
@@ -32,15 +32,19 @@ public class GuiButtonStencil extends GuiButton
* Draws this button to the screen.
*/
@Override
public void drawButton (Minecraft mc, int mouseX, int mouseY)
{
if (this.visible)
{
boolean var4 = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
boolean var4 = mouseX >= this.xPosition
&& mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(background);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
this.field_146123_n = mouseX >= this.xPosition
&& mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
int var5 = this.getHoverState(this.field_146123_n);
int index = 18 * getHoverState(field_146123_n);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 144 + index * 2, 234, 18, 18);
@@ -8,22 +8,21 @@ import org.lwjgl.opengl.GL11;
import tconstruct.library.client.ToolGuiElement;
@SideOnly(Side.CLIENT)
public class GuiButtonTool extends GuiButton
{
public class GuiButtonTool extends GuiButton {
/**
* True for pointing right (next page), false for pointing left (previous
* page).
*/
int textureX;
int textureY;
public String texture;
public ToolGuiElement element;
private ResourceLocation background;// = new
// ResourceLocation("tinker",
// "textures/gui/armorextended.png");
private ResourceLocation background; // = new
// ResourceLocation("tinker",
// "textures/gui/armorextended.png");
public GuiButtonTool(int id, int posX, int posY, int texX, int texY, String domain, String tex, ToolGuiElement e)
{
public GuiButtonTool(int id, int posX, int posY, int texX, int texY, String domain, String tex, ToolGuiElement e) {
super(id, posX, posY, 18, 18, "");
textureX = texX;
textureY = texY;
@@ -36,15 +35,19 @@ public class GuiButtonTool extends GuiButton
* Draws this button to the screen.
*/
@Override
public void drawButton (Minecraft mc, int mouseX, int mouseY)
{
if (this.visible)
{
boolean var4 = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
boolean var4 = mouseX >= this.xPosition
&& mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(background);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
this.field_146123_n = mouseX >= this.xPosition
&& mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
int var5 = this.getHoverState(this.field_146123_n);
int index = 18 * getHoverState(field_146123_n);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 144 + index * 2, 216, 18, 18);
@@ -5,20 +5,20 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
/*
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
*
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
*
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
@SideOnly(Side.CLIENT)
public class GuiElementDuex {
@@ -88,4 +88,4 @@ public class GuiElementDuex {
return new GuiElementDuex(x, y, w, h, this.w, this.h);
}
}
}
}
@@ -5,20 +5,20 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
/*
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
*
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
*
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
@SideOnly(Side.CLIENT)
public class GuiElementScalable extends GuiElementDuex {
@@ -32,12 +32,12 @@ public class GuiElementScalable extends GuiElementDuex {
}
public int drawScaledX(int xPos, int yPos, int width) {
for(int i = 0; i < width / w; i++) {
for (int i = 0; i < width / w; i++) {
draw(xPos + i * w, yPos);
}
// remainder that doesn't fit total width
int remainder = width % w;
if(remainder > 0) {
if (remainder > 0) {
GuiScreen.func_146110_a(xPos + width - remainder, yPos, x, y, remainder, h, texW, texH);
}
@@ -45,12 +45,12 @@ public class GuiElementScalable extends GuiElementDuex {
}
public int drawScaledY(int xPos, int yPos, int height) {
for(int i = 0; i < height / h; i++) {
for (int i = 0; i < height / h; i++) {
draw(xPos, yPos + i * h);
}
// remainder that doesn't fit total width
int remainder = height % h;
if(remainder > 0) {
if (remainder > 0) {
// drawModalRectWithCustomSizedTexture
GuiScreen.func_146110_a(xPos, yPos + height - remainder, x, y, w, remainder, texW, texH);
}
@@ -61,7 +61,7 @@ public class GuiElementScalable extends GuiElementDuex {
public int drawScaled(int xPos, int yPos, int width, int height) {
// we draw full height row-wise
int full = height / this.h;
for(int i = 0; i < full; i++) {
for (int i = 0; i < full; i++) {
drawScaledX(xPos, yPos + i * this.h, width);
}
@@ -70,12 +70,12 @@ public class GuiElementScalable extends GuiElementDuex {
// and the remainder is drawn manually
int yRest = height % this.h;
// the same as drawScaledX but with the remaining height
for(int i = 0; i < width / w; i++) {
for (int i = 0; i < width / w; i++) {
drawScaledY(xPos + i * w, yPos, yRest);
}
// remainder that doesn't fit total width
int remainder = width % w;
if(remainder > 0) {
if (remainder > 0) {
// drawModalRectWithCustomSizedTexture
GuiScreen.func_146110_a(xPos + width - remainder, yPos, x, y, remainder, yRest, texW, texH);
}
@@ -89,4 +89,4 @@ public class GuiElementScalable extends GuiElementDuex {
element.setTextureSize(texW, texH);
return element;
}
}
}
@@ -5,20 +5,20 @@ import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.input.Mouse;
/*
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
*
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
*
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
// a vertical slider!
@SideOnly(Side.CLIENT)
@@ -51,7 +51,13 @@ public class GuiSliderWidget {
private int clickY;
private boolean clickedBar; // if the bar has already been clicked and not released
public GuiSliderWidget(GuiElementDuex slider, GuiElementDuex sliderHighlighted, GuiElementDuex sliderDisabled, GuiElementDuex slideBarTop, GuiElementDuex slideBarBottom, GuiElementScalable slideBar) {
public GuiSliderWidget(
GuiElementDuex slider,
GuiElementDuex sliderHighlighted,
GuiElementDuex sliderDisabled,
GuiElementDuex slideBarTop,
GuiElementDuex slideBarBottom,
GuiElementScalable slideBar) {
this.slider = slider;
this.sliderHighlighted = sliderHighlighted;
this.sliderDisabled = sliderDisabled;
@@ -244,8 +250,7 @@ public class GuiSliderWidget {
}
}
// not scrolling yet but possibly inside the slider
else if (x >= 0 && y >= getSliderTop() &&
x - sliderOffset <= slider.w && y <= getSliderTop() + slider.h) {
else if (x >= 0 && y >= getSliderTop() && x - sliderOffset <= slider.w && y <= getSliderTop() + slider.h) {
isHighlighted = true;
if (mouseDown) {
isScrolling = true;
@@ -254,9 +259,7 @@ public class GuiSliderWidget {
}
}
// not on the slider but clicked on the bar
else if (mouseDown && !clickedBar &&
x >= 0 && y >= 0 &&
x <= slideBar.w && y <= height) {
else if (mouseDown && !clickedBar && x >= 0 && y >= 0 && x <= slideBar.w && y <= height) {
if (y < getSliderTop()) {
decrement();
} else {
@@ -278,4 +281,4 @@ public class GuiSliderWidget {
setSliderValue(currentValue + increment);
return currentValue;
}
}
}
@@ -4,6 +4,8 @@ import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import cpw.mods.fml.common.Optional;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -19,12 +21,8 @@ import tconstruct.smeltery.inventory.ActiveContainer;
import tconstruct.tools.inventory.PartCrafterChestContainer;
import tconstruct.tools.logic.PartBuilderLogic;
import java.util.Collections;
import java.util.List;
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
{
public class PartCrafterGui extends GuiContainer implements INEIGuiHandler {
PartBuilderLogic logic;
String title, otherTitle = "";
boolean drawChestPart;
@@ -52,8 +50,8 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
private int chestLeft = 0;
private int chestTop = 0;
public PartCrafterGui(InventoryPlayer inventoryplayer, PartBuilderLogic partlogic, World world, int x, int y, int z)
{
public PartCrafterGui(
InventoryPlayer inventoryplayer, PartBuilderLogic partlogic, World world, int x, int y, int z) {
super((ActiveContainer) partlogic.getGuiContainer(inventoryplayer, world, x, y, z));
logic = partlogic;
drawChestPart = inventorySlots instanceof PartCrafterChestContainer;
@@ -62,8 +60,7 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
}
@Override
public void initGui ()
{
public void initGui() {
super.initGui();
this.xSize = CRAFT_WIDTH;
@@ -78,120 +75,166 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
this.descLeft = this.craftingLeft + CRAFT_WIDTH;
this.descTop = this.craftingTop;
if (drawChestPart)
{
if (drawChestPart) {
this.xSize += CHEST_WIDTH - 6;
this.guiLeft -= CHEST_WIDTH - 6;
this.chestLeft = this.guiLeft;
this.chestTop = this.guiTop + 11;
}
this.craftingTextLeft = this.craftingLeft - this.guiLeft;
this.descTextLeft = this.descLeft - this.guiLeft;
}
@Override
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
if (drawChestPart)
{
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
if (drawChestPart) {
this.fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 14, 17, 4210752);
}
this.fontRendererObj.drawString(StatCollector.translateToLocal("crafters.PartBuilder"), craftingTextLeft + 6, 6, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), craftingTextLeft + 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("crafters.PartBuilder"), craftingTextLeft + 6, 6, 4210752);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"),
craftingTextLeft + 8,
this.ySize - 96 + 2,
4210752);
drawMaterialInformation();
}
void drawDefaultInformation ()
{
void drawDefaultInformation() {
title = "\u00A7n" + StatCollector.translateToLocal("gui.partcrafter2");
this.drawCenteredString(fontRendererObj, title, descTextLeft + DESC_WIDTH / 2, 8, 16777215);
fontRendererObj.drawSplitString(StatCollector.translateToLocal("gui.partcrafter3"), descTextLeft + 8, 24, 115, 16777215);
fontRendererObj.drawSplitString(
StatCollector.translateToLocal("gui.partcrafter3"), descTextLeft + 8, 24, 115, 16777215);
}
void drawMaterialInformation ()
{
void drawMaterialInformation() {
ItemStack top = logic.getStackInSlot(2);
//ItemStack topResult = logic.getStackInSlot(4);
// ItemStack topResult = logic.getStackInSlot(4);
ItemStack bottom = logic.getStackInSlot(3);
//ItemStack bottomResult = logic.getStackInSlot(6);
if (topMaterial != top)
{
// ItemStack bottomResult = logic.getStackInSlot(6);
if (topMaterial != top) {
topMaterial = top;
int topID = PatternBuilder.instance.getPartID(top);
if (topID != Short.MAX_VALUE)// && topResult != null)
if (topID != Short.MAX_VALUE) // && topResult != null)
{
topEnum = TConstructRegistry.getMaterial(topID);
hasTop = true;
title = "\u00A7n" + topEnum.localizedName();
}
else
hasTop = false;
} else hasTop = false;
}
if (bottomMaterial != bottom)
{
if (bottomMaterial != bottom) {
bottomMaterial = bottom;
int bottomID = PatternBuilder.instance.getPartID(bottom);
if (bottomID != Short.MAX_VALUE)// && bottomResult != null)
if (bottomID != Short.MAX_VALUE) // && bottomResult != null)
{
bottomEnum = TConstructRegistry.getMaterial(bottomID);
hasBottom = true;
otherTitle = "\u00A7n" + bottomEnum.localizedName();
}
else
hasBottom = false;
} else hasBottom = false;
}
int offset = 8;
if (hasTop)
{
if (hasTop) {
this.drawCenteredString(fontRendererObj, title, descTextLeft + DESC_WIDTH / 2, offset, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter4") + topEnum.durability(), descTextLeft + 8, offset + 16, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter5") + topEnum.handleDurability() + "x", descTextLeft + 8, offset + 27, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter6") + topEnum.toolSpeed() / 100f, descTextLeft + 8, offset + 38, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter7") + HarvestLevels.getHarvestLevelName(topEnum.harvestLevel()), descTextLeft + 8, offset + 49, 16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter4") + topEnum.durability(),
descTextLeft + 8,
offset + 16,
16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter5") + topEnum.handleDurability() + "x",
descTextLeft + 8,
offset + 27,
16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter6") + topEnum.toolSpeed() / 100f,
descTextLeft + 8,
offset + 38,
16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter7")
+ HarvestLevels.getHarvestLevelName(topEnum.harvestLevel()),
descTextLeft + 8,
offset + 49,
16777215);
int attack = topEnum.attack();
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
String heart = attack == 2
? StatCollector.translateToLocal("gui.partcrafter8")
: StatCollector.translateToLocal("gui.partcrafter9");
if (attack % 2 == 0)
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart, descTextLeft + 8, offset + 60, 0xffffff);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart,
descTextLeft + 8,
offset + 60,
0xffffff);
else
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart, descTextLeft + 8, offset + 60, 0xffffff);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart,
descTextLeft + 8,
offset + 60,
0xffffff);
}
offset = 90;
if (hasBottom)
{
if (hasBottom) {
this.drawCenteredString(fontRendererObj, otherTitle, descTextLeft + DESC_WIDTH / 2, offset, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter4") + bottomEnum.durability(), descTextLeft + 8, offset + 16, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter5") + bottomEnum.handleDurability() + "x", descTextLeft + 8, offset + 27, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter6") + bottomEnum.toolSpeed() / 100f, descTextLeft + 8, offset + 38, 16777215);
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter7") + HarvestLevels.getHarvestLevelName(bottomEnum.harvestLevel()), descTextLeft + 8, offset + 49, 16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter4") + bottomEnum.durability(),
descTextLeft + 8,
offset + 16,
16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter5") + bottomEnum.handleDurability() + "x",
descTextLeft + 8,
offset + 27,
16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter6") + bottomEnum.toolSpeed() / 100f,
descTextLeft + 8,
offset + 38,
16777215);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter7")
+ HarvestLevels.getHarvestLevelName(bottomEnum.harvestLevel()),
descTextLeft + 8,
offset + 49,
16777215);
int attack = bottomEnum.attack();
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
String heart = attack == 2
? StatCollector.translateToLocal("gui.partcrafter8")
: StatCollector.translateToLocal("gui.partcrafter9");
if (attack % 2 == 0)
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart, descTextLeft + 8, offset + 60, 0xffffff);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart,
descTextLeft + 8,
offset + 60,
0xffffff);
else
this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart, descTextLeft + 8, offset + 60, 0xffffff);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart,
descTextLeft + 8,
offset + 60,
0xffffff);
}
if (!hasTop && !hasBottom)
drawDefaultInformation();
if (!hasTop && !hasBottom) drawDefaultInformation();
}
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/toolparts.png");
private static final ResourceLocation minichest = new ResourceLocation("tinker", "textures/gui/patternchestmini.png");
private static final ResourceLocation minichest =
new ResourceLocation("tinker", "textures/gui/patternchestmini.png");
private static final ResourceLocation description = new ResourceLocation("tinker", "textures/gui/description.png");
@Override
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
{
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
// Draw the background
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(background);
@@ -199,26 +242,21 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
// Draw Slots
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 26, 0, 166, 98, 36);
if (!logic.isStackInSlot(0))
{
if (!logic.isStackInSlot(0)) {
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 26, 176, 0, 18, 18);
}
if (!logic.isStackInSlot(2))
{
if (!logic.isStackInSlot(2)) {
this.drawTexturedModalRect(craftingLeft + 57, craftingTop + 26, 176, 18, 18, 18);
}
if (!logic.isStackInSlot(1))
{
if (!logic.isStackInSlot(1)) {
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 44, 176, 0, 18, 18);
}
if (!logic.isStackInSlot(3))
{
if (!logic.isStackInSlot(3)) {
this.drawTexturedModalRect(craftingLeft + 57, craftingTop + 44, 176, 36, 18, 18);
}
// Draw chest
if (drawChestPart)
{
if (drawChestPart) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(minichest);
this.drawTexturedModalRect(chestLeft, chestTop, 0, 0, CHEST_WIDTH, CHEST_HEIGHT);
@@ -231,19 +269,14 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
}
@Override
public VisiblityData modifyVisiblity (GuiContainer gui, VisiblityData currentVisibility)
{
if (width - xSize < 107)
{
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
if (width - xSize < 107) {
currentVisibility.showWidgets = false;
}
else
{
} else {
currentVisibility.showWidgets = true;
}
if (guiLeft < 58)
{
if (guiLeft < 58) {
currentVisibility.showStateButtons = false;
}
@@ -251,33 +284,26 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler
}
@Override
public Iterable<Integer> getItemSpawnSlots (GuiContainer gui, ItemStack item)
{
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) {
return null;
}
@Override
public List<TaggedInventoryArea> getInventoryAreas (GuiContainer gui)
{
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
return Collections.emptyList();
}
@Override
public boolean handleDragNDrop (GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button)
{
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) {
return false;
}
@Override
public boolean hideItemPanelSlot (GuiContainer gui, int x, int y, int w, int h)
{
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize)
return false;
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize) return false;
if (x - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + DESC_WIDTH)
return false;
if (x - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + DESC_WIDTH) return false;
return true;
}
}
}
@@ -7,12 +7,11 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import tconstruct.tools.logic.PatternChestLogic;
public class PatternChestGui extends GuiContainer
{
public class PatternChestGui extends GuiContainer {
public PatternChestLogic logic;
public PatternChestGui(InventoryPlayer inventoryplayer, PatternChestLogic holder, World world, int x, int y, int z)
{
public PatternChestGui(
InventoryPlayer inventoryplayer, PatternChestLogic holder, World world, int x, int y, int z) {
super(holder.getGuiContainer(inventoryplayer, world, x, y, z));
logic = holder;
xSize = 194;
@@ -20,17 +19,16 @@ public class PatternChestGui extends GuiContainer
}
@Override
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 60, 6, 0x404040);
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040);
fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040);
}
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternchest.png");
@Override
protected void drawGuiContainerBackgroundLayer (float f, int i, int j)
{
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(background);
int cornerX = (width - xSize) / 2;
@@ -4,6 +4,8 @@ import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import cpw.mods.fml.common.Optional;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -18,56 +20,48 @@ import tconstruct.tools.inventory.PatternShaperContainer;
import tconstruct.tools.logic.StencilTableLogic;
import tconstruct.util.network.PatternTablePacket;
import java.util.Collections;
import java.util.List;
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
public class StencilTableGui extends GuiContainer implements INEIGuiHandler
{
int[] buttonsLeftRect = new int[]{ Integer.MAX_VALUE, Integer.MIN_VALUE };
int[] buttonsRightRect = new int[]{ Integer.MIN_VALUE, Integer.MIN_VALUE };
public class StencilTableGui extends GuiContainer implements INEIGuiHandler {
int[] buttonsLeftRect = new int[] {Integer.MAX_VALUE, Integer.MIN_VALUE};
int[] buttonsRightRect = new int[] {Integer.MIN_VALUE, Integer.MIN_VALUE};
StencilTableLogic logic;
int activeButton;
public StencilTableGui(InventoryPlayer inventoryplayer, StencilTableLogic shaper, World world, int x, int y, int z)
{
public StencilTableGui(
InventoryPlayer inventoryplayer, StencilTableLogic shaper, World world, int x, int y, int z) {
super(new PatternShaperContainer(inventoryplayer, shaper));
logic = shaper;
activeButton = 0;
}
@Override
public void onGuiClosed ()
{
public void onGuiClosed() {
super.onGuiClosed();
}
@Override
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRendererObj.drawString(StatCollector.translateToLocal("crafters.PatternShaper"), 50, 6, 0x404040);
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternshaper.png");
@Override
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
{
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(background);
int cornerX = (this.width - this.xSize) / 2;
int cornerY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
if (!logic.isStackInSlot(0))
{
if (!logic.isStackInSlot(0)) {
this.drawTexturedModalRect(cornerX + 47, cornerY + 34, 176, 0, 18, 18);
}
}
@Override
public void initGui ()
{
public void initGui() {
super.initGui();
int bpr = 4; // buttons per row!
@@ -75,16 +69,22 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
int cornerY = this.guiTop + 2;
this.buttonList.clear();
this.buttonsLeftRect = new int[]{ Integer.MAX_VALUE, Integer.MIN_VALUE };
this.buttonsRightRect = new int[]{ Integer.MIN_VALUE, Integer.MIN_VALUE };
this.buttonsLeftRect = new int[] {Integer.MAX_VALUE, Integer.MIN_VALUE};
this.buttonsRightRect = new int[] {Integer.MIN_VALUE, Integer.MIN_VALUE};
int id = 0;
for (int iter = 0; iter < TConstructClientRegistry.stencilButtons.size(); iter++)
{
for (int iter = 0; iter < TConstructClientRegistry.stencilButtons.size(); iter++) {
StencilGuiElement element = TConstructClientRegistry.stencilButtons.get(iter);
if (element.stencilIndex == -1)
continue;
GuiButtonStencil button = new GuiButtonStencil(id++, cornerX + 22 * (iter % bpr), cornerY + 22 * (iter / bpr), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
if (element.stencilIndex == -1) continue;
GuiButtonStencil button = new GuiButtonStencil(
id++,
cornerX + 22 * (iter % bpr),
cornerY + 22 * (iter / bpr),
element.buttonIconX,
element.buttonIconY,
element.domain,
element.texture,
element);
this.buttonList.add(button);
this.buttonsLeftRect[0] = Math.min(button.xPosition, this.buttonsLeftRect[0]);
this.buttonsLeftRect[1] = Math.max(button.yPosition + button.height, this.buttonsLeftRect[1]);
@@ -93,12 +93,18 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
// secondary buttons, yay!
// these are to use for other mods :I
cornerX = this.guiLeft + this.xSize + 4;
for (int iter = 0; iter < TConstructClientRegistry.stencilButtons2.size(); iter++)
{
for (int iter = 0; iter < TConstructClientRegistry.stencilButtons2.size(); iter++) {
StencilGuiElement element = TConstructClientRegistry.stencilButtons2.get(iter);
if (element.stencilIndex == -1)
continue;
GuiButtonStencil button = new GuiButtonStencil(id++, cornerX + 22 * (iter % bpr), cornerY + 22 * (iter / bpr), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
if (element.stencilIndex == -1) continue;
GuiButtonStencil button = new GuiButtonStencil(
id++,
cornerX + 22 * (iter % bpr),
cornerY + 22 * (iter / bpr),
element.buttonIconX,
element.buttonIconY,
element.domain,
element.texture,
element);
this.buttonList.add(button);
this.buttonsRightRect[0] = Math.max(button.xPosition + button.width, this.buttonsRightRect[0]);
this.buttonsRightRect[1] = Math.max(button.yPosition + button.height, this.buttonsRightRect[1]);
@@ -106,29 +112,24 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
// get the correct setting :I
ItemStack stack;
if (logic.getStackInSlot(1) != null)
{
if (logic.getStackInSlot(1) != null) {
activeButton = StencilBuilder.getId(logic.getStackInSlot(1));
setActiveButton(activeButton);
stack = StencilBuilder.getStencil(((GuiButtonStencil) this.buttonList.get(activeButton)).element.stencilIndex);
}
else
stack = null;
stack = StencilBuilder.getStencil(
((GuiButtonStencil) this.buttonList.get(activeButton)).element.stencilIndex);
} else stack = null;
logic.setSelectedPattern(stack);
updateServer(stack);
}
@Override
protected void actionPerformed (GuiButton button)
{
protected void actionPerformed(GuiButton button) {
ItemStack pattern = logic.getStackInSlot(0);
if (pattern != null && StencilBuilder.isBlank(pattern))
{
if (pattern != null && StencilBuilder.isBlank(pattern)) {
int id = ((GuiButtonStencil) button).element.stencilIndex;
ItemStack stack = StencilBuilder.getStencil(id);
if (stack != null)
{
if (stack != null) {
logic.setSelectedPattern(stack);
updateServer(stack);
}
@@ -137,8 +138,7 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
setActiveButton(button.id);
}
private void setActiveButton (int id)
{
private void setActiveButton(int id) {
// deactivate old button
((GuiButton) this.buttonList.get(activeButton)).enabled = true;
// update active button
@@ -147,8 +147,7 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
((GuiButton) this.buttonList.get(activeButton)).enabled = false;
}
void updateServer (ItemStack stack)
{
void updateServer(ItemStack stack) {
TConstruct.packetPipeline.sendToServer(new PatternTablePacket(logic.xCoord, logic.yCoord, logic.zCoord, stack));
}
@@ -173,11 +172,13 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
}
@Override
public boolean hideItemPanelSlot(GuiContainer guiContainer, int x, int y, int w, int h)
{
public boolean hideItemPanelSlot(GuiContainer guiContainer, int x, int y, int w, int h) {
// is it in the horizontal column of the right buttons?
if (x > this.guiLeft + this.xSize && x < this.buttonsRightRect[0] && y + h > this.guiTop && y < this.buttonsRightRect[1]) {
if (x > this.guiLeft + this.xSize
&& x < this.buttonsRightRect[0]
&& y + h > this.guiTop
&& y < this.buttonsRightRect[1]) {
return true;
}
@@ -188,4 +189,4 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler
return false;
}
}
}
@@ -9,45 +9,64 @@ import tconstruct.library.client.*;
import tconstruct.tools.logic.ToolForgeLogic;
@SideOnly(Side.CLIENT)
public class ToolForgeGui extends ToolStationGui
{
public class ToolForgeGui extends ToolStationGui {
int selectedButton;
public ToolForgeGui(InventoryPlayer inventoryplayer, ToolForgeLogic stationlogic, World world, int x, int y, int z)
{
public ToolForgeGui(
InventoryPlayer inventoryplayer, ToolForgeLogic stationlogic, World world, int x, int y, int z) {
super(inventoryplayer, stationlogic, world, x, y, z);
}
@Override
public void initGui ()
{
public void initGui() {
super.initGui();
this.buttonList.clear();
ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0);
GuiButtonTool repairButton = new GuiButtonTool(0, this.guiLeft, this.guiTop, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair
GuiButtonTool repairButton = new GuiButtonTool(
0,
this.guiLeft,
this.guiTop,
repair.buttonIconX,
repair.buttonIconY,
repair.domain,
repair.texture,
repair); // Repair
repairButton.enabled = false;
this.buttonList.add(repairButton);
int offset = TConstructClientRegistry.tierTwoButtons.size();
for (int iter = 0; iter < TConstructClientRegistry.tierTwoButtons.size(); iter++)
{
for (int iter = 0; iter < TConstructClientRegistry.tierTwoButtons.size(); iter++) {
ToolGuiElement element = TConstructClientRegistry.tierTwoButtons.get(iter);
GuiButtonTool button = new GuiButtonTool(iter + 1, this.guiLeft + 22 * ((iter + 1) % 5), this.guiTop + 22 * ((iter + 1) / 5), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
GuiButtonTool button = new GuiButtonTool(
iter + 1,
this.guiLeft + 22 * ((iter + 1) % 5),
this.guiTop + 22 * ((iter + 1) / 5),
element.buttonIconX,
element.buttonIconY,
element.domain,
element.texture,
element);
this.buttonList.add(button);
}
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++)
{
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++) {
ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter);
GuiButtonTool button = new GuiButtonTool(iter + offset, this.guiLeft + 22 * ((iter + offset) % 5), this.guiTop + 22 * ((iter + offset) / 5), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
GuiButtonTool button = new GuiButtonTool(
iter + offset,
this.guiLeft + 22 * ((iter + offset) % 5),
this.guiTop + 22 * ((iter + offset) / 5),
element.buttonIconX,
element.buttonIconY,
element.domain,
element.texture,
element);
this.buttonList.add(button);
}
}
@Override
protected void actionPerformed (GuiButton button)
{
protected void actionPerformed(GuiButton button) {
GuiButtonTool b = (GuiButtonTool) button;
((GuiButton) this.buttonList.get(selectedButton)).enabled = true;
selectedButton = button.id;
@@ -58,73 +77,70 @@ public class ToolForgeGui extends ToolStationGui
iconY = b.element.iconsY;
title = "\u00A7n" + b.element.title;
body = StatCollector.translateToLocal(b.element.body);
if(body != null) {
if (body != null) {
int i;
// for some really weird reason replaceAll doesn't find "\\n", but indexOf does. We have to replace manually.
while((i = body.indexOf("\\n")) >= 0)
{
body = body.substring(0, i) + '\n' + body.substring(i+2);
// for some really weird reason replaceAll doesn't find "\\n", but indexOf does. We have to replace
// manually.
while ((i = body.indexOf("\\n")) >= 0) {
body = body.substring(0, i) + '\n' + body.substring(i + 2);
}
}
}
@Override
void resetGui ()
{
void resetGui() {
this.text.setText("");
selectedButton = 0;
setSlotType(0);
iconX = new int[] { 0, 1, 2, 13 };
iconY = new int[] { 13, 13, 13, 13 };
iconX = new int[] {0, 1, 2, 13};
iconY = new int[] {13, 13, 13, 13};
title = "\u00A7n" + StatCollector.translateToLocal("gui.toolforge1");
body = StatCollector.translateToLocal("gui.toolforge2");
}
@Override
void setSlotType (int type)
{
switch (type)
{
case 0:
slotX = new int[] { 56, 38, 38, 14 }; // Repair
slotY = new int[] { 37, 28, 46, 37 };
break;
case 1:
slotX = new int[] { 56, 56, 56, 14 }; // Three parts
slotY = new int[] { 19, 55, 37, 37 };
break;
case 2:
slotX = new int[] { 56, 56, 14, 14 }; // Two parts
slotY = new int[] { 28, 46, 28, 46 };
break;
case 3:
slotX = new int[] { 38, 47, 56, 14 }; // Double head
slotY = new int[] { 28, 46, 28, 37 };
break;
case 4:
slotX = new int[] { 47, 38, 56, 47 }; // Four parts
slotY = new int[] { 19, 37, 37, 55 };
break;
case 5:
slotX = new int[] { 38, 47, 56, 47 }; // Four parts, double head
slotY = new int[] { 19, 55, 19, 37 };
break;
case 6:
slotX = new int[] { 38, 38, 20, 56 }; // Double head
slotY = new int[] { 28, 46, 28, 28 };
break;
case 7:
slotX = new int[] { 56, 56, 56, 14 }; // Three parts reverse
slotY = new int[] { 19, 37, 55, 37 };
break;
case 8:
slotX = new int[] { 20, 38, 56, 38 }; // Double head middle
slotY = new int[] { 28, 46, 28, 28 };
break;
case 9:
slotX = new int[] { 38, 56, 47, 47 }; // Four parts, crossbow.
slotY = new int[] { 37, 37, 55, 19 };
break;
void setSlotType(int type) {
switch (type) {
case 0:
slotX = new int[] {56, 38, 38, 14}; // Repair
slotY = new int[] {37, 28, 46, 37};
break;
case 1:
slotX = new int[] {56, 56, 56, 14}; // Three parts
slotY = new int[] {19, 55, 37, 37};
break;
case 2:
slotX = new int[] {56, 56, 14, 14}; // Two parts
slotY = new int[] {28, 46, 28, 46};
break;
case 3:
slotX = new int[] {38, 47, 56, 14}; // Double head
slotY = new int[] {28, 46, 28, 37};
break;
case 4:
slotX = new int[] {47, 38, 56, 47}; // Four parts
slotY = new int[] {19, 37, 37, 55};
break;
case 5:
slotX = new int[] {38, 47, 56, 47}; // Four parts, double head
slotY = new int[] {19, 55, 19, 37};
break;
case 6:
slotX = new int[] {38, 38, 20, 56}; // Double head
slotY = new int[] {28, 46, 28, 28};
break;
case 7:
slotX = new int[] {56, 56, 56, 14}; // Three parts reverse
slotY = new int[] {19, 37, 55, 37};
break;
case 8:
slotX = new int[] {20, 38, 56, 38}; // Double head middle
slotY = new int[] {28, 46, 28, 28};
break;
case 9:
slotX = new int[] {38, 56, 47, 47}; // Four parts, crossbow.
slotY = new int[] {37, 37, 55, 19};
break;
}
toolSlots.resetSlots(slotX, slotY);
}
@@ -6,6 +6,8 @@ import codechicken.nei.api.TaggedInventoryArea;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -24,13 +26,9 @@ import tconstruct.tools.inventory.ToolStationContainer;
import tconstruct.tools.logic.ToolStationLogic;
import tconstruct.util.network.ToolStationPacket;
import java.util.Collections;
import java.util.List;
@SideOnly(Side.CLIENT)
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
public class ToolStationGui extends GuiContainer implements INEIGuiHandler
{
public class ToolStationGui extends GuiContainer implements INEIGuiHandler {
public ToolStationLogic logic;
public ToolStationContainer toolSlots;
public GuiTextField text;
@@ -40,8 +38,8 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
public boolean active;
public String title, body = "";
public ToolStationGui(InventoryPlayer inventoryplayer, ToolStationLogic stationlogic, World world, int x, int y, int z)
{
public ToolStationGui(
InventoryPlayer inventoryplayer, ToolStationLogic stationlogic, World world, int x, int y, int z) {
super((ActiveContainer) stationlogic.getGuiContainer(inventoryplayer, world, x, y, z));
this.logic = stationlogic;
toolSlots = (ToolStationContainer) inventorySlots;
@@ -58,11 +56,9 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
}
@Override
protected void mouseClicked (int mouseX, int mouseY, int mouseButton)
{
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
if (mouseButton == 0)
{
if (mouseButton == 0) {
int gLeft = this.guiLeft + 68 + 110;
int gTop = this.guiTop + 6;
int gwidth = 102;
@@ -71,41 +67,53 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
}
}
void resetGui ()
{
void resetGui() {
this.text.setText("");
guiType = 0;
setSlotType(0);
iconX = new int[] { 0, 1, 2 };
iconY = new int[] { 13, 13, 13 };
iconX = new int[] {0, 1, 2};
iconY = new int[] {13, 13, 13};
title = "\u00A7n" + StatCollector.translateToLocal("gui.toolforge1");
body = StatCollector.translateToLocal("gui.toolforge2");
}
@Override
public void initGui ()
{
public void initGui() {
super.initGui();
this.xSize = 176 + 110;
this.guiLeft = (this.width - 176) / 2 - 110;
this.buttonList.clear();
ToolGuiElement repair = TConstructClientRegistry.toolButtons.get(0);
GuiButtonTool repairButton = new GuiButtonTool(0, this.guiLeft, this.guiTop, repair.buttonIconX, repair.buttonIconY, repair.domain, repair.texture, repair); // Repair
GuiButtonTool repairButton = new GuiButtonTool(
0,
this.guiLeft,
this.guiTop,
repair.buttonIconX,
repair.buttonIconY,
repair.domain,
repair.texture,
repair); // Repair
repairButton.enabled = false;
this.buttonList.add(repairButton);
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++)
{
for (int iter = 1; iter < TConstructClientRegistry.toolButtons.size(); iter++) {
ToolGuiElement element = TConstructClientRegistry.toolButtons.get(iter);
GuiButtonTool button = new GuiButtonTool(iter, this.guiLeft + 22 * (iter % 5), this.guiTop + 22 * (iter / 5), element.buttonIconX, element.buttonIconY, element.domain, element.texture, element);
GuiButtonTool button = new GuiButtonTool(
iter,
this.guiLeft + 22 * (iter % 5),
this.guiTop + 22 * (iter / 5),
element.buttonIconX,
element.buttonIconY,
element.domain,
element.texture,
element);
this.buttonList.add(button);
}
}
@Override
protected void actionPerformed (GuiButton button)
{
protected void actionPerformed(GuiButton button) {
((GuiButton) this.buttonList.get(guiType)).enabled = true;
guiType = button.id;
button.enabled = false;
@@ -116,47 +124,44 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
iconY = element.iconsY;
title = "\u00A7n" + element.title;
body = StatCollector.translateToLocal(element.body);
if(body != null) {
if (body != null) {
int i;
// for some really weird reason replaceAll doesn't find "\\n", but indexOf does. We have to replace manually.
while((i = body.indexOf("\\n")) >= 0)
{
body = body.substring(0, i) + '\n' + body.substring(i+2);
// for some really weird reason replaceAll doesn't find "\\n", but indexOf does. We have to replace
// manually.
while ((i = body.indexOf("\\n")) >= 0) {
body = body.substring(0, i) + '\n' + body.substring(i + 2);
}
}
}
void setSlotType (int type)
{
switch (type)
{
case 0:
slotX = new int[] { 56, 38, 38 }; // Repair
slotY = new int[] { 37, 28, 46 };
break;
case 1:
slotX = new int[] { 56, 56, 56 }; // Three parts
slotY = new int[] { 19, 55, 37 };
break;
case 2:
slotX = new int[] { 56, 56, 14 }; // Two parts
slotY = new int[] { 28, 46, 37 };
break;
case 3:
slotX = new int[] { 38, 47, 56 }; // Double head
slotY = new int[] { 28, 46, 28 };
break;
case 7:
slotX = new int[] { 56, 56, 56 }; // Three parts reverse
slotY = new int[] { 19, 37, 55 };
break;
void setSlotType(int type) {
switch (type) {
case 0:
slotX = new int[] {56, 38, 38}; // Repair
slotY = new int[] {37, 28, 46};
break;
case 1:
slotX = new int[] {56, 56, 56}; // Three parts
slotY = new int[] {19, 55, 37};
break;
case 2:
slotX = new int[] {56, 56, 14}; // Two parts
slotY = new int[] {28, 46, 37};
break;
case 3:
slotX = new int[] {38, 47, 56}; // Double head
slotY = new int[] {28, 46, 28};
break;
case 7:
slotX = new int[] {56, 56, 56}; // Three parts reverse
slotY = new int[] {19, 37, 55};
break;
}
toolSlots.resetSlots(slotX, slotY);
}
@Override
public void updateScreen ()
{
public void updateScreen() {
super.updateScreen();
this.text.updateCursorCounter();
}
@@ -166,20 +171,17 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
* the items)
*/
@Override
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
this.fontRendererObj.drawString(StatCollector.translateToLocal(logic.getInvName()), 116, 8, 0x000000);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 118, this.ySize - 96 + 2, 0x000000);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"), 118, this.ySize - 96 + 2, 0x000000);
this.fontRendererObj.drawString(toolName + "_", 180, 8, 0xffffff);
if (logic.isStackInSlot(0))
ToolStationGuiHelper.drawToolStats(logic.getStackInSlot(0), 294, 0);
else
drawToolInformation();
if (logic.isStackInSlot(0)) ToolStationGuiHelper.drawToolStats(logic.getStackInSlot(0), 294, 0);
else drawToolInformation();
}
protected void drawToolInformation ()
{
protected void drawToolInformation() {
this.drawCenteredString(fontRendererObj, title, 349, 8, 0xffffff);
fontRendererObj.drawSplitString(body, 294, 24, 115, 0xffffff);
}
@@ -193,16 +195,14 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
* items)
*/
@Override
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
{
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
// Draw the background
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(background);
final int cornerX = this.guiLeft + 110;
this.drawTexturedModalRect(cornerX, this.guiTop, 0, 0, 176, this.ySize);
if (active)
{
if (active) {
this.drawTexturedModalRect(cornerX + 62, this.guiTop, 0, this.ySize, 112, 22);
}
@@ -210,12 +210,11 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
this.mc.getTextureManager().bindTexture(icons);
// Draw the slots
for (int i = 0; i < slotX.length; i++)
{
for (int i = 0; i < slotX.length; i++) {
this.drawTexturedModalRect(cornerX + slotX[i], this.guiTop + slotY[i], 144, 216, 18, 18);
if (!logic.isStackInSlot(i + 1))
{
this.drawTexturedModalRect(cornerX + slotX[i], this.guiTop + slotY[i], 18 * iconX[i], 18 * iconY[i], 18, 18);
if (!logic.isStackInSlot(i + 1)) {
this.drawTexturedModalRect(
cornerX + slotX[i], this.guiTop + slotY[i], 18 * iconX[i], 18 * iconY[i], 18, 18);
}
}
@@ -223,21 +222,16 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(description);
this.drawTexturedModalRect(cornerX + 176, this.guiTop, 0, 0, 126, this.ySize + 30);
}
@Override
protected void keyTyped (char par1, int keyCode)
{
if (keyCode == 1 || (!active && keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()))
{
protected void keyTyped(char par1, int keyCode) {
if (keyCode == 1 || (!active && keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())) {
logic.setToolname("");
updateServer("");
Keyboard.enableRepeatEvents(false);
this.mc.thePlayer.closeScreen();
}
else if (active)
{
} else if (active) {
text.textboxKeyTyped(par1, keyCode);
toolName = text.getText().trim();
logic.setToolname(toolName);
@@ -245,8 +239,7 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
}
}
void updateServer (String name)
{
void updateServer(String name) {
/*
* ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
* DataOutputStream outputStream = new DataOutputStream(bos); try {
@@ -256,11 +249,11 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
* outputStream.writeInt(logic.yCoord);
* outputStream.writeInt(logic.zCoord); outputStream.writeUTF(name); }
* catch (Exception ex) { ex.printStackTrace(); }
*
*
* Packet250CustomPayload packet = new Packet250CustomPayload();
* packet.channel = "TConstruct"; packet.data = bos.toByteArray();
* packet.length = bos.size();
*
*
* PacketDispatcher.sendPacketToServer(packet);
*/
@@ -274,19 +267,14 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
*/
@Override
public VisiblityData modifyVisiblity (GuiContainer gui, VisiblityData currentVisibility)
{
if (width - xSize < 107)
{
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
if (width - xSize < 107) {
currentVisibility.showWidgets = false;
}
else
{
} else {
currentVisibility.showWidgets = true;
}
if (guiLeft < 58)
{
if (guiLeft < 58) {
currentVisibility.showStateButtons = false;
}
@@ -294,31 +282,25 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler
}
@Override
public Iterable<Integer> getItemSpawnSlots (GuiContainer gui, ItemStack item)
{
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) {
return null;
}
@Override
public List<TaggedInventoryArea> getInventoryAreas (GuiContainer gui)
{
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
return Collections.emptyList();
}
@Override
public boolean handleDragNDrop (GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button)
{
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) {
return false;
}
@Override
public boolean hideItemPanelSlot (GuiContainer gui, int x, int y, int w, int h)
{
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize)
return false;
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize) return false;
if (x - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + 126)
return false;
if (x - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + 126) return false;
return true;
}
@@ -1,5 +1,9 @@
package tconstruct.tools.gui;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.Item;
@@ -11,21 +15,12 @@ import tconstruct.library.accessory.AccessoryCore;
import tconstruct.library.armor.ArmorCore;
import tconstruct.library.modifier.IModifyable;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.DualHarvestTool;
import tconstruct.library.tools.HarvestTool;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.util.HarvestLevels;
import tconstruct.library.weaponry.AmmoWeapon;
import tconstruct.library.weaponry.IAmmo;
import tconstruct.library.weaponry.ProjectileWeapon;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
public final class ToolStationGuiHelper {
// non-instantiable
private ToolStationGuiHelper() {}
@@ -33,23 +28,21 @@ public final class ToolStationGuiHelper {
private static final FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRenderer;
private static int xPos, yPos;
private static final DecimalFormat df = new DecimalFormat("#.##");
private static final DecimalFormat df = new DecimalFormat("#.##");
private static void newline()
{
private static void newline() {
yPos += 10;
}
private static void write(String s)
{
private static void write(String s) {
fontRendererObj.drawString(s, xPos, yPos, 0xffffffff);
newline();
}
public static void drawToolStats (ItemStack stack, int x, int y)
{
String name = stack.getItem() instanceof ToolCore ? ((ToolCore) stack.getItem()).getLocalizedToolName() : stack.getDisplayName();
public static void drawToolStats(ItemStack stack, int x, int y) {
String name = stack.getItem() instanceof ToolCore
? ((ToolCore) stack.getItem()).getLocalizedToolName()
: stack.getDisplayName();
Item item = stack.getItem();
NBTTagCompound tags = stack.getTagCompound();
Collection<String> categories = new LinkedList<String>();
@@ -59,7 +52,7 @@ public final class ToolStationGuiHelper {
yPos = y + 8;
// get the correct tags
if(item instanceof IModifyable) {
if (item instanceof IModifyable) {
IModifyable modifyable = (IModifyable) item;
tags = tags.getCompoundTag(modifyable.getBaseTagName());
categories = Arrays.asList(modifyable.getTraits());
@@ -70,24 +63,19 @@ public final class ToolStationGuiHelper {
newline();
// does it have ammo instead of durability?
if(item instanceof IAmmo)
drawAmmo((IAmmo) item, stack);
if (item instanceof IAmmo) drawAmmo((IAmmo) item, stack);
// regular durability?
else if(item instanceof ToolCore || item instanceof ArmorCore)
drawDurability(tags);
else if (item instanceof ToolCore || item instanceof ArmorCore) drawDurability(tags);
// tools
if(item instanceof ToolCore) {
if (item instanceof ToolCore) {
ToolCore tool = (ToolCore) item;
// DualHarvest tool?
if (categories.contains("dualharvest"))
drawDualHarvestStats(tool, tags);
if (categories.contains("dualharvest")) drawDualHarvestStats(tool, tags);
// or regular Harvest tool?
else if (categories.contains("harvest"))
drawHarvestStats(tool, tags);
else if (categories.contains("harvest")) drawHarvestStats(tool, tags);
// weapon?
if (categories.contains("weapon"))
drawWeaponStats(tool, tags);
if (categories.contains("weapon")) drawWeaponStats(tool, tags);
// throwing weapon?
if (categories.contains("thrown") && tool instanceof AmmoWeapon)
drawThrowingWeaponStats((AmmoWeapon) tool, tags);
@@ -95,18 +83,15 @@ public final class ToolStationGuiHelper {
if (categories.contains("bow") && tool instanceof ProjectileWeapon)
drawProjectileWeaponStats((ProjectileWeapon) tool, tags, stack);
// projectile?
if (categories.contains("projectile"))
drawProjectileStats(tags);
if (categories.contains("projectile")) drawProjectileStats(tags);
}
// armor
if(item instanceof ArmorCore)
{
if (item instanceof ArmorCore) {
ArmorCore armor = (ArmorCore) item;
drawArmorStats(armor, tags, stack);
}
// Accessory
if(item instanceof AccessoryCore)
{
if (item instanceof AccessoryCore) {
AccessoryCore accessory = (AccessoryCore) item;
drawAccessoryStats(accessory, tags);
}
@@ -123,31 +108,25 @@ public final class ToolStationGuiHelper {
final int availableDurability = maxDur - durability;
// big durabilities have to split to 2 lines
if (maxDur >= 10000)
{
if (maxDur >= 10000) {
write(StatCollector.translateToLocal("gui.toolstation1"));
write("- " + availableDurability + "/" + maxDur);
}
else
{
} else {
write(StatCollector.translateToLocal("gui.toolstation2") + availableDurability + "/" + maxDur);
}
}
private static void drawAmmo(IAmmo ammoItem, ItemStack stack)
{
private static void drawAmmo(IAmmo ammoItem, ItemStack stack) {
final int max = ammoItem.getMaxAmmo(stack);
final int current = ammoItem.getAmmoCount(stack);
write(StatCollector.translateToLocal("gui.toolstation21") + current + "/" + max);
write(StatCollector.translateToLocal("gui.toolstation21") + current + "/" + max);
}
private static void drawModifiers(NBTTagCompound tags)
{
private static void drawModifiers(NBTTagCompound tags) {
int modifiers = tags.getInteger("Modifiers");
// remaining modifiers
if (modifiers != 0)
write(StatCollector.translateToLocal("gui.toolstation18") + modifiers);
if (modifiers != 0) write(StatCollector.translateToLocal("gui.toolstation18") + modifiers);
// Modifier-header (if we have modifiers)
if (tags.hasKey("ModifierTip1")) {
@@ -160,14 +139,15 @@ public final class ToolStationGuiHelper {
String locString = "modifier.toolstation." + tipName;
// strip out the '(X of Y)' in some for the localization strings.. sigh
int bracket = tipName.indexOf("(");
if(bracket > 0)
locString = "modifier.toolstation." + tipName.substring(0, bracket);
if (bracket > 0) locString = "modifier.toolstation." + tipName.substring(0, bracket);
locString = EnumChatFormatting.getTextWithoutFormattingCodes(locString.replace(" ", ""));
if(StatCollector.canTranslate(locString)) {
tipName = tipName.replace(EnumChatFormatting.getTextWithoutFormattingCodes(tipName), StatCollector.translateToLocal(locString));
if (StatCollector.canTranslate(locString)) {
tipName = tipName.replace(
EnumChatFormatting.getTextWithoutFormattingCodes(tipName),
StatCollector.translateToLocal(locString));
// re-add the X/Y
if(bracket > 0)
if (bracket > 0)
tipName += " " + tags.getString(tooltip + tipNum).substring(bracket);
}
write("- " + tipName);
@@ -176,40 +156,41 @@ public final class ToolStationGuiHelper {
}
}
private static void drawHarvestStats(ToolCore tool, NBTTagCompound tags)
{
private static void drawHarvestStats(ToolCore tool, NBTTagCompound tags) {
float mineSpeed = AbilityHelper.calcToolSpeed(tool, tags);
float stoneboundSpeed = AbilityHelper.calcStoneboundBonus(tool, tags);
write(StatCollector.translateToLocal("gui.toolstation14") + df.format(mineSpeed));
if(stoneboundSpeed != 0)
{
String bloss = stoneboundSpeed > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
if (stoneboundSpeed != 0) {
String bloss = stoneboundSpeed > 0
? StatCollector.translateToLocal("gui.toolstation4")
: StatCollector.translateToLocal("gui.toolstation5");
write(bloss + df.format(stoneboundSpeed));
}
write(StatCollector.translateToLocal("gui.toolstation15") + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")));
write(StatCollector.translateToLocal("gui.toolstation15")
+ HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")));
}
private static void drawDualHarvestStats(ToolCore tool, NBTTagCompound tags)
{
private static void drawDualHarvestStats(ToolCore tool, NBTTagCompound tags) {
float mineSpeed = AbilityHelper.calcDualToolSpeed(tool, tags, false);
float mineSpeed2 = AbilityHelper.calcDualToolSpeed(tool, tags, true);
float stoneboundSpeed = AbilityHelper.calcStoneboundBonus(tool, tags);
write(StatCollector.translateToLocal("gui.toolstation12"));
write("- " + df.format(mineSpeed) + ", " + df.format(mineSpeed2));
if (stoneboundSpeed != 0)
{
String bloss = stoneboundSpeed > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
if (stoneboundSpeed != 0) {
String bloss = stoneboundSpeed > 0
? StatCollector.translateToLocal("gui.toolstation4")
: StatCollector.translateToLocal("gui.toolstation5");
write(bloss + df.format(stoneboundSpeed));
}
write(StatCollector.translateToLocal("gui.toolstation13"));
write("- " + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")) + ", " + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel2")));
write("- " + HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel")) + ", "
+ HarvestLevels.getHarvestLevelName(tags.getInteger("HarvestLevel2")));
}
private static void drawWeaponStats(ToolCore tool, NBTTagCompound tags)
{
private static void drawWeaponStats(ToolCore tool, NBTTagCompound tags) {
// DAMAGE
int attack = (tags.getInteger("Attack"));
@@ -218,19 +199,21 @@ public final class ToolStationGuiHelper {
attack += stoneboundDamage;
attack *= tool.getDamageModifier();
if (attack < 1)
attack = 1;
if (attack < 1) attack = 1;
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
if (attack % 2 == 0)
write(StatCollector.translateToLocal("gui.toolstation3") + attack / 2 + heart);
else
write(StatCollector.translateToLocal("gui.toolstation3") + df.format(attack / 2f) + heart);
String heart = attack == 2
? StatCollector.translateToLocal("gui.partcrafter8")
: StatCollector.translateToLocal("gui.partcrafter9");
if (attack % 2 == 0) write(StatCollector.translateToLocal("gui.toolstation3") + attack / 2 + heart);
else write(StatCollector.translateToLocal("gui.toolstation3") + df.format(attack / 2f) + heart);
if (stoneboundDamage != 0)
{
heart = stoneboundDamage == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
String bloss = stoneboundDamage > 0 ? StatCollector.translateToLocal("gui.toolstation4") : StatCollector.translateToLocal("gui.toolstation5");
if (stoneboundDamage != 0) {
heart = stoneboundDamage == 2
? StatCollector.translateToLocal("gui.partcrafter8")
: StatCollector.translateToLocal("gui.partcrafter9");
String bloss = stoneboundDamage > 0
? StatCollector.translateToLocal("gui.toolstation4")
: StatCollector.translateToLocal("gui.toolstation5");
write(bloss + df.format(stoneboundDamage / 2f) + heart);
}
}
@@ -240,20 +223,18 @@ public final class ToolStationGuiHelper {
attackf *= weapon.getDamageModifier();
attackf *= weapon.getProjectileSpeed();
if (attackf < 1)
attackf = 1;
if (attackf < 1) attackf = 1;
int attack = (int)attackf;
int attack = (int) attackf;
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
if (attack % 2 == 0)
write(StatCollector.translateToLocal("gui.toolstation23") + attack / 2 + heart);
else
write(StatCollector.translateToLocal("gui.toolstation23") + df.format(attack / 2f) + heart);
String heart = attack == 2
? StatCollector.translateToLocal("gui.partcrafter8")
: StatCollector.translateToLocal("gui.partcrafter9");
if (attack % 2 == 0) write(StatCollector.translateToLocal("gui.toolstation23") + attack / 2 + heart);
else write(StatCollector.translateToLocal("gui.toolstation23") + df.format(attack / 2f) + heart);
}
private static void drawProjectileWeaponStats(ProjectileWeapon weapon, NBTTagCompound tags, ItemStack stack)
{
private static void drawProjectileWeaponStats(ProjectileWeapon weapon, NBTTagCompound tags, ItemStack stack) {
// drawspeed
final int drawSpeed = weapon.getWindupTime(stack);
final float trueDraw = drawSpeed / 20f;
@@ -264,8 +245,7 @@ public final class ToolStationGuiHelper {
write(StatCollector.translateToLocal("gui.toolstation7") + df.format(flightSpeed) + "x");
}
private static void drawProjectileStats(NBTTagCompound tags)
{
private static void drawProjectileStats(NBTTagCompound tags) {
// weight
final float weight = tags.getFloat("Mass");
write(StatCollector.translateToLocal("gui.toolstation8") + df.format(weight));
@@ -279,23 +259,22 @@ public final class ToolStationGuiHelper {
write(StatCollector.translateToLocal("gui.toolstation22") + df.format(breakChance) + "%");
}
private static void drawArmorStats(ArmorCore armor, NBTTagCompound tags, ItemStack stack)
{
private static void drawArmorStats(ArmorCore armor, NBTTagCompound tags, ItemStack stack) {
// Damage reduction
double damageReduction = tags.getDouble("DamageReduction");
if(damageReduction > 0)
if (damageReduction > 0)
write(StatCollector.translateToLocal("gui.toolstation19") + df.format(damageReduction));
// Protection
double protection = armor.getProtection(stack);
double maxProtection = tags.getDouble("MaxDefense");
write(StatCollector.translateToLocal("gui.toolstation20") + df.format(protection) + "/" + df.format(maxProtection));
write(StatCollector.translateToLocal("gui.toolstation20") + df.format(protection) + "/"
+ df.format(maxProtection));
}
private static void drawAccessoryStats(AccessoryCore core, NBTTagCompound tags)
{
if(tags.hasKey("MiningSpeed")) {
private static void drawAccessoryStats(AccessoryCore core, NBTTagCompound tags) {
if (tags.hasKey("MiningSpeed")) {
float mineSpeed = tags.getInteger("MiningSpeed");
float trueSpeed = mineSpeed / (100f);
write(StatCollector.translateToLocal("gui.toolstation16") + trueSpeed);
@@ -306,8 +285,9 @@ public final class ToolStationGuiHelper {
* Renders the specified text to the screen, center-aligned.
* Copied out of GUI
*/
public static void drawCenteredString(FontRenderer p_73732_1_, String p_73732_2_, int p_73732_3_, int p_73732_4_, int p_73732_5_)
{
p_73732_1_.drawStringWithShadow(p_73732_2_, p_73732_3_ - p_73732_1_.getStringWidth(p_73732_2_) / 2, p_73732_4_, p_73732_5_);
public static void drawCenteredString(
FontRenderer p_73732_1_, String p_73732_2_, int p_73732_3_, int p_73732_4_, int p_73732_5_) {
p_73732_1_.drawStringWithShadow(
p_73732_2_, p_73732_3_ - p_73732_1_.getStringWidth(p_73732_2_) / 2, p_73732_4_, p_73732_5_);
}
}
@@ -1,6 +1,7 @@
package tconstruct.tools.inventory;
import com.google.common.primitives.Ints;
import java.lang.ref.WeakReference;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -19,24 +20,20 @@ import tconstruct.tools.TinkerTools;
import tconstruct.tools.gui.ChestSlot;
import tconstruct.tools.logic.CraftingStationLogic;
import javax.annotation.Nonnull;
import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.Set;
public class CraftingStationContainer extends Container {
private final World worldObj;
private final int posX;
private final int posY;
private final int posZ;
@SuppressWarnings("rawtypes")
private final WeakReference [] inventories;
private final WeakReference[] inventories;
/**
* The crafting matrix inventory (3x3).
*/
public InventoryCrafting craftMatrix;
public IInventory craftResult;
public CraftingStationLogic logic;
EntityPlayer player;
@@ -55,31 +52,32 @@ public class CraftingStationContainer extends Container {
int row, col;
int bothOffset = 0;
if (logic.chest != null) {
if(logic.slotCount > 54)
bothOffset += 12; // SlideBar.width
if (logic.slotCount > 54) bothOffset += 12; // SlideBar.width
bothOffset += 122;
}
final int craftingOffsetX = 30 + bothOffset;
final int inventoryOffsetX = 8 + bothOffset;
// 0 - crafting slot
this.addSlotToContainer(new SlotCraftingStation(inventoryplayer.player, this.craftMatrix, this.craftResult, 0, craftingOffsetX + 94, 35));
this.addSlotToContainer(new SlotCraftingStation(
inventoryplayer.player, this.craftMatrix, this.craftResult, 0, craftingOffsetX + 94, 35));
// 1 - 9 - Crafting Matrix
for (row = 0; row < 3; ++row) {
for (col = 0; col < 3; ++col) {
this.addSlotToContainer(new Slot(this.craftMatrix, col + row * 3, craftingOffsetX + col * 18, 17 + row * 18));
this.addSlotToContainer(
new Slot(this.craftMatrix, col + row * 3, craftingOffsetX + col * 18, 17 + row * 18));
}
}
// Player Inventory 10 - 36
for (row = 0; row < 3; ++row) {
for (col = 0; col < 9; ++col) {
this.addSlotToContainer(new Slot(inventoryplayer, col + row * 9 + 9, inventoryOffsetX + col * 18, 84 + row * 18));
this.addSlotToContainer(
new Slot(inventoryplayer, col + row * 9 + 9, inventoryOffsetX + col * 18, 84 + row * 18));
}
}
// Player Hotbar - 37 - 45
@@ -93,20 +91,22 @@ public class CraftingStationContainer extends Container {
IInventory secondInv = logic.getSecondInventory();
final int accessSide = logic.chestDirection.getOpposite().ordinal();
final int[] accessibleSlots = inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(accessSide) : null;
final int[] accessibleSlots = inv instanceof ISidedInventory
? ((ISidedInventory) inv).getAccessibleSlotsFromSide(accessSide)
: null;
int index = 0, curIndex = 0;
IInventory curInv;
final int invSize = inv.getSizeInventory() * (secondInv != null ? 2 : 1);
final int invSize = inv.getSizeInventory() * (secondInv != null ? 2 : 1);
for (row = 0; row < logic.invRows; row++) {
for (col = 0; col < logic.invColumns; col++) {
if(index >= invSize) break;
if (index >= invSize) break;
// Adjust the inventory to account for double chests
curInv = secondInv != null && index >= 27 ? secondInv : inv;
// Adjust the index for the inventory
curIndex = secondInv != null && index >= 27 ? index - 27 : index;
if(accessibleSlots != null) {
if (accessibleSlots != null) {
if (curIndex >= accessibleSlots.length) {
break;
} else {
@@ -114,7 +114,8 @@ public class CraftingStationContainer extends Container {
}
}
this.addSlotToContainer(new ChestSlot(curInv, curIndex, index, 8 + col * 18, 19 + row * 18, accessSide));
this.addSlotToContainer(
new ChestSlot(curInv, curIndex, index, 8 + col * 18, 19 + row * 18, accessSide));
index++;
}
}
@@ -141,20 +142,21 @@ public class CraftingStationContainer extends Container {
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int index) {
Slot slot = (Slot) this.inventorySlots.get(index);
if(slot == null || !slot.getHasStack()) {
if (slot == null || !slot.getHasStack()) {
return null;
}
ItemStack itemstack = slot.getStack();
ItemStack ret = itemstack.copy();
boolean nothingDone = true;
if (index == 0) {
// Crafting Result
if (ret.getItem() instanceof IModifyable) {
nothingDone &= !this.mergeCraftedStack(itemstack, logic.getSizeInventory(), this.inventorySlots.size(), true, entityPlayer);
nothingDone &= !this.mergeCraftedStack(
itemstack, logic.getSizeInventory(), this.inventorySlots.size(), true, entityPlayer);
} else {
// First refill the attached chests
nothingDone &= this.refillChest(itemstack);
@@ -164,20 +166,19 @@ public class CraftingStationContainer extends Container {
}
slot.onSlotChange(itemstack, ret);
} else if(index >= 1 && index < 10) { // From Crafting Grid
} else if (index >= 1 && index < 10) { // From Crafting Grid
// First refill the attached chests
nothingDone &= this.refillChest(itemstack);
// Then try moving to player inventory
nothingDone &= moveToPlayerInventory(itemstack);
}
else if (index >= 10 && index < 46) { // From Player Inv or Hotbar
} else if (index >= 10 && index < 46) { // From Player Inv or Hotbar
// First to the crafting Matrix
nothingDone &= moveToCraftingGrid(itemstack);
// Then to any attached chest
nothingDone &= this.moveToChest(itemstack);
} else { // From the Attached Chests
} else { // From the Attached Chests
// First to the crafting Matrix
nothingDone &= moveToCraftingGrid(itemstack);
@@ -185,10 +186,10 @@ public class CraftingStationContainer extends Container {
nothingDone &= moveToPlayerInventory(itemstack);
}
if(nothingDone) {
if (nothingDone) {
return null;
}
if (itemstack.stackSize == 0) {
slot.putStack(null);
} else {
@@ -203,31 +204,32 @@ public class CraftingStationContainer extends Container {
return ret;
}
protected boolean refillChest(ItemStack itemstack) {
if(itemstack == null || itemstack.stackSize <= 0 || logic.slotCount == 0) return false;
if (itemstack == null || itemstack.stackSize <= 0 || logic.slotCount == 0) return false;
return !this.mergeItemStackRefill(itemstack, 46, 46 + logic.slotCount, false);
}
protected boolean moveToChest(ItemStack itemstack) {
if(itemstack == null || itemstack.stackSize <= 0 || logic.slotCount == 0) return false;
if (itemstack == null || itemstack.stackSize <= 0 || logic.slotCount == 0) return false;
return !this.mergeItemStack(itemstack, 46, 46 + logic.slotCount, false);
}
protected boolean moveToPlayerInventory(ItemStack itemstack) {
if(itemstack == null || itemstack.stackSize <= 0) return false;
if (itemstack == null || itemstack.stackSize <= 0) return false;
return !this.mergeItemStack(itemstack, 10, 46, false);
}
protected boolean moveToCraftingGrid(ItemStack itemstack) {
if(itemstack == null || itemstack.stackSize <= 0) return false;
if (itemstack == null || itemstack.stackSize <= 0) return false;
return !this.mergeItemStack(itemstack, 1, 10, true);
}
public boolean func_94530_a/*canMergeSlot*/(ItemStack par1ItemStack, Slot par2Slot) {
public boolean func_94530_a /*canMergeSlot*/(ItemStack par1ItemStack, Slot par2Slot) {
return par2Slot.inventory != this.craftResult && super.func_94530_a(par1ItemStack, par2Slot);
}
@@ -248,25 +250,26 @@ public class CraftingStationContainer extends Container {
public void onCraftMatrixChanged(IInventory par1IInventory) {
ItemStack tool = modifyItem();
if (tool != null)
this.craftResult.setInventorySlotContents(0, tool);
if (tool != null) this.craftResult.setInventorySlotContents(0, tool);
else
this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
this.craftResult.setInventorySlotContents(
0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
}
@Override
public boolean canInteractWith(EntityPlayer player) {
Block block = worldObj.getBlock(this.posX, this.posY, this.posZ);
if (block != TinkerTools.craftingStationWood && block != TinkerTools.craftingSlabWood)
return false;
if (block != TinkerTools.craftingStationWood && block != TinkerTools.craftingSlabWood) return false;
if (!this.logic.isUseableByPlayer(player) || !CraftingStationLogic.isUseableByPlayer(player, this.inventories))
return false;
return player.getDistanceSq((double) this.posX + 0.5D, (double) this.posY + 0.5D, (double) this.posZ + 0.5D) <= 64.0D;
return player.getDistanceSq((double) this.posX + 0.5D, (double) this.posY + 0.5D, (double) this.posZ + 0.5D)
<= 64.0D;
}
protected boolean mergeCraftedStack(ItemStack stack, int slotsStart, int slotsTotal, boolean playerInventory, EntityPlayer player) {
protected boolean mergeCraftedStack(
ItemStack stack, int slotsStart, int slotsTotal, boolean playerInventory, EntityPlayer player) {
boolean failedToMerge = false;
int slotIndex = slotsStart;
@@ -282,7 +285,7 @@ public class CraftingStationContainer extends Container {
otherInventorySlot = (Slot) this.inventorySlots.get(slotIndex);
copyStack = otherInventorySlot.getStack();
if (copyStack == null) {
if (copyStack == null && otherInventorySlot.isItemValid(stack)) {
otherInventorySlot.putStack(stack.copy());
otherInventorySlot.onSlotChanged();
stack.stackSize = 0;
@@ -304,54 +307,53 @@ public class CraftingStationContainer extends Container {
@Override
protected boolean mergeItemStack(@Nonnull ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
boolean ret = mergeItemStackRefill(stack, startIndex, endIndex, useEndIndex);
if(stack.stackSize > 0) {
if (stack.stackSize > 0) {
ret |= mergeItemStackMove(stack, startIndex, endIndex, useEndIndex);
}
return ret;
}
// only refills items that are already present
protected boolean mergeItemStackRefill(@Nonnull ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
if(stack.stackSize <= 0) {
protected boolean mergeItemStackRefill(
@Nonnull ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
if (stack.stackSize <= 0) {
return false;
}
boolean didSomething = false;
int k = useEndIndex ? endIndex - 1 : startIndex;
Slot slot;
ItemStack itemstack1;
if(stack.isStackable()) {
while(stack.stackSize > 0 && (!useEndIndex && k < endIndex || useEndIndex && k >= startIndex)) {
slot = (Slot)this.inventorySlots.get(k);
if (stack.isStackable()) {
while (stack.stackSize > 0 && (!useEndIndex && k < endIndex || useEndIndex && k >= startIndex)) {
slot = (Slot) this.inventorySlots.get(k);
itemstack1 = slot.getStack();
if(itemstack1 != null
&& itemstack1.getItem() == stack.getItem()
&& (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage())
&& ItemStack.areItemStackTagsEqual(stack, itemstack1)
&& this.func_94530_a/*canMergeSlot*/(stack, slot)) {
if (itemstack1 != null
&& itemstack1.getItem() == stack.getItem()
&& (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage())
&& ItemStack.areItemStackTagsEqual(stack, itemstack1)
&& this.func_94530_a /*canMergeSlot*/(stack, slot)) {
int l = itemstack1.stackSize + stack.stackSize;
int limit = Math.min(stack.getMaxStackSize(), slot.getSlotStackLimit());
if(l <= limit) {
if (l <= limit) {
stack.stackSize = 0;
itemstack1.stackSize = l;
slot.onSlotChanged();
didSomething = true;
}
else if(itemstack1.stackSize < limit) {
} else if (itemstack1.stackSize < limit) {
stack.stackSize -= (limit - itemstack1.stackSize);
itemstack1.stackSize = limit;
slot.onSlotChanged();
didSomething = true;
}
}
if(useEndIndex) --k;
else ++k;
if (useEndIndex) --k;
else ++k;
}
}
@@ -360,43 +362,42 @@ public class CraftingStationContainer extends Container {
// only moves items into empty slots
protected boolean mergeItemStackMove(@Nonnull ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
if(stack.stackSize <= 0) {
if (stack.stackSize <= 0) {
return false;
}
boolean didSomething = false;
int k = useEndIndex ? endIndex - 1 : startIndex;
while(!useEndIndex && k < endIndex || useEndIndex && k >= startIndex) {
final Slot slot = (Slot)this.inventorySlots.get(k);
while (!useEndIndex && k < endIndex || useEndIndex && k >= startIndex) {
final Slot slot = (Slot) this.inventorySlots.get(k);
ItemStack itemstack1 = slot.getStack();
if((itemstack1 == null || itemstack1.stackSize == 0) && slot.isItemValid(stack) && this.func_94530_a/*canMergeSlot*/(stack, slot)) {
if ((itemstack1 == null || itemstack1.stackSize == 0)
&& slot.isItemValid(stack)
&& this.func_94530_a /*canMergeSlot*/(stack, slot)) {
// Forge: Make sure to respect isItemValid in the slot.
int limit = slot.getSlotStackLimit();
ItemStack stack2 = stack.copy();
if(stack2.stackSize > limit) {
if (stack2.stackSize > limit) {
stack2.stackSize = limit;
stack.stackSize -= limit;
}
else {
} else {
stack.stackSize = 0;
}
slot.putStack(stack2);
slot.onSlotChanged();
didSomething = true;
if(stack.stackSize <= 0) {
if (stack.stackSize <= 0) {
break;
}
}
if(useEndIndex) --k;
else ++k;
if (useEndIndex) --k;
else ++k;
}
return didSomething;
}
}
@@ -7,15 +7,13 @@ import net.minecraft.item.ItemStack;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.FrypanLogic;
public class FrypanContainer extends Container
{
public class FrypanContainer extends Container {
public FrypanLogic logic;
public int progress = 0;
public int fuel = 0;
public int fuelGague = 0;
public FrypanContainer(EntityPlayer player, FrypanLogic frypan)
{
public FrypanContainer(EntityPlayer player, FrypanLogic frypan) {
InventoryPlayer inventoryplayer = player.inventory;
logic = frypan;
this.addSlotToContainer(new Slot(frypan, 1, 26, 45));
@@ -24,37 +22,30 @@ public class FrypanContainer extends Container
this.addSlotToContainer(new SlotFrypan(frypan, 2 + x + y * 4, 70 + x * 18, 27 + y * 18, player));
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(
new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
}
}
@Override
public void detectAndSendChanges ()
{
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++)
{
for (int i = 0; i < crafters.size(); i++) {
ICrafting icrafting = (ICrafting) crafters.get(i);
if (progress != logic.progress)
{
if (progress != logic.progress) {
icrafting.sendProgressBarUpdate(this, 0, logic.progress);
}
if (fuel != logic.fuel)
{
if (fuel != logic.fuel) {
icrafting.sendProgressBarUpdate(this, 1, logic.fuel);
}
if (fuelGague != logic.fuelGague)
{
if (fuelGague != logic.fuelGague) {
icrafting.sendProgressBarUpdate(this, 2, logic.fuelGague);
}
}
@@ -65,61 +56,46 @@ public class FrypanContainer extends Container
}
@Override
public void updateProgressBar (int i, int j)
{
if (i == 0)
{
public void updateProgressBar(int i, int j) {
if (i == 0) {
logic.progress = j;
}
if (i == 1)
{
if (i == 1) {
logic.fuel = j;
}
if (i == 2)
{
if (i == 2) {
logic.fuelGague = j;
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
public boolean canInteractWith(EntityPlayer entityplayer) {
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.heldItemBlock)
return false;
if (block != TinkerTools.heldItemBlock) return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
if (slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
if (slotID < logic.getSizeInventory()) {
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
}
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false))
{
} else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) {
return null;
}
if (slotStack.stackSize == 0)
{
if (slotStack.stackSize == 0) {
slot.putStack((ItemStack) null);
}
else
{
} else {
slot.onSlotChanged();
}
}
@@ -8,38 +8,32 @@ import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntityFurnace;
import tconstruct.tools.logic.FurnaceLogic;
public class FurnaceContainer extends Container
{
public class FurnaceContainer extends Container {
private FurnaceLogic furnace;
private int lastCookTime;
private int lastBurnTime;
private int lastItemBurnTime;
public FurnaceContainer(InventoryPlayer par1InventoryPlayer, FurnaceLogic par2TileEntityFurnace)
{
public FurnaceContainer(InventoryPlayer par1InventoryPlayer, FurnaceLogic par2TileEntityFurnace) {
this.furnace = par2TileEntityFurnace;
this.addSlotToContainer(new Slot(par2TileEntityFurnace, 0, 56, 17));
this.addSlotToContainer(new Slot(par2TileEntityFurnace, 1, 56, 53));
this.addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, par2TileEntityFurnace, 2, 116, 35));
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public void addCraftingToCrafters (ICrafting par1ICrafting)
{
public void addCraftingToCrafters(ICrafting par1ICrafting) {
super.addCraftingToCrafters(par1ICrafting);
par1ICrafting.sendProgressBarUpdate(this, 0, this.furnace.progress);
par1ICrafting.sendProgressBarUpdate(this, 1, this.furnace.fuel);
@@ -50,26 +44,21 @@ public class FurnaceContainer extends Container
* Looks for changes made in the container, sends them to every listener.
*/
@Override
public void detectAndSendChanges ()
{
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < this.crafters.size(); ++i)
{
for (int i = 0; i < this.crafters.size(); ++i) {
ICrafting icrafting = (ICrafting) this.crafters.get(i);
if (this.lastCookTime != this.furnace.progress)
{
if (this.lastCookTime != this.furnace.progress) {
icrafting.sendProgressBarUpdate(this, 0, this.furnace.progress);
}
if (this.lastBurnTime != this.furnace.fuel)
{
if (this.lastBurnTime != this.furnace.fuel) {
icrafting.sendProgressBarUpdate(this, 1, this.furnace.fuel);
}
if (this.lastItemBurnTime != this.furnace.fuelGague)
{
if (this.lastItemBurnTime != this.furnace.fuelGague) {
icrafting.sendProgressBarUpdate(this, 2, this.furnace.fuelGague);
}
}
@@ -81,27 +70,22 @@ public class FurnaceContainer extends Container
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar (int par1, int par2)
{
if (par1 == 0)
{
public void updateProgressBar(int par1, int par2) {
if (par1 == 0) {
this.furnace.progress = par2;
}
if (par1 == 1)
{
if (par1 == 1) {
this.furnace.fuel = par2;
}
if (par1 == 2)
{
if (par1 == 2) {
this.furnace.fuelGague = par2;
}
}
@Override
public boolean canInteractWith (EntityPlayer par1EntityPlayer)
{
public boolean canInteractWith(EntityPlayer par1EntityPlayer) {
return this.furnace.isUseableByPlayer(par1EntityPlayer);
}
@@ -110,69 +94,47 @@ public class FurnaceContainer extends Container
* you will crash when someone does that.
*/
@Override
public ItemStack transferStackInSlot (EntityPlayer par1EntityPlayer, int par2)
{
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
ItemStack itemstack = null;
Slot slot = (Slot) this.inventorySlots.get(par2);
if (slot != null && slot.getHasStack())
{
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (par2 == 2)
{
if (!this.mergeItemStack(itemstack1, 3, 39, true))
{
if (par2 == 2) {
if (!this.mergeItemStack(itemstack1, 3, 39, true)) {
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (par2 != 1 && par2 != 0)
{
if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null)
{
if (!this.mergeItemStack(itemstack1, 0, 1, false))
{
} else if (par2 != 1 && par2 != 0) {
if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null) {
if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
return null;
}
}
else if (TileEntityFurnace.isItemFuel(itemstack1))
{
if (!this.mergeItemStack(itemstack1, 1, 2, false))
{
} else if (TileEntityFurnace.isItemFuel(itemstack1)) {
if (!this.mergeItemStack(itemstack1, 1, 2, false)) {
return null;
}
}
else if (par2 >= 3 && par2 < 30)
{
if (!this.mergeItemStack(itemstack1, 30, 39, false))
{
} else if (par2 >= 3 && par2 < 30) {
if (!this.mergeItemStack(itemstack1, 30, 39, false)) {
return null;
}
}
else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
{
} else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) {
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{
} else if (!this.mergeItemStack(itemstack1, 3, 39, false)) {
return null;
}
if (itemstack1.stackSize == 0)
{
if (itemstack1.stackSize == 0) {
slot.putStack((ItemStack) null);
}
else
{
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
{
if (itemstack1.stackSize == itemstack.stackSize) {
return null;
}
@@ -5,8 +5,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.*;
import net.minecraft.item.ItemStack;
public class InventoryCraftingStation extends InventoryCrafting
{
public class InventoryCraftingStation extends InventoryCrafting {
/** the width of the crafting inventory */
private int inventoryWidth;
@@ -15,10 +14,10 @@ public class InventoryCraftingStation extends InventoryCrafting
* on_CraftMaxtrixChanged.
*/
private Container eventHandler;
private InventoryLogic logic;
public InventoryCraftingStation(Container par1Container, int size, int height, InventoryLogic logic)
{
public InventoryCraftingStation(Container par1Container, int size, int height, InventoryLogic logic) {
super(par1Container, size, height);
this.eventHandler = par1Container;
this.inventoryWidth = size;
@@ -29,45 +28,36 @@ public class InventoryCraftingStation extends InventoryCrafting
* Returns the number of slots in the inventory.
*/
@Override
public int getSizeInventory ()
{
public int getSizeInventory() {
return 9;
}
@Override
public ItemStack getStackInSlot (int slot)
{
public ItemStack getStackInSlot(int slot) {
// the 9 slots + 1 output slot that's not accessible, we therefore have to add 1 to the slot accessed
return slot >= this.getSizeInventory() ? null : logic.getStackInSlot(slot+1);
return slot >= this.getSizeInventory() ? null : logic.getStackInSlot(slot + 1);
}
@Override
public ItemStack getStackInRowAndColumn (int row, int column)
{
if (row >= 0 && row < this.inventoryWidth)
{
public ItemStack getStackInRowAndColumn(int row, int column) {
if (row >= 0 && row < this.inventoryWidth) {
int k = row + column * this.inventoryWidth;
return this.getStackInSlot(k);
}
else
{
} else {
return null;
}
}
public String getInvName ()
{
public String getInvName() {
return "container.crafting";
}
public boolean isInvNameLocalized ()
{
public boolean isInvNameLocalized() {
return false;
}
@Override
public ItemStack getStackInSlotOnClosing (int par1)
{
public ItemStack getStackInSlotOnClosing(int par1) {
return null;
}
@@ -76,36 +66,28 @@ public class InventoryCraftingStation extends InventoryCrafting
* (second arg) of items and returns them in a new stack.
*/
@Override
public ItemStack decrStackSize (int slotID, int par2)
{
public ItemStack decrStackSize(int slotID, int par2) {
ItemStack stack = logic.getStackInSlot(slotID + 1);
if (stack != null)
{
if (stack != null) {
ItemStack itemstack;
if (stack.stackSize <= par2)
{
if (stack.stackSize <= par2) {
itemstack = stack.copy();
stack = null;
logic.setInventorySlotContents(slotID + 1, null);
this.eventHandler.onCraftMatrixChanged(this);
return itemstack;
}
else
{
} else {
itemstack = stack.splitStack(par2);
if (stack.stackSize == 0)
{
if (stack.stackSize == 0) {
stack = null;
}
this.eventHandler.onCraftMatrixChanged(this);
return itemstack;
}
}
else
{
} else {
return null;
}
}
@@ -115,8 +97,7 @@ public class InventoryCraftingStation extends InventoryCrafting
* crafting or armor sections).
*/
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
public void setInventorySlotContents(int slot, ItemStack itemstack) {
logic.setInventorySlotContents(slot + 1, itemstack);
this.eventHandler.onCraftMatrixChanged(this);
}
@@ -126,8 +107,7 @@ public class InventoryCraftingStation extends InventoryCrafting
* 64, possibly will be extended. *Isn't this more of a set than a get?*
*/
@Override
public int getInventoryStackLimit ()
{
public int getInventoryStackLimit() {
return 64;
}
@@ -135,34 +115,26 @@ public class InventoryCraftingStation extends InventoryCrafting
* Called when an the contents of an Inventory change, usually
*/
@Override
public void markDirty ()
{
}
public void markDirty() {}
/**
* Do not make give this method the name canInteractWith because it clashes
* with Container
*/
@Override
public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer)
{
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) {
return true;
}
public void openChest ()
{
}
public void openChest() {}
public void closeChest ()
{
}
public void closeChest() {}
/**
* Returns true if automation is allowed to insert the given stack (ignoring
* stack size) into the given slot.
*/
public boolean isStackValidForSlot (int par1, ItemStack par2ItemStack)
{
public boolean isStackValidForSlot(int par1, ItemStack par2ItemStack) {
return true;
}
}
@@ -5,12 +5,10 @@ import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.item.ItemStack;
import tconstruct.tools.logic.CraftingStationLogic;
public class InventoryCraftingStationResult extends InventoryCraftResult
{
public class InventoryCraftingStationResult extends InventoryCraftResult {
CraftingStationLogic logic;
public InventoryCraftingStationResult(CraftingStationLogic logic)
{
public InventoryCraftingStationResult(CraftingStationLogic logic) {
this.logic = logic;
}
@@ -18,8 +16,7 @@ public class InventoryCraftingStationResult extends InventoryCraftResult
* Returns the number of slots in the inventory.
*/
@Override
public int getSizeInventory ()
{
public int getSizeInventory() {
return 1;
}
@@ -27,16 +24,14 @@ public class InventoryCraftingStationResult extends InventoryCraftResult
* Returns the stack in slot i
*/
@Override
public ItemStack getStackInSlot (int par1)
{
return logic.getStackInSlot(0);// this.stackResult[0];
public ItemStack getStackInSlot(int par1) {
return logic.getStackInSlot(0); // this.stackResult[0];
}
/**
* Returns the name of the inventory.
*/
public String getInvName ()
{
public String getInvName() {
return "Result";
}
@@ -45,8 +40,7 @@ public class InventoryCraftingStationResult extends InventoryCraftResult
* name, and translated into the player's language. Otherwise it will be
* used directly.
*/
public boolean isInvNameLocalized ()
{
public boolean isInvNameLocalized() {
return false;
}
@@ -55,17 +49,13 @@ public class InventoryCraftingStationResult extends InventoryCraftResult
* (second arg) of items and returns them in a new stack.
*/
@Override
public ItemStack decrStackSize (int par1, int par2)
{
public ItemStack decrStackSize(int par1, int par2) {
ItemStack stack = logic.getStackInSlot(0);
if (stack != null)
{
if (stack != null) {
ItemStack itemstack = stack;
logic.setInventorySlotContents(0, null);
return itemstack;
}
else
{
} else {
return null;
}
}
@@ -76,8 +66,7 @@ public class InventoryCraftingStationResult extends InventoryCraftResult
* GUI.
*/
@Override
public ItemStack getStackInSlotOnClosing (int par1)
{
public ItemStack getStackInSlotOnClosing(int par1) {
return null;
}
@@ -86,8 +75,7 @@ public class InventoryCraftingStationResult extends InventoryCraftResult
* crafting or armor sections).
*/
@Override
public void setInventorySlotContents (int par1, ItemStack par2ItemStack)
{
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
logic.setInventorySlotContents(0, par2ItemStack);
}
@@ -96,8 +84,7 @@ public class InventoryCraftingStationResult extends InventoryCraftResult
* 64, possibly will be extended. *Isn't this more of a set than a get?*
*/
@Override
public int getInventoryStackLimit ()
{
public int getInventoryStackLimit() {
return 64;
}
@@ -105,34 +92,26 @@ public class InventoryCraftingStationResult extends InventoryCraftResult
* Called when an the contents of an Inventory change, usually
*/
@Override
public void markDirty ()
{
}
public void markDirty() {}
/**
* Do not make give this method the name canInteractWith because it clashes
* with Container
*/
@Override
public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer)
{
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) {
return true;
}
public void openChest ()
{
}
public void openChest() {}
public void closeChest ()
{
}
public void closeChest() {}
/**
* Returns true if automation is allowed to insert the given stack (ignoring
* stack size) into the given slot.
*/
public boolean isStackValidForSlot (int par1, ItemStack par2ItemStack)
{
public boolean isStackValidForSlot(int par1, ItemStack par2ItemStack) {
return true;
}
}
@@ -12,8 +12,7 @@ import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.PartBuilderLogic;
import tconstruct.tools.logic.PatternChestLogic;
public class PartCrafterChestContainer extends ActiveContainer
{
public class PartCrafterChestContainer extends ActiveContainer {
protected PatternChestLogic patternLogic;
protected InventoryPlayer invPlayer;
protected PartBuilderLogic logic;
@@ -21,82 +20,73 @@ public class PartCrafterChestContainer extends ActiveContainer
protected Slot[] inventory;
public boolean largeInventory;
public PartCrafterChestContainer(InventoryPlayer inventoryplayer, PartBuilderLogic partLogic, PatternChestLogic pLogic)
{
public PartCrafterChestContainer(
InventoryPlayer inventoryplayer, PartBuilderLogic partLogic, PatternChestLogic pLogic) {
logic = partLogic;
patternLogic = pLogic;
largeInventory = true;
inventory = new Slot[] { new SlotPattern(partLogic, 0, 156, 27), new SlotPattern(partLogic, 1, 156, 45), new Slot(partLogic, 2, 174, 27), new Slot(partLogic, 3, 174, 45), new SlotOnlyTake(partLogic, 4, 218, 27), new SlotOnlyTake(partLogic, 5, 236, 27), new SlotOnlyTake(partLogic, 6, 218, 45), new SlotOnlyTake(partLogic, 7, 236, 45) };
for (int iter = 0; iter < inventory.length; iter++)
this.addSlotToContainer(inventory[iter]);
inventory = new Slot[] {
new SlotPattern(partLogic, 0, 156, 27),
new SlotPattern(partLogic, 1, 156, 45),
new Slot(partLogic, 2, 174, 27),
new Slot(partLogic, 3, 174, 45),
new SlotOnlyTake(partLogic, 4, 218, 27),
new SlotOnlyTake(partLogic, 5, 236, 27),
new SlotOnlyTake(partLogic, 6, 218, 45),
new SlotOnlyTake(partLogic, 7, 236, 45)
};
for (int iter = 0; iter < inventory.length; iter++) this.addSlotToContainer(inventory[iter]);
/* Holder inventory */
for (int column = 0; column < 5; column++)
{
for (int row = 0; row < 6; row++)
{
for (int column = 0; column < 5; column++) {
for (int row = 0; row < 6; row++) {
this.addSlotToContainer(new SlotPattern(pLogic, row + column * 6, 8 + row * 18, 30 + column * 18));
}
}
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 124 + row * 18, 84 + column * 18));
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(
new Slot(inventoryplayer, row + column * 9 + 9, 124 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(inventoryplayer, column, 124 + column * 18, 142));
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
public boolean canInteractWith(EntityPlayer entityplayer) {
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood) return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
if (slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
int inventorySize = this.inventory.length + this.patternLogic.getSizeInventory();
if (slotID < inventorySize)
{
if (!this.mergeItemStack(slotStack, inventorySize, this.inventorySlots.size(), true))
{
if (slotID < inventorySize) {
if (!this.mergeItemStack(slotStack, inventorySize, this.inventorySlots.size(), true)) {
return null;
}
}
else
{
if (slotStack.getItem() instanceof IPattern)
{
} else {
if (slotStack.getItem() instanceof IPattern) {
if (!this.mergeItemStack(slotStack, 0, 2, false) && !this.mergeItemStack(slotStack, 8, 38, false))
return null;
}
else if (!this.mergeItemStack(slotStack, 2, 4, false))
return null;
} else if (!this.mergeItemStack(slotStack, 2, 4, false)) return null;
}
if (slotStack.stackSize == 0)
{
if (slotStack.stackSize == 0) {
slot.putStack(null);
logic.tryBuildPart(slotID);
}
@@ -10,80 +10,70 @@ import tconstruct.smeltery.inventory.ActiveContainer;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.PartBuilderLogic;
public class PartCrafterContainer extends ActiveContainer
{
public class PartCrafterContainer extends ActiveContainer {
protected InventoryPlayer invPlayer;
protected PartBuilderLogic logic;
protected Slot[] input;
protected Slot[] inventory;
public boolean largeInventory;
public PartCrafterContainer(InventoryPlayer inventoryplayer, PartBuilderLogic partLogic)
{
public PartCrafterContainer(InventoryPlayer inventoryplayer, PartBuilderLogic partLogic) {
invPlayer = inventoryplayer;
logic = partLogic;
largeInventory = false;
inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new SlotPattern(partLogic, 1, 40, 45), new Slot(partLogic, 2, 58, 27), new Slot(partLogic, 3, 58, 45), new SlotOnlyTake(partLogic, 4, 102, 27), new SlotOnlyTake(partLogic, 5, 120, 27), new SlotOnlyTake(partLogic, 6, 102, 45), new SlotOnlyTake(partLogic, 7, 120, 45) };
for (int iter = 0; iter < inventory.length; iter++)
this.addSlotToContainer(inventory[iter]);
inventory = new Slot[] {
new SlotPattern(partLogic, 0, 40, 27),
new SlotPattern(partLogic, 1, 40, 45),
new Slot(partLogic, 2, 58, 27),
new Slot(partLogic, 3, 58, 45),
new SlotOnlyTake(partLogic, 4, 102, 27),
new SlotOnlyTake(partLogic, 5, 120, 27),
new SlotOnlyTake(partLogic, 6, 102, 45),
new SlotOnlyTake(partLogic, 7, 120, 45)
};
for (int iter = 0; iter < inventory.length; iter++) this.addSlotToContainer(inventory[iter]);
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(
new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
public boolean canInteractWith(EntityPlayer entityplayer) {
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood) return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
if (slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
if (slotID < logic.getSizeInventory()) {
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
}
else
{
if (slotStack.getItem() instanceof IPattern)
{
if (!this.mergeItemStack(slotStack, 0, 2, false))
return null;
}
else if (!this.mergeItemStack(slotStack, 2, 4, false))
return null;
} else {
if (slotStack.getItem() instanceof IPattern) {
if (!this.mergeItemStack(slotStack, 0, 2, false)) return null;
} else if (!this.mergeItemStack(slotStack, 2, 4, false)) return null;
}
if (slotStack.stackSize == 0)
{
if (slotStack.stackSize == 0) {
slot.putStack((ItemStack) null);
logic.tryBuildPart(slotID);
}
@@ -10,77 +10,60 @@ import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.PatternChestLogic;
@ChestContainer
public class PatternChestContainer extends Container
{
public class PatternChestContainer extends Container {
public PatternChestLogic logic;
public int progress = 0;
public int fuel = 0;
public int fuelGague = 0;
public PatternChestContainer(InventoryPlayer inventoryplayer, PatternChestLogic chest)
{
public PatternChestContainer(InventoryPlayer inventoryplayer, PatternChestLogic chest) {
logic = chest;
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 10; row++)
{
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 10; row++) {
this.addSlotToContainer(new SlotPattern(chest, row + column * 10, 8 + row * 18, 18 + column * 18));
}
}
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 17 + row * 18, 86 + column * 18));
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(
new Slot(inventoryplayer, row + column * 9 + 9, 17 + row * 18, 86 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(inventoryplayer, column, 17 + column * 18, 144));
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
public boolean canInteractWith(EntityPlayer entityplayer) {
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood) return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
if (slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
if (slotID < logic.getSizeInventory()) {
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
}
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false))
{
} else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) {
return null;
}
if (slotStack.stackSize == 0)
{
if (slotStack.stackSize == 0) {
slot.putStack((ItemStack) null);
}
else
{
} else {
slot.onSlotChanged();
}
}
@@ -89,11 +72,9 @@ public class PatternChestContainer extends Container
}
@Override
protected boolean mergeItemStack (ItemStack stack, int inventorySize, int slotSize, boolean par4)
{
if (!(stack.getItem() instanceof IPattern))
return false;
protected boolean mergeItemStack(ItemStack stack, int inventorySize, int slotSize, boolean par4) {
if (!(stack.getItem() instanceof IPattern)) return false;
return super.mergeItemStack(stack, inventorySize, slotSize, par4);
}
}
}
@@ -8,12 +8,10 @@ import tconstruct.armor.inventory.SlotOnlyTake;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.StencilTableLogic;
public class PatternShaperContainer extends Container
{
public class PatternShaperContainer extends Container {
public StencilTableLogic logic;
public PatternShaperContainer(InventoryPlayer inventoryplayer, StencilTableLogic shaper)
{
public PatternShaperContainer(InventoryPlayer inventoryplayer, StencilTableLogic shaper) {
logic = shaper;
this.addSlotToContainer(new Slot(shaper, 0, 48, 35));
this.addSlotToContainer(new SlotOnlyTake(shaper, 1, 106, 35));
@@ -26,16 +24,14 @@ public class PatternShaperContainer extends Container
}*/
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(
new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
}
}
@@ -61,17 +57,14 @@ public class PatternShaperContainer extends Container
}*/
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
public boolean canInteractWith(EntityPlayer entityplayer) {
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood) return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
return null;
/*ItemStack stack = null;
Slot slot = (Slot)this.inventorySlots.get(slotID);
@@ -105,5 +98,4 @@ public class PatternShaperContainer extends Container
return stack;*/
}
}
}
@@ -6,26 +6,34 @@ import net.minecraft.item.ItemStack;
import tconstruct.library.modifier.IModifyable;
import tconstruct.library.tools.AbilityHelper;
public class SlotCraftingStation extends SlotCrafting
{
public class SlotCraftingStation extends SlotCrafting {
private final IInventory matrix;
private EntityPlayer player;
public SlotCraftingStation(EntityPlayer par1EntityPlayer, IInventory par2IInventory, IInventory par3iInventory, int par4, int par5, int par6)
{
public SlotCraftingStation(
EntityPlayer par1EntityPlayer,
IInventory par2IInventory,
IInventory par3iInventory,
int par4,
int par5,
int par6) {
super(par1EntityPlayer, par2IInventory, par3iInventory, par4, par5, par6);
this.matrix = par2IInventory;
this.player = par1EntityPlayer;
}
@Override
public void onPickupFromSlot (EntityPlayer player, ItemStack stack)
{
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
ItemStack tool = this.matrix.getStackInSlot(4);
if (stack.getItem() instanceof IModifyable && tool != null && tool.getItem() instanceof IModifyable)
{
if (stack.getItem() instanceof IModifyable && tool != null && tool.getItem() instanceof IModifyable) {
matrix.setInventorySlotContents(4, null);
player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "tinker:little_saw", 1.0F, (AbilityHelper.random.nextFloat() - AbilityHelper.random.nextFloat()) * 0.2F + 1.0F);
player.worldObj.playSoundEffect(
player.posX,
player.posY,
player.posZ,
"tinker:little_saw",
1.0F,
(AbilityHelper.random.nextFloat() - AbilityHelper.random.nextFloat()) * 0.2F + 1.0F);
}
super.onPickupFromSlot(player, stack);
}
@@ -6,31 +6,28 @@ import net.minecraft.item.*;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.achievements.TAchievements;
public class SlotFrypan extends Slot
{
public class SlotFrypan extends Slot {
public EntityPlayer player;
public SlotFrypan(IInventory par1IInventory, int par2, int par3, int par4, EntityPlayer player)
{
public SlotFrypan(IInventory par1IInventory, int par2, int par3, int par4, EntityPlayer player) {
super(par1IInventory, par2, par3, par4);
this.player = player;
}
@Override
public void putStack (ItemStack par1ItemStack)
{
public void putStack(ItemStack par1ItemStack) {
super.putStack(par1ItemStack);
if (par1ItemStack != null && par1ItemStack.getItem() != null && par1ItemStack.getItem() instanceof ItemFood && par1ItemStack.hasTagCompound())
{
if (par1ItemStack != null
&& par1ItemStack.getItem() != null
&& par1ItemStack.getItem() instanceof ItemFood
&& par1ItemStack.hasTagCompound()) {
NBTTagCompound stackTagCompound = par1ItemStack.getTagCompound();
if (stackTagCompound == null || !stackTagCompound.getBoolean("frypanKill"))
{
if (stackTagCompound == null || !stackTagCompound.getBoolean("frypanKill")) {
return;
}
TAchievements.triggerAchievement(player, "tconstruct.dualConvenience");
}
}
}
@@ -3,17 +3,12 @@ package tconstruct.tools.inventory;
import net.minecraft.inventory.*;
import net.minecraft.item.ItemStack;
public class SlotPartBuilder extends Slot
{
public class SlotPartBuilder extends Slot {
public SlotPartBuilder(IInventory inv, int index, int posX, int posY)
{
public SlotPartBuilder(IInventory inv, int index, int posX, int posY) {
super(inv, index, posX, posY);
}
@Override
protected void onCrafting (ItemStack par1ItemStack, int par2)
{
}
protected void onCrafting(ItemStack par1ItemStack, int par2) {}
}
@@ -4,10 +4,8 @@ import net.minecraft.inventory.*;
import net.minecraft.item.ItemStack;
import tconstruct.library.util.IPattern;
public class SlotPattern extends Slot
{
public SlotPattern(IInventory builder, int par3, int par4, int par5)
{
public class SlotPattern extends Slot {
public SlotPattern(IInventory builder, int par3, int par4, int par5) {
super(builder, par3, par4, par5);
}
@@ -15,8 +13,7 @@ public class SlotPattern extends Slot
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
@Override
public boolean isItemValid (ItemStack stack)
{
public boolean isItemValid(ItemStack stack) {
return stack.getItem() instanceof IPattern;
}
}
}
@@ -9,16 +9,14 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;
import tconstruct.library.event.ToolCraftedEvent;
import tconstruct.library.modifier.IModifyable;
import tconstruct.tools.logic.ToolStationLogic;
public class SlotTool extends Slot
{
public class SlotTool extends Slot {
/** The player that is using the GUI where this slot resides. */
public EntityPlayer player;
Random random = new Random();
public SlotTool(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)
{
public SlotTool(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5) {
super(builder, par3, par4, par5);
this.player = entityplayer;
}
@@ -26,16 +24,14 @@ public class SlotTool extends Slot
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
public boolean isItemValid (ItemStack stack)
{
public boolean isItemValid(ItemStack stack) {
return false;
//return stack.getItem() instanceof ToolCore;
// return stack.getItem() instanceof ToolCore;
}
public void onPickupFromSlot (EntityPlayer par1EntityPlayer, ItemStack stack)
{
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack stack) {
this.onCrafting(stack);
//stack.setUnlocalizedName("\u00A7f" + toolName);
// stack.setUnlocalizedName("\u00A7f" + toolName);
super.onPickupFromSlot(par1EntityPlayer, stack);
}
@@ -43,38 +39,41 @@ public class SlotTool extends Slot
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
* internal count then calls onCrafting(item).
*/
protected void onCrafting (ItemStack stack, int par2)
{
//this.field_75228_b += par2;
protected void onCrafting(ItemStack stack, int par2) {
// this.field_75228_b += par2;
this.onCrafting(stack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
*/
protected void onCrafting (ItemStack stack)
{
if (stack.getItem() instanceof IModifyable)
{
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
protected void onCrafting(ItemStack stack) {
if (stack.getItem() instanceof IModifyable) {
NBTTagCompound tags =
stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null);
for (int i = 2; i <= 3; i++)
inventory.decrStackSize(i, 1);
for (int i = 2; i <= 3; i++) inventory.decrStackSize(i, 1);
ItemStack compare = inventory.getStackInSlot(1);
int amount = compare.getItem() instanceof IModifyable ? compare.stackSize : 1;
inventory.decrStackSize(1, amount);
if (!player.worldObj.isRemote && full)
player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "tinker:little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
player.worldObj.playSoundEffect(
player.posX,
player.posY,
player.posZ,
"tinker:little_saw",
1.0F,
(random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
MinecraftForge.EVENT_BUS.post(new ToolCraftedEvent(this.inventory, player, stack));
}
else
//Simply naming items
} else
// Simply naming items
{
int amount = inventory.getStackInSlot(1).stackSize;
inventory.decrStackSize(1, amount);
for(int i = 0; i < inventory.getSizeInventory(); i++) {
if(inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).getItem() == Items.name_tag) {
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (inventory.getStackInSlot(i) != null
&& inventory.getStackInSlot(i).getItem() == Items.name_tag) {
inventory.decrStackSize(i, 1);
break;
}
@@ -10,39 +10,37 @@ import net.minecraftforge.common.MinecraftForge;
import tconstruct.library.event.ToolCraftedEvent;
import tconstruct.library.modifier.IModifyable;
public class SlotToolForge extends SlotTool
{
public class SlotToolForge extends SlotTool {
/** The player that is using the GUI where this slot resides. */
Random random = new Random();
public SlotToolForge(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)
{
public SlotToolForge(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5) {
super(entityplayer, builder, par3, par4, par5);
}
protected void onCrafting (ItemStack stack)
{
if (stack.getItem() instanceof IModifyable)
{
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null || inventory.getStackInSlot(4) != null);
for (int i = 2; i <= 4; i++)
inventory.decrStackSize(i, 1);
protected void onCrafting(ItemStack stack) {
if (stack.getItem() instanceof IModifyable) {
NBTTagCompound tags =
stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
Boolean full = (inventory.getStackInSlot(2) != null
|| inventory.getStackInSlot(3) != null
|| inventory.getStackInSlot(4) != null);
for (int i = 2; i <= 4; i++) inventory.decrStackSize(i, 1);
ItemStack compare = inventory.getStackInSlot(1);
int amount = compare.getItem() instanceof IModifyable ? compare.stackSize : 1;
inventory.decrStackSize(1, amount);
if (!player.worldObj.isRemote && full)
player.worldObj.playAuxSFX(1021, (int) player.posX, (int) player.posY, (int) player.posZ, 0);
MinecraftForge.EVENT_BUS.post(new ToolCraftedEvent(this.inventory, player, stack));
}
else
//Simply naming items
} else
// Simply naming items
{
int amount = inventory.getStackInSlot(1).stackSize;
inventory.decrStackSize(1, amount);
for(int i = 0; i < inventory.getSizeInventory(); i++) {
if(inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).getItem() == Items.name_tag) {
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (inventory.getStackInSlot(i) != null
&& inventory.getStackInSlot(i).getItem() == Items.name_tag) {
inventory.decrStackSize(i, 1);
break;
}
@@ -12,79 +12,73 @@ import tconstruct.library.modifier.IModifyable;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.*;
public class ToolForgeContainer extends ToolStationContainer
{
public class ToolForgeContainer extends ToolStationContainer {
public ToolForgeContainer(InventoryPlayer inventoryplayer, ToolForgeLogic logic)
{
public ToolForgeContainer(InventoryPlayer inventoryplayer, ToolForgeLogic logic) {
super(inventoryplayer, logic);
}
@Override
public void initializeContainer (InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
{
public void initializeContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic) {
invPlayer = inventoryplayer;
this.logic = builderlogic;
toolSlot = new SlotToolForge(inventoryplayer.player, logic, 0, 225, 38);
this.addSlotToContainer(toolSlot);
slots = new Slot[] { new Slot(logic, 1, 167, 29), new Slot(logic, 2, 169, 29), new Slot(logic, 3, 167, 47), new Slot(logic, 4, 149, 47) };
slots = new Slot[] {
new Slot(logic, 1, 167, 29),
new Slot(logic, 2, 169, 29),
new Slot(logic, 3, 167, 47),
new Slot(logic, 4, 149, 47)
};
for (int iter = 0; iter < 4; iter++)
this.addSlotToContainer(slots[iter]);
for (int iter = 0; iter < 4; iter++) this.addSlotToContainer(slots[iter]);
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(
new Slot(inventoryplayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(inventoryplayer, column, 118 + column * 18, 142));
}
}
// posX and posY must be the same length
@Override
public void resetSlots (int[] posX, int[] posY)
{
public void resetSlots(int[] posX, int[] posY) {
inventorySlots.clear();
inventoryItemStacks.clear();
this.addSlotToContainer(toolSlot);
for (int iter = 0; iter < 4; iter++)
{
for (int iter = 0; iter < 4; iter++) {
slots[iter].xDisplayPosition = posX[iter] + 111;
slots[iter].yDisplayPosition = posY[iter] + 1;
addSlotToContainer(slots[iter]);
}
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(new Slot(invPlayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(invPlayer, column, 118 + column * 18, 142));
}
}
@Override
protected void craftTool (ItemStack stack)
{
if (stack.getItem() instanceof IModifyable)
{
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
Boolean full = (logic.getStackInSlot(2) != null || logic.getStackInSlot(3) != null || logic.getStackInSlot(4) != null);
for (int i = 2; i <= 4; i++)
logic.decrStackSize(i, 1);
protected void craftTool(ItemStack stack) {
if (stack.getItem() instanceof IModifyable) {
NBTTagCompound tags =
stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
Boolean full = (logic.getStackInSlot(2) != null
|| logic.getStackInSlot(3) != null
|| logic.getStackInSlot(4) != null);
for (int i = 2; i <= 4; i++) logic.decrStackSize(i, 1);
ItemStack compare = logic.getStackInSlot(1);
int amount = compare.getItem() instanceof IModifyable ? compare.stackSize : 1;
logic.decrStackSize(1, amount);
@@ -92,17 +86,17 @@ public class ToolForgeContainer extends ToolStationContainer
if (!player.worldObj.isRemote && full)
player.worldObj.playAuxSFX(1021, (int) player.posX, (int) player.posY, (int) player.posZ, 0);
MinecraftForge.EVENT_BUS.post(new ToolCraftedEvent(this.logic, player, stack));
}
else
//Simply naming items
} else
// Simply naming items
{
ItemStack stack2 = logic.getStackInSlot(1);
int amount = logic.getStackInSlot(1).stackSize;
logic.decrStackSize(1, amount);
if(!ToolStationLogic.canRename(stack2.getTagCompound(), stack2)) {
for(int i = 0; i < logic.getSizeInventory(); i++) {
if(logic.getStackInSlot(i) != null && logic.getStackInSlot(i).getItem() == Items.name_tag) {
if (!ToolStationLogic.canRename(stack2.getTagCompound(), stack2)) {
for (int i = 0; i < logic.getSizeInventory(); i++) {
if (logic.getStackInSlot(i) != null
&& logic.getStackInSlot(i).getItem() == Items.name_tag) {
logic.decrStackSize(i, 1);
break;
}
@@ -112,11 +106,9 @@ public class ToolForgeContainer extends ToolStationContainer
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
public boolean canInteractWith(EntityPlayer entityplayer) {
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolForge && block != TinkerTools.craftingSlabWood)
return false;
if (block != TinkerTools.toolForge && block != TinkerTools.craftingSlabWood) return false;
return logic.isUseableByPlayer(entityplayer);
}
}
@@ -14,119 +14,98 @@ import tconstruct.smeltery.inventory.ActiveContainer;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.ToolStationLogic;
public class ToolStationContainer extends ActiveContainer
{
public class ToolStationContainer extends ActiveContainer {
public InventoryPlayer invPlayer;
public ToolStationLogic logic;
public Slot[] slots;
public SlotTool toolSlot;
public Random random = new Random();
public ToolStationContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
{
public ToolStationContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic) {
initializeContainer(inventoryplayer, builderlogic);
}
public void initializeContainer (InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
{
public void initializeContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic) {
invPlayer = inventoryplayer;
logic = builderlogic;
toolSlot = new SlotTool(inventoryplayer.player, builderlogic, 0, 225, 38);
this.addSlotToContainer(toolSlot);
slots = new Slot[] { new Slot(builderlogic, 1, 167, 29), new Slot(builderlogic, 2, 149, 38), new Slot(builderlogic, 3, 167, 47) };
slots = new Slot[] {
new Slot(builderlogic, 1, 167, 29), new Slot(builderlogic, 2, 149, 38), new Slot(builderlogic, 3, 167, 47)
};
for (int iter = 0; iter < 3; iter++)
this.addSlotToContainer(slots[iter]);
for (int iter = 0; iter < 3; iter++) this.addSlotToContainer(slots[iter]);
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(
new Slot(inventoryplayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(inventoryplayer, column, 118 + column * 18, 142));
}
}
// posX and posY must be the same length
public void resetSlots (int[] posX, int[] posY)
{
public void resetSlots(int[] posX, int[] posY) {
/* Station inventory */
inventorySlots.clear();
inventoryItemStacks.clear();
this.addSlotToContainer(toolSlot);
for (int iter = 0; iter < 3; iter++)
{
for (int iter = 0; iter < 3; iter++) {
slots[iter].xDisplayPosition = posX[iter] + 111;
slots[iter].yDisplayPosition = posY[iter] + 1;
addSlotToContainer(slots[iter]);
}
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(new Slot(invPlayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(invPlayer, column, 118 + column * 18, 142));
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
public boolean canInteractWith(EntityPlayer entityplayer) {
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood) return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
if (slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (slotID == 0)
{
if (!this.mergeCraftedStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true, player))
{
if (slotID < logic.getSizeInventory()) {
if (slotID == 0) {
if (!this.mergeCraftedStack(
slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true, player)) {
return null;
}
}
else if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
} else if (!this.mergeItemStack(
slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
}
else if (!this.mergeItemStack(slotStack, 1, logic.getSizeInventory(), false))
{
} else if (!this.mergeItemStack(slotStack, 1, logic.getSizeInventory(), false)) {
return null;
}
if (slotStack.stackSize == 0)
{
if (slotStack.stackSize == 0) {
slot.putStack((ItemStack) null);
}
else
{
} else {
slot.onSlotChanged();
}
}
@@ -134,32 +113,36 @@ public class ToolStationContainer extends ActiveContainer
return stack;
}
protected void craftTool (ItemStack stack)
{
if (stack.getItem() instanceof IModifyable)
{
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
protected void craftTool(ItemStack stack) {
if (stack.getItem() instanceof IModifyable) {
NBTTagCompound tags =
stack.getTagCompound().getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
Boolean full = (logic.getStackInSlot(2) != null || logic.getStackInSlot(3) != null);
for (int i = 2; i <= 3; i++)
logic.decrStackSize(i, 1);
for (int i = 2; i <= 3; i++) logic.decrStackSize(i, 1);
ItemStack compare = logic.getStackInSlot(1);
int amount = compare.getItem() instanceof IModifyable ? compare.stackSize : 1;
logic.decrStackSize(1, amount);
EntityPlayer player = invPlayer.player;
if (!player.worldObj.isRemote && full)
player.worldObj.playSoundEffect(logic.xCoord, logic.yCoord, logic.zCoord, "tinker:little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
player.worldObj.playSoundEffect(
logic.xCoord,
logic.yCoord,
logic.zCoord,
"tinker:little_saw",
1.0F,
(random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
MinecraftForge.EVENT_BUS.post(new ToolCraftedEvent(this.logic, player, stack));
}
else
//Simply naming items
} else
// Simply naming items
{
ItemStack stack2 = logic.getStackInSlot(1);
int amount = logic.getStackInSlot(1).stackSize;
logic.decrStackSize(1, amount);
if(!ToolStationLogic.canRename(stack2.getTagCompound(), stack2)) {
for(int i = 0; i < logic.getSizeInventory(); i++) {
if(logic.getStackInSlot(i) != null && logic.getStackInSlot(i).getItem() == Items.name_tag) {
if (!ToolStationLogic.canRename(stack2.getTagCompound(), stack2)) {
for (int i = 0; i < logic.getSizeInventory(); i++) {
if (logic.getStackInSlot(i) != null
&& logic.getStackInSlot(i).getItem() == Items.name_tag) {
logic.decrStackSize(i, 1);
break;
}
@@ -168,37 +151,30 @@ public class ToolStationContainer extends ActiveContainer
}
}
protected boolean mergeCraftedStack (ItemStack stack, int slotsStart, int slotsTotal, boolean playerInventory, EntityPlayer player)
{
protected boolean mergeCraftedStack(
ItemStack stack, int slotsStart, int slotsTotal, boolean playerInventory, EntityPlayer player) {
boolean failedToMerge = false;
int slotIndex = slotsStart;
if (playerInventory)
{
if (playerInventory) {
slotIndex = slotsTotal - 1;
}
Slot otherInventorySlot;
ItemStack copyStack = null;
if (stack.stackSize > 0)
{
if (playerInventory)
{
if (stack.stackSize > 0) {
if (playerInventory) {
slotIndex = slotsTotal - 1;
}
else
{
} else {
slotIndex = slotsStart;
}
while (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart)
{
while (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart) {
otherInventorySlot = (Slot) this.inventorySlots.get(slotIndex);
copyStack = otherInventorySlot.getStack();
if (copyStack == null)
{
if (copyStack == null) {
craftTool(stack);
otherInventorySlot.putStack(stack.copy());
otherInventorySlot.onSlotChanged();
@@ -207,12 +183,9 @@ public class ToolStationContainer extends ActiveContainer
break;
}
if (playerInventory)
{
if (playerInventory) {
--slotIndex;
}
else
{
} else {
++slotIndex;
}
}
@@ -5,23 +5,21 @@ import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
public class CraftingSlabItemBlock extends MultiItemBlock
{
public static final String blockTypes[] = { "tile.CraftingStation", "Crafter", "Parts", "PatternShaper", "PatternChest", "tile.ToolForge" };
public class CraftingSlabItemBlock extends MultiItemBlock {
public static final String blockTypes[] = {
"tile.CraftingStation", "Crafter", "Parts", "PatternShaper", "PatternChest", "tile.ToolForge"
};
public CraftingSlabItemBlock(Block b)
{
public CraftingSlabItemBlock(Block b) {
super(b, "ToolStation", blockTypes);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public String getUnlocalizedName (ItemStack itemstack)
{
public String getUnlocalizedName(ItemStack itemstack) {
int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, this.blockTypes.length - 1);
if (pos == 0 || pos == 5)
{
if (pos == 0 || pos == 5) {
return this.blockTypes[pos];
}
return super.getUnlocalizedName(itemstack);
@@ -8,12 +8,27 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class MultiBrickFancyItem extends MultiItemBlock
{
static String blockTypes[] = { "obsidian", "sandstone", "netherrack", "stone.refined", "iron", "gold", "lapis", "diamond", "redstone", "bone", "slime", "blueslime", "endstone", "obsidian.ingot", "stone", "stone.road" };
public class MultiBrickFancyItem extends MultiItemBlock {
static String blockTypes[] = {
"obsidian",
"sandstone",
"netherrack",
"stone.refined",
"iron",
"gold",
"lapis",
"diamond",
"redstone",
"bone",
"slime",
"blueslime",
"endstone",
"obsidian.ingot",
"stone",
"stone.road"
};
public MultiBrickFancyItem(Block b)
{
public MultiBrickFancyItem(Block b) {
super(b, "block.fancybrick", blockTypes);
setMaxDamage(0);
setHasSubtypes(true);
@@ -21,25 +36,23 @@ public class MultiBrickFancyItem extends MultiItemBlock
@Override
@SideOnly(Side.CLIENT)
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
{
switch (stack.getItemDamage())
{
case 5:
case 6:
list.add(StatCollector.translateToLocal("fancybrick1.tooltip"));
break;
case 7:
list.add(StatCollector.translateToLocal("fancybrick2.tooltip"));
break;
case 8:
list.add(StatCollector.translateToLocal("fancybrick3.tooltip"));
list.add(StatCollector.translateToLocal("fancybrick4.tooltip"));
break;
case 10:
case 11:
list.add(StatCollector.translateToLocal("fancybrick5.tooltip"));
break;
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
switch (stack.getItemDamage()) {
case 5:
case 6:
list.add(StatCollector.translateToLocal("fancybrick1.tooltip"));
break;
case 7:
list.add(StatCollector.translateToLocal("fancybrick2.tooltip"));
break;
case 8:
list.add(StatCollector.translateToLocal("fancybrick3.tooltip"));
list.add(StatCollector.translateToLocal("fancybrick4.tooltip"));
break;
case 10:
case 11:
list.add(StatCollector.translateToLocal("fancybrick5.tooltip"));
break;
}
}
}
@@ -8,12 +8,27 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class MultiBrickItem extends MultiItemBlock
{
static String blockTypes[] = { "obsidian", "sandstone", "netherrack", "stone.refined", "iron", "gold", "lapis", "diamond", "redstone", "bone", "slime", "blueslime", "endstone", "obsidian.ingot", "stone.road", "stone.refined.road" };
public class MultiBrickItem extends MultiItemBlock {
static String blockTypes[] = {
"obsidian",
"sandstone",
"netherrack",
"stone.refined",
"iron",
"gold",
"lapis",
"diamond",
"redstone",
"bone",
"slime",
"blueslime",
"endstone",
"obsidian.ingot",
"stone.road",
"stone.refined.road"
};
public MultiBrickItem(Block b)
{
public MultiBrickItem(Block b) {
super(b, "block.brick", blockTypes);
setMaxDamage(0);
setHasSubtypes(true);
@@ -21,25 +36,23 @@ public class MultiBrickItem extends MultiItemBlock
@Override
@SideOnly(Side.CLIENT)
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
{
switch (stack.getItemDamage())
{
case 5:
case 6:
list.add(StatCollector.translateToLocal("brick1.tooltip"));
break;
case 7:
list.add(StatCollector.translateToLocal("brick2.tooltip"));
break;
case 8:
list.add(StatCollector.translateToLocal("brick3.tooltip"));
list.add(StatCollector.translateToLocal("brick4.tooltip"));
break;
case 10:
case 11:
list.add(StatCollector.translateToLocal("brick5.tooltip"));
break;
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
switch (stack.getItemDamage()) {
case 5:
case 6:
list.add(StatCollector.translateToLocal("brick1.tooltip"));
break;
case 7:
list.add(StatCollector.translateToLocal("brick2.tooltip"));
break;
case 8:
list.add(StatCollector.translateToLocal("brick3.tooltip"));
list.add(StatCollector.translateToLocal("brick4.tooltip"));
break;
case 10:
case 11:
list.add(StatCollector.translateToLocal("brick5.tooltip"));
break;
}
}
}
@@ -4,10 +4,18 @@ import mantle.blocks.abstracts.MultiItemBlock;
import net.minecraft.block.Block;
public class MultiBrickMetalItem extends MultiItemBlock {
static String blockTypes[] = { "brick.alumite", "brick.ardite", "brick.cobalt", "brick.manyullyn", "fancybrick.alumite", "fancybrick.ardite", "fancybrick.cobalt", "fancybrick.manyullyn" };
static String blockTypes[] = {
"brick.alumite",
"brick.ardite",
"brick.cobalt",
"brick.manyullyn",
"fancybrick.alumite",
"fancybrick.ardite",
"fancybrick.cobalt",
"fancybrick.manyullyn"
};
public MultiBrickMetalItem(Block b)
{
public MultiBrickMetalItem(Block b) {
super(b, "block", blockTypes);
setMaxDamage(0);
setHasSubtypes(true);
@@ -3,12 +3,26 @@ package tconstruct.tools.itemblocks;
import mantle.blocks.abstracts.MultiItemBlock;
import net.minecraft.block.Block;
public class ToolStationItemBlock extends MultiItemBlock
{
public static final String blockTypes[] = { "Crafter", "Parts", "Parts", "Parts", "Parts", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternShaper", "PatternShaper", "PatternShaper", "PatternShaper", "CastingTable" };
public class ToolStationItemBlock extends MultiItemBlock {
public static final String blockTypes[] = {
"Crafter",
"Parts",
"Parts",
"Parts",
"Parts",
"PatternChest",
"PatternChest",
"PatternChest",
"PatternChest",
"PatternChest",
"PatternShaper",
"PatternShaper",
"PatternShaper",
"PatternShaper",
"CastingTable"
};
public ToolStationItemBlock(Block b)
{
public ToolStationItemBlock(Block b) {
super(b, "ToolStation", blockTypes);
setMaxDamage(0);
setHasSubtypes(true);
@@ -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);
}
}
}
@@ -11,86 +11,69 @@ import net.minecraft.world.World;
* 0: Battlesign item
*/
public class BattlesignLogic extends EquipLogic
{
public class BattlesignLogic extends EquipLogic {
protected String[] text;
public BattlesignLogic()
{
public BattlesignLogic() {
super(1);
}
@Override
public String getDefaultName ()
{
public String getDefaultName() {
return "decoration.battlesign";
}
@Override
/* NBT */
public void readFromNBT (NBTTagCompound tags)
{
public void readFromNBT(NBTTagCompound tags) {
super.readFromNBT(tags);
text = new String[tags.getInteger("lineCount")];
for (int i = 0; i < text.length; i++)
{
for (int i = 0; i < text.length; i++) {
text[i] = tags.getString("line" + i);
}
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
public void writeToNBT(NBTTagCompound tags) {
super.writeToNBT(tags);
if (text == null)
{
if (text == null) {
text = new String[0];
}
tags.setInteger("lineCount", text.length);
for (int i = 0; i < text.length; i++)
{
for (int i = 0; i < text.length; i++) {
tags.setString("line" + i, text[i]);
}
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return null; //Not a normal gui block
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
return null; // Not a normal gui block
}
@Override
public String getInventoryName ()
{
public String getInventoryName() {
return null;
}
@Override
public void openInventory ()
{
}
public void openInventory() {}
@Override
public void closeInventory ()
{
}
public void closeInventory() {}
public void setText (String[] text)
{
public void setText(String[] text) {
this.text = text;
}
public String[] getText ()
{
public String[] getText() {
return text;
}
@Override
public S35PacketUpdateTileEntity getDescriptionPacket ()
{
public S35PacketUpdateTileEntity getDescriptionPacket() {
NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
@@ -99,8 +82,7 @@ public class BattlesignLogic extends EquipLogic
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt)
{
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g());
}
}
}
@@ -1,5 +1,6 @@
package tconstruct.tools.logic;
import java.lang.ref.WeakReference;
import mantle.blocks.abstracts.InventoryLogic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -15,8 +16,6 @@ import net.minecraftforge.common.util.ForgeDirection;
import tconstruct.tools.inventory.CraftingStationContainer;
import tconstruct.util.config.PHConstruct;
import java.lang.ref.WeakReference;
public class CraftingStationLogic extends InventoryLogic implements ISidedInventory {
public ForgeDirection chestDirection = ForgeDirection.UNKNOWN;
public int chestSize;
@@ -42,8 +41,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
@Override
public ItemStack decrStackSize(int slot, int quantity) {
if (slot == 0) {
for (int i = 1; i < getSizeInventory(); i++)
decrStackSize(i, 1);
for (int i = 1; i < getSizeInventory(); i++) decrStackSize(i, 1);
}
return super.decrStackSize(slot, quantity);
}
@@ -67,7 +65,9 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
for (final ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
final int xPos = x + dir.offsetX, yPos = y + dir.offsetY, zPos = z + dir.offsetZ;
final TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
if (!(tile instanceof IInventory) || (tile instanceof CraftingStationLogic) || isBlacklisted(tile.getClass())) continue;
if (!(tile instanceof IInventory)
|| (tile instanceof CraftingStationLogic)
|| isBlacklisted(tile.getClass())) continue;
final IInventory inv = (IInventory) tile;
@@ -82,13 +82,22 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
continue;
}
if(tile instanceof ISidedInventory && ((ISidedInventory)tile).getAccessibleSlotsFromSide(dir.getOpposite().ordinal()).length == 0) continue;
if (tile instanceof ISidedInventory
&& ((ISidedInventory) tile)
.getAccessibleSlotsFromSide(
dir.getOpposite().ordinal())
.length
== 0) continue;
if (chest == null && inv.isUseableByPlayer(inventoryplayer.player)) {
chest = new WeakReference<>(inv);
chestDirection = dir;
invColumns = 6;
chestSize = tile instanceof ISidedInventory ? ((ISidedInventory)tile).getAccessibleSlotsFromSide(dir.getOpposite().ordinal()).length : inv.getSizeInventory();
chestSize = tile instanceof ISidedInventory
? ((ISidedInventory) tile)
.getAccessibleSlotsFromSide(dir.getOpposite().ordinal())
.length
: inv.getSizeInventory();
if (tile instanceof TileEntityChest) {
checkForChest(world, xPos, yPos, zPos, 1, 0);
@@ -98,8 +107,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
}
slotCount = chestSize * (doubleChest != null ? 2 : 1);
invRows = (int) Math.ceil((double) slotCount / invColumns);
}
}
}
return new CraftingStationContainer(inventoryplayer, this, x, y, z);
@@ -108,7 +116,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
private boolean isBlacklisted(Class<? extends TileEntity> clazz) {
return PHConstruct.craftingStationBlacklist.contains(clazz.getName());
}
void checkForChest(World world, int x, int y, int z, int dx, int dz) {
TileEntity tile = world.getTileEntity(x + dx, y, z + dz);
if (tile instanceof TileEntityChest) {
@@ -116,11 +124,11 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
doubleFirst = dx + dz < 0;
}
}
public boolean isDoubleChest() {
return this.doubleChest != null;
}
public IInventory getFirstInventory() {
if (doubleFirst && doubleChest != null) {
return doubleChest.get();
@@ -130,7 +138,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
}
public IInventory getSecondInventory() {
if(!isDoubleChest()) return null;
if (!isDoubleChest()) return null;
if (doubleFirst) {
return chest.get();
@@ -154,8 +162,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
for (WeakReference<IInventory> ref : inventories) {
if (ref != null) {
IInventory inv = ref.get();
if (inv != null && !inv.isUseableByPlayer(player))
return false;
if (inv != null && !inv.isUseableByPlayer(player)) return false;
}
}
@@ -164,12 +171,12 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
@SuppressWarnings("rawtypes")
public WeakReference[] getInventories() {
return new WeakReference[]{this.chest, this.doubleChest, this.patternChest, this.furnace};
return new WeakReference[] {this.chest, this.doubleChest, this.patternChest, this.furnace};
}
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
return new int[]{};
return new int[] {};
}
@Override
@@ -12,57 +12,45 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
* 2-9: Food
*/
public abstract class EquipLogic extends InventoryLogic
{
public abstract class EquipLogic extends InventoryLogic {
public EquipLogic(int invSize)
{
public EquipLogic(int invSize) {
super(invSize);
}
public void setEquipmentItem (ItemStack stack)
{
public void setEquipmentItem(ItemStack stack) {
inventory[0] = stack.copy();
}
public boolean hasEquipmentItem ()
{
public boolean hasEquipmentItem() {
return inventory[0] != null;
}
public ItemStack getEquipmentItem ()
{
public ItemStack getEquipmentItem() {
return inventory[0];
}
@Override
public void setInventorySlotContents (int slot, ItemStack stack)
{
if (slot == 0)
{
public void setInventorySlotContents(int slot, ItemStack stack) {
if (slot == 0) {
return;
}
else
{
} else {
super.setInventorySlotContents(slot, stack);
}
}
@Override
public ItemStack getStackInSlot (int slot)
{
public ItemStack getStackInSlot(int slot) {
return slot != 0 ? inventory[slot] : null;
}
@Override
public boolean isStackInSlot (int slot)
{
public boolean isStackInSlot(int slot) {
return slot != 0 ? inventory[slot] != null : false;
}
@Override
public S35PacketUpdateTileEntity getDescriptionPacket ()
{
public S35PacketUpdateTileEntity getDescriptionPacket() {
NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
@@ -71,8 +59,7 @@ public abstract class EquipLogic extends InventoryLogic
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt)
{
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g());
}
}
@@ -20,51 +20,42 @@ import tconstruct.tools.inventory.FrypanContainer;
* 2-9: Food
*/
public class FrypanLogic extends EquipLogic implements IActiveLogic
{
public class FrypanLogic extends EquipLogic implements IActiveLogic {
boolean active;
public int fuel;
public int fuelGague;
public int progress;
public FrypanLogic()
{
public FrypanLogic() {
super(10);
active = false;
}
@Override
public String getDefaultName ()
{
public String getDefaultName() {
return "crafters.frypan";
}
@Override
public boolean getActive ()
{
public boolean getActive() {
return active;
}
@Override
public void setActive (boolean flag)
{
public void setActive(boolean flag) {
active = flag;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
/* Fuel gauge */
public int gaugeProgressScaled (int scale)
{
public int gaugeProgressScaled(int scale) {
return (progress * scale) / 1000;
}
public int gaugeFuelScaled (int scale)
{
if (fuelGague == 0)
{
public int gaugeFuelScaled(int scale) {
if (fuelGague == 0) {
fuelGague = fuel;
if (fuelGague == 0)
{
if (fuelGague == 0) {
fuelGague = 1000;
}
}
@@ -73,84 +64,65 @@ public class FrypanLogic extends EquipLogic implements IActiveLogic
/* Item cooking */
@Override
public void updateEntity ()
{
public void updateEntity() {
boolean burning = isBurning();
boolean updateInventory = false;
if (fuel <= 0 && canCook())
{
if (fuel <= 0 && canCook()) {
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]) * 2.5);
if (fuel > 0)
{
if (inventory[1].getItem().hasContainerItem(inventory[1])) //Fuel slot
if (fuel > 0) {
if (inventory[1].getItem().hasContainerItem(inventory[1])) // Fuel slot
{
inventory[1] = inventory[1].getItem().getContainerItem(inventory[1]);
}
else
{
} else {
inventory[1].stackSize--;
}
if (inventory[1].stackSize <= 0)
{
if (inventory[1].stackSize <= 0) {
inventory[1] = null;
}
updateInventory = true;
}
}
if (isBurning() && canCook())
{
if (isBurning() && canCook()) {
progress++;
if (progress >= 1000)
{
if (progress >= 1000) {
progress = 0;
cookItems();
updateInventory = true;
}
}
else
{
} else {
progress = 0;
}
if (fuel > 0)
{
if (fuel > 0) {
fuel--;
}
if (burning != isBurning())
{
if (burning != isBurning()) {
setActive(isBurning());
updateInventory = true;
}
if (updateInventory)
{
if (updateInventory) {
markDirty();
}
}
public void cookItems ()
{
if (!canCook())
return;
public void cookItems() {
if (!canCook()) return;
for (int id = 2; id < 10; id++) //Check every slot
for (int id = 2; id < 10; id++) // Check every slot
{
if (canCook())
{
if (canCook()) {
ItemStack result = getResultFor(inventory[id]);
if (result != null)
{
if (result != null) {
int ids = 2;
boolean placed = false;
while (ids < 10 && !placed) //Try to merge stacks first
while (ids < 10 && !placed) // Try to merge stacks first
{
if (inventory[ids] != null && inventory[ids].isItemEqual(result) && inventory[ids].stackSize < inventory[ids].getMaxStackSize())
{
if (inventory[ids].stackSize + result.stackSize <= inventory[ids].getMaxStackSize())
{
if (inventory[ids] != null
&& inventory[ids].isItemEqual(result)
&& inventory[ids].stackSize < inventory[ids].getMaxStackSize()) {
if (inventory[ids].stackSize + result.stackSize <= inventory[ids].getMaxStackSize()) {
inventory[ids].stackSize += result.stackSize;
placed = true;
}
else
{
} else {
int decrement = inventory[ids].getMaxStackSize() - inventory[ids].stackSize;
inventory[ids].stackSize = inventory[ids].getMaxStackSize();
result.stackSize -= decrement;
@@ -160,127 +132,101 @@ public class FrypanLogic extends EquipLogic implements IActiveLogic
}
ids = 2;
while (!placed && ids < 10) //Place remaining in slot
while (!placed && ids < 10) // Place remaining in slot
{
if (inventory[ids] == null)
{
if (inventory[ids] == null) {
inventory[ids] = result;
placed = true;
}
ids++;
}
if (placed)
decrStackSize(id, 1);
if (placed) decrStackSize(id, 1);
}
}
}
}
public boolean canCook ()
{
for (int id = 2; id < 10; id++)
{
if (inventory[id] == null) //Nothing here!
continue;
public boolean canCook() {
for (int id = 2; id < 10; id++) {
if (inventory[id] == null) // Nothing here!
continue;
ItemStack result = getResultFor(inventory[id]);
if (result == null) //Doesn't cook into anything
continue;
if (result == null) // Doesn't cook into anything
continue;
for (int slotid = 2; slotid < 10; slotid++)
{
if (inventory[slotid] == null)
return true;
else if (inventory[slotid].isItemEqual(result) && inventory[slotid].stackSize + result.stackSize <= inventory[slotid].getMaxStackSize())
for (int slotid = 2; slotid < 10; slotid++) {
if (inventory[slotid] == null) return true;
else if (inventory[slotid].isItemEqual(result)
&& inventory[slotid].stackSize + result.stackSize <= inventory[slotid].getMaxStackSize())
return true;
}
}
return false;
}
public boolean isBurning ()
{
public boolean isBurning() {
return fuel > 0;
}
public ItemStack getResultFor (ItemStack stack)
{
if (stack == null)
{
public ItemStack getResultFor(ItemStack stack) {
if (stack == null) {
return null;
}
else
{
} else {
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
if (result != null && result.getItem() instanceof ItemFood) //Only valid for food
return result.copy();
if (result != null && result.getItem() instanceof ItemFood) // Only valid for food
return result.copy();
return null;
}
}
public static int getItemBurnTime (ItemStack stack)
{
if (stack == null)
{
public static int getItemBurnTime(ItemStack stack) {
if (stack == null) {
return 0;
}
else
{
} else {
Item item = stack.getItem();
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null)
{
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null) {
Block block = BlockUtils.getBlockFromItem(item);
if (block == Blocks.wooden_slab)
{
if (block == Blocks.wooden_slab) {
return 150;
}
if (block == Blocks.log)
{
if (block == Blocks.log) {
return 2400;
}
if (block.getMaterial() == Material.wood)
{
if (block.getMaterial() == Material.wood) {
return 300;
}
}
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
return 200;
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
return 200;
if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD"))
return 200;
if (item == Items.stick)
return 100;
if (item == Items.coal)
return 800;
if (item == Items.lava_bucket)
return 20000;
if (new ItemStack(item).equals(new ItemStack(Blocks.sapling)))
return 100;
if (item == Items.blaze_rod)
return 2400;
if (item instanceof ItemTool
&& ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemSword
&& ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemHoe
&& ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.stick) return 100;
if (item == Items.coal) return 800;
if (item == Items.lava_bucket) return 20000;
if (new ItemStack(item).equals(new ItemStack(Blocks.sapling))) return 100;
if (item == Items.blaze_rod) return 2400;
return GameRegistry.getFuelValue(stack);
}
}
/* NBT */
public void readFromNBT (NBTTagCompound tags)
{
public void readFromNBT(NBTTagCompound tags) {
super.readFromNBT(tags);
active = tags.getBoolean("Active");
fuel = tags.getInteger("Fuel");
fuelGague = tags.getInteger("FuelGague");
}
public void writeToNBT (NBTTagCompound tags)
{
public void writeToNBT(NBTTagCompound tags) {
super.writeToNBT(tags);
tags.setBoolean("Active", active);
tags.setInteger("Fuel", fuel);
@@ -288,30 +234,23 @@ public class FrypanLogic extends EquipLogic implements IActiveLogic
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
return new FrypanContainer(inventoryplayer.player, this);
}
@Override
public String getInventoryName ()
{
public String getInventoryName() {
return getDefaultName();
}
@Override
public boolean hasCustomInventoryName ()
{
public boolean hasCustomInventoryName() {
return true;
}
@Override
public void openInventory ()
{
}
public void openInventory() {}
@Override
public void closeInventory ()
{
}
}
public void closeInventory() {}
}
@@ -27,55 +27,46 @@ import tconstruct.tools.inventory.FurnaceContainer;
* 3-16: Chest
*/
public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacingLogic, ISidedInventory
{
public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacingLogic, ISidedInventory {
boolean active = false;
public int fuel;
public int fuelGague;
public int progress;
public int fuelScale = 200;
byte direction;
private static final int[] slots_top = new int[] { 0 };
private static final int[] slots_bottom = new int[] { 2, 1 };
private static final int[] slots_sides = new int[] { 1 };
private static final int[] slots_top = new int[] {0};
private static final int[] slots_bottom = new int[] {2, 1};
private static final int[] slots_sides = new int[] {1};
public FurnaceLogic()
{
public FurnaceLogic() {
super(3);
}
@Override
public String getDefaultName ()
{
public String getDefaultName() {
return "container.furnace";
}
@Override
public boolean getActive ()
{
public boolean getActive() {
return active;
}
@Override
public void setActive (boolean flag)
{
public void setActive(boolean flag) {
active = flag;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
/* Fuel gauge */
public int gaugeProgressScaled (int scale)
{
public int gaugeProgressScaled(int scale) {
return (progress * scale) / fuelScale;
}
public int gaugeFuelScaled (int scale)
{
if (fuelGague == 0)
{
public int gaugeFuelScaled(int scale) {
if (fuelGague == 0) {
fuelGague = fuel;
if (fuelGague == 0)
{
if (fuelGague == 0) {
fuelGague = fuelScale;
}
}
@@ -84,175 +75,133 @@ public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacin
/* Item cooking */
@Override
public void updateEntity ()
{
public void updateEntity() {
boolean burning = isBurning();
boolean updateInventory = false;
if (fuel <= 0 && canSmelt())
{
if (fuel <= 0 && canSmelt()) {
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]));
if (fuel > 0)
{
if (fuel > 0) {
if (inventory[1].getItem().hasContainerItem()) // Fuel slot
{
inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem());
}
else
{
} else {
inventory[1].stackSize--;
}
if (inventory[1].stackSize <= 0)
{
if (inventory[1].stackSize <= 0) {
inventory[1] = null;
}
updateInventory = true;
}
}
if (isBurning() && canSmelt())
{
if (isBurning() && canSmelt()) {
progress++;
if (progress >= fuelScale)
{
if (progress >= fuelScale) {
progress = 0;
cookItems();
updateInventory = true;
}
}
else
{
} else {
progress = 0;
}
if (fuel > 0)
{
if (fuel > 0) {
fuel--;
}
if (burning != isBurning())
{
if (burning != isBurning()) {
setActive(isBurning());
updateInventory = true;
}
if (updateInventory)
{
if (updateInventory) {
markDirty();
}
}
public void cookItems ()
{
if (this.canSmelt())
{
public void cookItems() {
if (this.canSmelt()) {
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
if (this.inventory[2] == null)
{
if (this.inventory[2] == null) {
this.inventory[2] = itemstack.copy();
}
else if (this.inventory[2].isItemEqual(itemstack))
{
} else if (this.inventory[2].isItemEqual(itemstack)) {
inventory[2].stackSize += itemstack.stackSize;
}
--this.inventory[0].stackSize;
if (this.inventory[0].stackSize <= 0)
{
if (this.inventory[0].stackSize <= 0) {
this.inventory[0] = null;
}
}
}
public boolean canSmelt ()
{
public boolean canSmelt() {
if (inventory[0] == null) // Nothing here!
return false;
else
{
return false;
else {
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
if (itemstack == null)
return false;
if (this.inventory[2] == null)
return true;
if (!this.inventory[2].isItemEqual(itemstack))
return false;
if (itemstack == null) return false;
if (this.inventory[2] == null) return true;
if (!this.inventory[2].isItemEqual(itemstack)) return false;
int result = inventory[2].stackSize + itemstack.stackSize;
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
}
}
public boolean isBurning ()
{
public boolean isBurning() {
return fuel > 0;
}
public ItemStack getResultFor (ItemStack stack)
{
public ItemStack getResultFor(ItemStack stack) {
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
if (result != null) // Only valid for food
return result.copy();
return result.copy();
return null;
}
public static int getItemBurnTime (ItemStack stack)
{
if (stack == null)
{
public static int getItemBurnTime(ItemStack stack) {
if (stack == null) {
return 0;
}
else
{
} else {
Item item = stack.getItem();
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null)
{
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null) {
Block block = BlockUtils.getBlockFromItem(item);
if (block == Blocks.wooden_slab)
{
if (block == Blocks.wooden_slab) {
return 150;
}
if (block == Blocks.log)
{
if (block == Blocks.log) {
return 1200;
}
if (block.getMaterial() == Material.wood)
{
if (block.getMaterial() == Material.wood) {
return 300;
}
if (block == Blocks.coal_block)
{
if (block == Blocks.coal_block) {
return 16000;
}
}
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
return 200;
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
return 200;
if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD"))
return 200;
if (item == Items.stick)
return 100;
if (item == Items.coal)
return 1600;
if (item == Items.lava_bucket)
return 20000;
if (item == new ItemStack(Blocks.sapling).getItem())
return 100;
if (item == Items.blaze_rod)
return 2400;
if (item instanceof ItemTool
&& ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemSword
&& ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemHoe
&& ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.stick) return 100;
if (item == Items.coal) return 1600;
if (item == Items.lava_bucket) return 20000;
if (item == new ItemStack(Blocks.sapling).getItem()) return 100;
if (item == Items.blaze_rod) return 2400;
return GameRegistry.getFuelValue(stack);
}
}
/* NBT */
@Override
public void readFromNBT (NBTTagCompound tags)
{
public void readFromNBT(NBTTagCompound tags) {
super.readFromNBT(tags);
active = tags.getBoolean("Active");
fuel = tags.getInteger("Fuel");
@@ -261,140 +210,118 @@ public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacin
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
public void writeToNBT(NBTTagCompound tags) {
super.writeToNBT(tags);
tags.setInteger("Fuel", fuel);
tags.setInteger("FuelGague", fuelGague);
writeNetworkNBT(tags);
}
public void readNetworkNBT (NBTTagCompound tags)
{
public void readNetworkNBT(NBTTagCompound tags) {
active = tags.getBoolean("Active");
direction = tags.getByte("Direction");
}
public void writeNetworkNBT (NBTTagCompound tags)
{
public void writeNetworkNBT(NBTTagCompound tags) {
tags.setBoolean("Active", active);
tags.setByte("Direction", direction);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeNetworkNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
{
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readNetworkNBT(packet.func_148857_g());
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
return new FurnaceContainer(inventoryplayer, this);
}
@Override
public byte getRenderDirection ()
{
public byte getRenderDirection() {
return direction;
}
@Override
public ForgeDirection getForgeDirection ()
{
public ForgeDirection getForgeDirection() {
return ForgeDirection.VALID_DIRECTIONS[direction];
}
@Override
@Deprecated
public void setDirection (int side)
{
public void setDirection(int side) {
// Nope!
}
@Override
@Deprecated
public void setDirection (float yaw, float pitch, EntityLivingBase player)
{
public void setDirection(float yaw, float pitch, EntityLivingBase player) {
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
switch (facing)
{
case 0:
direction = 2;
break;
switch (facing) {
case 0:
direction = 2;
break;
case 1:
direction = 5;
break;
case 1:
direction = 5;
break;
case 2:
direction = 3;
break;
case 2:
direction = 3;
break;
case 3:
direction = 4;
break;
case 3:
direction = 4;
break;
}
}
@Override
public String getInventoryName ()
{
public String getInventoryName() {
return getDefaultName();
}
@Override
public boolean hasCustomInventoryName ()
{
public boolean hasCustomInventoryName() {
return false;
}
@Override
public void openInventory ()
{
}
public void openInventory() {}
@Override
public void closeInventory ()
{
}
public void closeInventory() {}
public static boolean isItemFuel (ItemStack par0ItemStack)
{
public static boolean isItemFuel(ItemStack par0ItemStack) {
return getItemBurnTime(par0ItemStack) > 0;
}
@Override
public boolean isItemValidForSlot (int par1, ItemStack par2ItemStack)
{
public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) {
return par1 == 2 ? false : (par1 == 1 ? isItemFuel(par2ItemStack) : true);
}
@Override
public int[] getAccessibleSlotsFromSide (int par1)
{
public int[] getAccessibleSlotsFromSide(int par1) {
return par1 == 0 ? slots_bottom : (par1 == 1 ? slots_top : slots_sides);
}
@Override
public boolean canInsertItem (int par1, ItemStack par2ItemStack, int par3)
{
public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) {
return this.isItemValidForSlot(par1, par2ItemStack);
}
@Override
public boolean canExtractItem (int par1, ItemStack par2ItemStack, int par3)
{
public boolean canExtractItem(int par1, ItemStack par2ItemStack, int par3) {
return par3 != 0 || par1 != 1 || par2ItemStack.getItem() == Items.bucket;
}
}
@@ -11,33 +11,26 @@ import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.util.IPattern;
import tconstruct.tools.inventory.*;
public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
{
public class PartBuilderLogic extends InventoryLogic implements ISidedInventory {
boolean craftedTop;
boolean craftedBottom;
public PartBuilderLogic()
{
public PartBuilderLogic() {
super(10);
craftedTop = false;
craftedBottom = false;
}
@Override
public String getDefaultName ()
{
public String getDefaultName() {
return "toolstation.parts";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
for (int xPos = x - 1; xPos <= x + 1; xPos++)
{
for (int zPos = z - 1; zPos <= z + 1; zPos++)
{
for (int yPos = y - 1; yPos <= y + 1; yPos++)
{
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
for (int xPos = x - 1; xPos <= x + 1; xPos++) {
for (int zPos = z - 1; zPos <= z + 1; zPos++) {
for (int yPos = y - 1; yPos <= y + 1; yPos++) {
TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
if (tile != null && tile instanceof PatternChestLogic && (x == xPos || z == zPos))
return new PartCrafterChestContainer(inventoryplayer, this, (PatternChestLogic) tile);
@@ -48,172 +41,132 @@ public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
}
@Override
public boolean canDropInventorySlot (int slot)
{
public boolean canDropInventorySlot(int slot) {
return slot <= 3; // 0-3 = only drop input slots
}
//Called when emptying a slot, not when another item is placed in it
// Called when emptying a slot, not when another item is placed in it
@Override
public ItemStack decrStackSize (int slotID, int quantity)
{
public ItemStack decrStackSize(int slotID, int quantity) {
ItemStack returnStack = super.decrStackSize(slotID, quantity);
tryBuildPart(slotID);
return returnStack;
}
public void tryBuildPart (int slotID)
{
if (slotID == 4 || slotID == 5)
{
if (!craftedTop && inventory[0] != null)
{
public void tryBuildPart(int slotID) {
if (slotID == 4 || slotID == 5) {
if (!craftedTop && inventory[0] != null) {
int value = PatternBuilder.instance.getPartValue(inventory[2]);
IPattern item = (IPattern) inventory[0].getItem();
int cost = item != null ? item.getPatternCost(inventory[0]) : 0;
if (value > 0 && cost > 0)
{
if (value > 0 && cost > 0) {
int decrease = cost / value;
if (cost % value != 0)
decrease++;
super.decrStackSize(2, decrease); //Call super to avoid crafting again
if (cost % value != 0) decrease++;
super.decrStackSize(2, decrease); // Call super to avoid crafting again
}
}
if (inventory[4] != null || inventory[5] != null)
craftedTop = true;
else
craftedTop = false;
if (inventory[4] != null || inventory[5] != null) craftedTop = true;
else craftedTop = false;
}
if (!craftedTop)
buildTopPart();
if (!craftedTop) buildTopPart();
if (slotID == 6 || slotID == 7)
{
if (!craftedBottom && inventory[1] != null)
{
if (slotID == 6 || slotID == 7) {
if (!craftedBottom && inventory[1] != null) {
int value = PatternBuilder.instance.getPartValue(inventory[3]);
IPattern item = (IPattern) inventory[1].getItem();
int cost = item != null ? item.getPatternCost(inventory[1]) : 0;
if (value > 0 && cost > 0)
{
if (value > 0 && cost > 0) {
int decrease = cost / value;
if (cost % value != 0)
decrease++;
super.decrStackSize(3, decrease); //Call super to avoid crafting again
if (cost % value != 0) decrease++;
super.decrStackSize(3, decrease); // Call super to avoid crafting again
}
}
if (inventory[6] != null || inventory[7] != null)
craftedBottom = true;
else
craftedBottom = false;
if (inventory[6] != null || inventory[7] != null) craftedBottom = true;
else craftedBottom = false;
}
if (!craftedBottom)
buildBottomPart();
if (!craftedBottom) buildBottomPart();
}
//Called when a slot has something placed into it.
// Called when a slot has something placed into it.
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
public void setInventorySlotContents(int slot, ItemStack itemstack) {
super.setInventorySlotContents(slot, itemstack);
if ((slot == 0 || slot == 2) && !craftedTop)
buildTopPart();
if ((slot == 1 || slot == 3) && !craftedBottom)
buildBottomPart();
if ((slot == 0 || slot == 2) && !craftedTop) buildTopPart();
if ((slot == 1 || slot == 3) && !craftedBottom) buildBottomPart();
}
void buildTopPart ()
{
void buildTopPart() {
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[2], inventory[0], inventory[1]);
if (parts != null)
{
if (parts != null) {
inventory[4] = parts[0];
inventory[5] = parts[1];
}
else
{
} else {
inventory[4] = inventory[5] = null;
}
}
void buildBottomPart ()
{
void buildBottomPart() {
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[1], inventory[0]);
if (parts != null)
{
if (parts != null) {
inventory[6] = parts[0];
inventory[7] = parts[1];
}
else
{
} else {
inventory[6] = inventory[7] = null;
}
}
/* NBT */
@Override
public void readFromNBT (NBTTagCompound tags)
{
public void readFromNBT(NBTTagCompound tags) {
super.readFromNBT(tags);
craftedTop = tags.getBoolean("CraftedTop");
craftedBottom = tags.getBoolean("CraftedBottom");
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
public void writeToNBT(NBTTagCompound tags) {
super.writeToNBT(tags);
tags.setBoolean("CraftedTop", craftedTop);
tags.setBoolean("CraftedBottom", craftedBottom);
}
@Override
public int[] getAccessibleSlotsFromSide (int side)
{
public int[] getAccessibleSlotsFromSide(int side) {
return new int[0];
}
@Override
public boolean canInsertItem (int i, ItemStack itemstack, int j)
{
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
return false;
}
@Override
public boolean canExtractItem (int i, ItemStack itemstack, int j)
{
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return false;
}
@Override
public String getInventoryName ()
{
public String getInventoryName() {
return getDefaultName();
}
@Override
public boolean hasCustomInventoryName ()
{
public boolean hasCustomInventoryName() {
return false;
}
@Override
public void openInventory ()
{
}
public void openInventory() {}
@Override
public void closeInventory ()
{
}
public void closeInventory() {}
@Override
public boolean canUpdate ()
{
public boolean canUpdate() {
return false;
}
}
}
@@ -8,40 +8,33 @@ import net.minecraft.world.World;
import tconstruct.library.util.IPattern;
import tconstruct.tools.inventory.PatternChestContainer;
public class PatternChestLogic extends InventoryLogic
{
public PatternChestLogic()
{
public class PatternChestLogic extends InventoryLogic {
public PatternChestLogic() {
super(30);
}
@Override
public boolean canUpdate ()
{
public boolean canUpdate() {
return false;
}
@Override
public String getDefaultName ()
{
public String getDefaultName() {
return "toolstation.patternholder";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
return new PatternChestContainer(inventoryplayer, this);
}
@Override
public String getInventoryName ()
{
public String getInventoryName() {
return getDefaultName();
}
@Override
public boolean hasCustomInventoryName ()
{
public boolean hasCustomInventoryName() {
return true;
}
@@ -51,12 +44,8 @@ public class PatternChestLogic extends InventoryLogic
}
@Override
public void openInventory ()
{
}
public void openInventory() {}
@Override
public void closeInventory ()
{
}
}
public void closeInventory() {}
}
@@ -10,30 +10,25 @@ import net.minecraft.world.World;
import tconstruct.library.crafting.StencilBuilder;
import tconstruct.tools.inventory.PatternShaperContainer;
public class StencilTableLogic extends InventoryLogic implements ISidedInventory
{
public class StencilTableLogic extends InventoryLogic implements ISidedInventory {
private ItemStack selectedStack;
public StencilTableLogic()
{
public StencilTableLogic() {
super(2);
}
@Override
public boolean canUpdate ()
{
public boolean canUpdate() {
return false;
}
@Override
public String getDefaultName ()
{
public String getDefaultName() {
return "toolstation.PatternShaper";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
return new PatternShaperContainer(inventoryplayer, this);
}
@@ -45,67 +40,49 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
super.onInventoryChanged();
}*/
public void setSelectedPattern (ItemStack stack)
{
public void setSelectedPattern(ItemStack stack) {
selectedStack = stack;
this.setInventorySlotContents(1, stack);
}
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
public void setInventorySlotContents(int slot, ItemStack itemstack) {
super.setInventorySlotContents(slot, itemstack);
if (slot == 0) {
if (itemstack != null && StencilBuilder.isBlank(itemstack))
{
if (itemstack != null && StencilBuilder.isBlank(itemstack)) {
super.setInventorySlotContents(1, selectedStack);
}
else if (itemstack!=null)
{
ItemStack cpy=itemstack.copy();
cpy.stackSize=1;
} else if (itemstack != null) {
ItemStack cpy = itemstack.copy();
cpy.stackSize = 1;
super.setInventorySlotContents(1, cpy);
}
else
{
super.setInventorySlotContents(1,null);
} else {
super.setInventorySlotContents(1, null);
}
}
}
@Override
public ItemStack decrStackSize (int slot, int quantity)
{
if (slot == 1)
{
public ItemStack decrStackSize(int slot, int quantity) {
if (slot == 1) {
super.decrStackSize(0, 1);
if (inventory[0] == null)
return super.decrStackSize(slot, quantity);
else
return inventory[1].copy();
}
else
{
if (inventory[0] == null) return super.decrStackSize(slot, quantity);
else return inventory[1].copy();
} else {
ItemStack ret = super.decrStackSize(slot, quantity);
if (inventory[0] == null)
super.decrStackSize(1, 1);
if (inventory[0] == null) super.decrStackSize(1, 1);
return ret;
}
}
public void altDecrStackSize (int slot, int quantity)
{
if (inventory[slot] != null)
{
if (inventory[slot].stackSize <= quantity)
{
public void altDecrStackSize(int slot, int quantity) {
if (inventory[slot] != null) {
if (inventory[slot].stackSize <= quantity) {
ItemStack stack = inventory[slot];
inventory[slot] = null;
return;
}
ItemStack split = inventory[slot].splitStack(quantity);
if (inventory[slot].stackSize == 0)
{
if (inventory[slot].stackSize == 0) {
inventory[slot] = null;
}
return;
@@ -113,51 +90,39 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
}
@Override
public boolean canDropInventorySlot (int slot)
{
if (slot == 0)
return true;
else
return false;
public boolean canDropInventorySlot(int slot) {
if (slot == 0) return true;
else return false;
}
@Override
public int[] getAccessibleSlotsFromSide (int side)
{
public int[] getAccessibleSlotsFromSide(int side) {
return new int[0];
}
@Override
public boolean canInsertItem (int i, ItemStack itemstack, int j)
{
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
return false;
}
@Override
public boolean canExtractItem (int i, ItemStack itemstack, int j)
{
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return false;
}
@Override
public String getInventoryName ()
{
public String getInventoryName() {
return StatCollector.translateToLocal("toolstation.PatternShaper");
}
@Override
public boolean hasCustomInventoryName ()
{
public boolean hasCustomInventoryName() {
return true;
}
@Override
public void closeInventory ()
{
}
public void closeInventory() {}
@Override
public void openInventory ()
{
}
}
public void openInventory() {}
}
@@ -11,62 +11,53 @@ import tconstruct.tools.inventory.ToolForgeContainer;
/* Simple class for storing items in the block
*/
public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory
{
public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory {
ItemStack previousTool;
String toolName;
public ToolForgeLogic()
{
public ToolForgeLogic() {
super(6);
toolName = "";
}
@Override
public String getDefaultName ()
{
public String getDefaultName() {
return "crafters.ToolForge";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
return new ToolForgeContainer(inventoryplayer, this);
}
@Override
public void buildTool (String name)
{
public void buildTool(String name) {
ItemStack output = null;
if (inventory[1] != null)
{
if (inventory[1].getItem() instanceof IModifyable) //Modify item
if (inventory[1] != null) {
if (inventory[1].getItem() instanceof IModifyable) // Modify item
{
if (inventory[2] == null && inventory[3] == null && inventory[4] == null)
output = inventory[1].copy();
else
{
output = ModifyBuilder.instance.modifyItem(inventory[1], new ItemStack[] { inventory[2], inventory[3], inventory[4] });
if (inventory[2] == null && inventory[3] == null && inventory[4] == null) output = inventory[1].copy();
else {
output = ModifyBuilder.instance.modifyItem(
inventory[1], new ItemStack[] {inventory[2], inventory[3], inventory[4]});
}
}
else
//Build new item
} else
// Build new item
{
toolName = name;
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name);
if (inventory[0] == null)
ItemStack tool =
ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name);
if (inventory[0] == null) output = tool;
else if (tool != null) {
// NBTTagCompound tags = tool.getTagCompound();
// if (!tags.getCompoundTag(((IModifyable) tool.getItem()).getBaseTagName()).hasKey("Built"))
// {
output = tool;
else if (tool != null)
{
//NBTTagCompound tags = tool.getTagCompound();
//if (!tags.getCompoundTag(((IModifyable) tool.getItem()).getBaseTagName()).hasKey("Built"))
//{
output = tool;
//}
// }
}
}
if (!name.equals("")) //Name item
output = tryRenameTool(output, name);
if (!name.equals("")) // Name item
output = tryRenameTool(output, name);
}
inventory[0] = output;
}
@@ -85,4 +76,4 @@ public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory
}
}
}*/
}
}
@@ -16,129 +16,105 @@ import tconstruct.tools.inventory.ToolStationContainer;
/* Simple class for storing items in the block
*/
public class ToolStationLogic extends InventoryLogic implements ISidedInventory
{
public class ToolStationLogic extends InventoryLogic implements ISidedInventory {
public ItemStack previousTool;
public String toolName;
public ToolStationLogic()
{
public ToolStationLogic() {
super(4);
toolName = "";
}
public ToolStationLogic(int slots)
{
public ToolStationLogic(int slots) {
super(slots);
toolName = "";
}
@Override
public boolean canDropInventorySlot (int slot)
{
if (slot == 0)
return false;
public boolean canDropInventorySlot(int slot) {
if (slot == 0) return false;
return true;
}
@Override
public ItemStack getStackInSlotOnClosing (int var1)
{
public ItemStack getStackInSlotOnClosing(int var1) {
return null;
}
@Override
public String getDefaultName ()
{
public String getDefaultName() {
return "crafters.ToolStation";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
return new ToolStationContainer(inventoryplayer, this);
}
@Override
public void markDirty ()
{
public void markDirty() {
buildTool(toolName);
if (this.worldObj != null)
{
if (this.worldObj != null) {
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
}
}
public void buildTool (String name)
{
public void buildTool(String name) {
ItemStack output = null;
if (inventory[1] != null)
{
if (inventory[1].getItem() instanceof IModifyable) //Modify item
if (inventory[1] != null) {
if (inventory[1].getItem() instanceof IModifyable) // Modify item
{
if (inventory[2] == null && inventory[3] == null)
output = inventory[1].copy();
else
{
output = ModifyBuilder.instance.modifyItem(inventory[1], new ItemStack[] { inventory[2], inventory[3] });
if (inventory[2] == null && inventory[3] == null) output = inventory[1].copy();
else {
output = ModifyBuilder.instance.modifyItem(
inventory[1], new ItemStack[] {inventory[2], inventory[3]});
}
}
else
//Build new item
} else
// Build new item
{
toolName = name;
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], name);
if (inventory[0] == null)
output = tool;
else if (tool != null)
{
if (inventory[0] == null) output = tool;
else if (tool != null) {
NBTTagCompound tags = tool.getTagCompound();
if (!tags.getCompoundTag(((IModifyable) tool.getItem()).getBaseTagName()).hasKey("Built"))
{
if (!tags.getCompoundTag(((IModifyable) tool.getItem()).getBaseTagName())
.hasKey("Built")) {
output = tool;
}
}
}
if (!name.equals("")) //Name item
output = tryRenameTool(output, name);
if (!name.equals("")) // Name item
output = tryRenameTool(output, name);
}
inventory[0] = output;
}
public void setToolname (String name)
{
public void setToolname(String name) {
toolName = name;
buildTool(name);
}
protected ItemStack tryRenameTool (ItemStack output, String name)
{
protected ItemStack tryRenameTool(ItemStack output, String name) {
ItemStack temp;
if (output != null)
temp = output;
else
temp = inventory[1].copy();
if (output != null) temp = output;
else temp = inventory[1].copy();
if (temp == null) {
return null; // output is null or not a tool :(
}
NBTTagCompound tags = temp.getTagCompound();
if (tags == null)
{
if (tags == null) {
tags = new NBTTagCompound();
temp.setTagCompound(tags);
}
NBTTagCompound display = null;
if (!(tags.hasKey("display")))
display = new NBTTagCompound();
else if (tags.getCompoundTag("display").hasKey("Name"))
display = tags.getCompoundTag("display");
if (!(tags.hasKey("display"))) display = new NBTTagCompound();
else if (tags.getCompoundTag("display").hasKey("Name")) display = tags.getCompoundTag("display");
if (display == null)
return output;
if (display == null) return output;
boolean doRename = false;
if (canRename(display, temp)) {
@@ -147,15 +123,13 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
// we only allow renaming with a nametag otherwise
else if (!("\u00A7f" + name).equals(display.getString("Name")) && !name.equals(display.getString("Name"))) {
int nametagCount = 0;
for(int i = 0; i < inventory.length; i++)
if(inventory[i] != null && inventory[i].getItem() == Items.name_tag)
nametagCount++;
for (int i = 0; i < inventory.length; i++)
if (inventory[i] != null && inventory[i].getItem() == Items.name_tag) nametagCount++;
doRename = nametagCount == 1;
}
if(!doRename)
return output;
if (!doRename) return output;
String dName = temp.getItem() instanceof IModifyable ? "\u00A7f" + name : name;
display.setString("Name", dName);
@@ -167,52 +141,42 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
}
@Override
public boolean canUpdate ()
{
public boolean canUpdate() {
return false;
}
@Override
public int[] getAccessibleSlotsFromSide (int side)
{
public int[] getAccessibleSlotsFromSide(int side) {
return new int[0];
}
@Override
public boolean canInsertItem (int i, ItemStack itemstack, int j)
{
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
return false;
}
@Override
public boolean canExtractItem (int i, ItemStack itemstack, int j)
{
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return false;
}
@Override
public String getInventoryName ()
{
public String getInventoryName() {
return "null";
}
@Override
public boolean hasCustomInventoryName ()
{
public boolean hasCustomInventoryName() {
return false;
}
@Override
public void openInventory ()
{
}
public void openInventory() {}
@Override
public void closeInventory ()
{
}
public void closeInventory() {}
public static boolean canRename(NBTTagCompound tags, ItemStack tool) {
return !tags.hasKey("Name") || tags.getString("Name").equals("\u00A7f" + ToolBuilder.defaultToolName(tool));
}
}
}
@@ -5,55 +5,49 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
public class BattlesignRender implements ISimpleBlockRenderingHandler
{
public class BattlesignRender implements ISimpleBlockRenderingHandler {
public static int battlesignModelID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
{
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
// Inventory should be an item. This is not here!
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
{
public boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) {
renderer.setRenderBounds(0.45F, 0.0F, 0.45F, 0.55F, 1.125F, 0.55F);
renderer.renderStandardBlock(block, x, y, z);
renderFace(world, x, y, z, block, renderer);
return true;
}
public void renderFace (IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer)
{
switch (world.getBlockMetadata(x, y, z))
{
case 0:
renderer.setRenderBounds(0.42F, 0.5F, 0F, 0.50F, 1.1F, 1F);
break;
case 1:
renderer.setRenderBounds(0.50F, 0.5F, 0F, 0.58F, 1.1F, 1F);
break;
case 2:
renderer.setRenderBounds(0F, 0.5F, 0.50F, 1F, 1.1F, 0.58F);
break;
case 3:
renderer.setRenderBounds(0F, 0.5F, 0.42F, 1F, 1.1F, 0.50F);
break;
public void renderFace(IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer) {
switch (world.getBlockMetadata(x, y, z)) {
case 0:
renderer.setRenderBounds(0.42F, 0.5F, 0F, 0.50F, 1.1F, 1F);
break;
case 1:
renderer.setRenderBounds(0.50F, 0.5F, 0F, 0.58F, 1.1F, 1F);
break;
case 2:
renderer.setRenderBounds(0F, 0.5F, 0.50F, 1F, 1.1F, 0.58F);
break;
case 3:
renderer.setRenderBounds(0F, 0.5F, 0.42F, 1F, 1.1F, 0.50F);
break;
}
renderer.renderStandardBlock(block, x, y, z);
}
@Override
public boolean shouldRender3DInInventory (int modelid)
{
public boolean shouldRender3DInInventory(int modelid) {
return true;
}
@Override
public int getRenderId ()
{
public int getRenderId() {
return battlesignModelID;
}
}
@@ -8,11 +8,9 @@ import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
import tconstruct.tools.logic.BattlesignLogic;
public class BattlesignTesr extends TileEntitySpecialRenderer
{
public class BattlesignTesr extends TileEntitySpecialRenderer {
public void renderTileEntityAt (BattlesignLogic te, double x, double y, double z, float something)
{
public void renderTileEntityAt(BattlesignLogic te, double x, double y, double z, float something) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
@@ -23,34 +21,40 @@ public class BattlesignTesr extends TileEntitySpecialRenderer
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
switch (te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord, te.zCoord))
{
case 0:
GL11.glRotatef(-90F, 0F, 1F, 0F);
GL11.glTranslatef(5F, -96F, -37F);
break;
case 1:
GL11.glRotatef(90F, 0F, 1F, 0F);
GL11.glTranslatef(-85F, -96F, 53F);
break;
case 2:
GL11.glTranslatef(5F, -96F, 53F);
break;
case 3:
GL11.glRotatef(180F, 0F, 1F, 0F);
GL11.glTranslatef(-85F, -96F, -37F);
break;
switch (te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord, te.zCoord)) {
case 0:
GL11.glRotatef(-90F, 0F, 1F, 0F);
GL11.glTranslatef(5F, -96F, -37F);
break;
case 1:
GL11.glRotatef(90F, 0F, 1F, 0F);
GL11.glTranslatef(-85F, -96F, 53F);
break;
case 2:
GL11.glTranslatef(5F, -96F, 53F);
break;
case 3:
GL11.glRotatef(180F, 0F, 1F, 0F);
GL11.glTranslatef(-85F, -96F, -37F);
break;
}
String strings[] = te.getText();
if (strings != null && strings.length > 0)
{
float lum = calcLuminance(te.getWorldObj().getBlock(te.xCoord, te.yCoord, te.zCoord).colorMultiplier(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord));
if (strings != null && strings.length > 0) {
float lum = calcLuminance(te.getWorldObj()
.getBlock(te.xCoord, te.yCoord, te.zCoord)
.colorMultiplier(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord));
for (int i = 0; i < strings.length; i++)
{
fr.drawString((lum >= 35F ? EnumChatFormatting.BLACK : lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE) + strings[i], -fr.getStringWidth(strings[i]) / 2 + 40, 10 * i, 0);
for (int i = 0; i < strings.length; i++) {
fr.drawString(
(lum >= 35F
? EnumChatFormatting.BLACK
: lum >= 31F ? EnumChatFormatting.GRAY : EnumChatFormatting.WHITE)
+ strings[i],
-fr.getStringWidth(strings[i]) / 2 + 40,
10 * i,
0);
}
}
@@ -58,8 +62,7 @@ public class BattlesignTesr extends TileEntitySpecialRenderer
GL11.glPopMatrix();
}
private float calcLuminance (int rgb)
{
private float calcLuminance(int rgb) {
int r = (rgb & 0xff0000) >> 16;
int g = (rgb & 0xff00) >> 8;
int b = (rgb & 0xff);
@@ -68,8 +71,7 @@ public class BattlesignTesr extends TileEntitySpecialRenderer
}
@Override
public void renderTileEntityAt (TileEntity te, double x, double y, double z, float something)
{
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float something) {
this.renderTileEntityAt((BattlesignLogic) te, x, y, z, something);
}
}
@@ -16,21 +16,22 @@ import net.minecraftforge.client.ForgeHooksClient;
import org.lwjgl.opengl.*;
@SideOnly(Side.CLIENT)
public class FancyItemRender extends Render
{
private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png");
public class FancyItemRender extends Render {
private static final ResourceLocation field_110798_h =
new ResourceLocation("textures/misc/enchanted_item_glint.png");
private RenderBlocks itemRenderBlocks = new RenderBlocks();
/** The RNG used in RenderItem (for bobbing itemstacks on the ground) */
private Random random = new Random();
public boolean renderWithColor = true;
/** Defines the zLevel of rendering of item on GUI. */
public float zLevel;
public static boolean renderInFrame;
public FancyItemRender()
{
public FancyItemRender() {
this.shadowSize = 0.15F;
this.shadowOpaque = 0.75F;
}
@@ -38,17 +39,19 @@ public class FancyItemRender extends Render
/**
* Renders the item
*/
public void doRenderItem (EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9)
{
public void doRenderItem(EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9) {
this.bindEntityTexture(par1EntityItem);
this.random.setSeed(187L);
ItemStack itemstack = par1EntityItem.getEntityItem();
if (itemstack.getItem() != null)
{
if (itemstack.getItem() != null) {
GL11.glPushMatrix();
float f2 = shouldBob() ? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F;
float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI);
float f2 = shouldBob()
? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F
+ 0.1F
: 0F;
float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart)
* (180F / (float) Math.PI);
byte b0 = getMiniBlockCount(itemstack);
GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6);
@@ -62,16 +65,16 @@ public class FancyItemRender extends Render
block = Block.getBlockFromItem(itemstack.getItem());
if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, field_147909_c, 1))
{
if (ForgeHooksClient.renderEntityItem(
par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, field_147909_c, 1)) {
;
}
else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType()))
{
} else if (itemstack.getItemSpriteNumber() == 0
&& block != null
&& RenderBlocks.renderItemIn3d(
Block.getBlockFromItem(itemstack.getItem()).getRenderType())) {
GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F);
if (renderInFrame)
{
if (renderInFrame) {
GL11.glScalef(1.25F, 1.25F, 1.25F);
GL11.glTranslatef(0.0F, 0.05F, 0.0F);
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
@@ -80,19 +83,16 @@ public class FancyItemRender extends Render
float f7 = 0.25F;
int j = block.getRenderType();
if (j == 1 || j == 19 || j == 12 || j == 2)
{
if (j == 1 || j == 19 || j == 12 || j == 2) {
f7 = 0.5F;
}
GL11.glScalef(f7, f7, f7);
for (i = 0; i < b0; ++i)
{
for (i = 0; i < b0; ++i) {
GL11.glPushMatrix();
if (i > 0)
{
if (i > 0) {
f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
@@ -103,69 +103,51 @@ public class FancyItemRender extends Render
this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5);
GL11.glPopMatrix();
}
}
else
{
} else {
float f8;
if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses())
{
if (renderInFrame)
{
if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses()) {
if (renderInFrame) {
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
}
else
{
} else {
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k)
{
for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) {
this.random.setSeed(187L);
IIcon icon = itemstack.getItem().getIcon(itemstack, k);
f8 = 1.0F;
if (this.renderWithColor)
{
if (this.renderWithColor) {
i = itemstack.getItem().getColorFromItemStack(itemstack, k);
f5 = (float) (i >> 16 & 255) / 255.0F;
f4 = (float) (i >> 8 & 255) / 255.0F;
f6 = (float) (i & 255) / 255.0F;
GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F);
this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k);
}
else
{
} else {
this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F, k);
}
}
}
else
{
if (renderInFrame)
{
} else {
if (renderInFrame) {
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
}
else
{
} else {
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
IIcon icon1 = itemstack.getIconIndex();
if (this.renderWithColor)
{
if (this.renderWithColor) {
int l = itemstack.getItem().getColorFromItemStack(itemstack, 0);
f8 = (float) (l >> 16 & 255) / 255.0F;
float f9 = (float) (l >> 8 & 255) / 255.0F;
f5 = (float) (l & 255) / 255.0F;
f4 = 1.0F;
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4);
}
else
{
} else {
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, 1.0F, 1.0F, 1.0F);
}
}
@@ -176,27 +158,34 @@ public class FancyItemRender extends Render
}
}
protected ResourceLocation func_110796_a (EntityItem par1EntityItem)
{
return this.renderManager.renderEngine.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber());
protected ResourceLocation func_110796_a(EntityItem par1EntityItem) {
return this.renderManager.renderEngine.getResourceLocation(
par1EntityItem.getEntityItem().getItemSpriteNumber());
}
/**
* Renders a dropped item
*/
private void renderDroppedItem (EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7)
{
private void renderDroppedItem(
EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7) {
renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0);
}
private void renderDroppedItem (EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass)
{
private void renderDroppedItem(
EntityItem par1EntityItem,
IIcon par2Icon,
int par3,
float par4,
float par5,
float par6,
float par7,
int pass) {
Tessellator tessellator = Tessellator.instance;
if (par2Icon == null)
{
if (par2Icon == null) {
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ResourceLocation resourcelocation = texturemanager.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber());
ResourceLocation resourcelocation = texturemanager.getResourceLocation(
par1EntityItem.getEntityItem().getItemSpriteNumber());
par2Icon = ((TextureMap) texturemanager.getTexture(resourcelocation)).getAtlasSprite("missingno");
}
@@ -211,13 +200,15 @@ public class FancyItemRender extends Render
GL11.glPushMatrix();
if (renderInFrame)
{
if (renderInFrame) {
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
}
else
{
GL11.glRotatef((((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
} else {
GL11.glRotatef(
(((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart)
* (180F / (float) Math.PI),
0.0F,
1.0F,
0.0F);
}
float f12 = 0.0625F;
@@ -228,35 +219,35 @@ public class FancyItemRender extends Render
GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F));
for (int k = 0; k < b0; ++k)
{
for (int k = 0; k < b0; ++k) {
// Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug...
if (k > 0 && shouldSpreadItems())
{
if (k > 0 && shouldSpreadItems()) {
float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
GL11.glTranslatef(x, y, f12 + f11);
}
else
{
} else {
GL11.glTranslatef(0f, 0f, f12 + f11);
}
if (itemstack.getItemSpriteNumber() == 0)
{
if (itemstack.getItemSpriteNumber() == 0) {
this.bindTexture(TextureMap.locationBlocksTexture);
}
else
{
} else {
this.bindTexture(TextureMap.locationItemsTexture);
}
GL11.glColor4f(par5, par6, par7, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((IIcon) par2Icon).getIconWidth(), ((IIcon) par2Icon).getIconHeight(), f12);
ItemRenderer.renderItemIn2D(
tessellator,
f5,
f6,
f4,
f7,
((IIcon) par2Icon).getIconWidth(),
((IIcon) par2Icon).getIconHeight(),
f12);
if (itemstack.hasEffect(pass))
{
if (itemstack.hasEffect(pass)) {
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
this.renderManager.renderEngine.bindTexture(field_110798_h);
@@ -288,19 +279,27 @@ public class FancyItemRender extends Render
}
GL11.glPopMatrix();
}
/**
* Renders the item's icon or block into the UI at the specified position.
*/
public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
public void renderItemIntoGUI(
FontRenderer par1FontRenderer,
TextureManager par2TextureManager,
ItemStack par3ItemStack,
int par4,
int par5) {
renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false);
}
public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect)
{
public void renderItemIntoGUI(
FontRenderer par1FontRenderer,
TextureManager par2TextureManager,
ItemStack par3ItemStack,
int par4,
int par5,
boolean renderEffect) {
Item k = par3ItemStack.getItem();
int l = par3ItemStack.getItemDamage();
Object object = par3ItemStack.getIconIndex();
@@ -309,9 +308,10 @@ public class FancyItemRender extends Render
float f1;
float f2;
Block block = Block.getBlockFromItem(k);//(k < Block.blocksList.length ? Block.blocksList[k] : null);
if (par3ItemStack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(block.getRenderType()))
{
Block block = Block.getBlockFromItem(k); // (k < Block.blocksList.length ? Block.blocksList[k] : null);
if (par3ItemStack.getItemSpriteNumber() == 0
&& block != null
&& RenderBlocks.renderItemIn3d(block.getRenderType())) {
par2TextureManager.bindTexture(TextureMap.locationBlocksTexture);
GL11.glPushMatrix();
GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel);
@@ -325,8 +325,7 @@ public class FancyItemRender extends Render
f1 = (float) (i1 >> 8 & 255) / 255.0F;
f2 = (float) (i1 & 255) / 255.0F;
if (this.renderWithColor)
{
if (this.renderWithColor) {
GL11.glColor4f(f, f1, f2, 1.0F);
}
@@ -335,44 +334,42 @@ public class FancyItemRender extends Render
this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F);
this.itemRenderBlocks.useInventoryTint = true;
GL11.glPopMatrix();
}
else if (k.requiresMultipleRenderPasses())
{
} else if (k.requiresMultipleRenderPasses()) {
GL11.glDisable(GL11.GL_LIGHTING);
for (int j1 = 0; j1 < k.getRenderPasses(l); ++j1)
{
par2TextureManager.bindTexture(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
for (int j1 = 0; j1 < k.getRenderPasses(l); ++j1) {
par2TextureManager.bindTexture(
par3ItemStack.getItemSpriteNumber() == 0
? TextureMap.locationBlocksTexture
: TextureMap.locationItemsTexture);
IIcon icon = k.getIcon(par3ItemStack, j1);
int k1 = k.getColorFromItemStack(par3ItemStack, j1);
f1 = (float) (k1 >> 16 & 255) / 255.0F;
f2 = (float) (k1 >> 8 & 255) / 255.0F;
float f3 = (float) (k1 & 255) / 255.0F;
if (this.renderWithColor)
{
if (this.renderWithColor) {
GL11.glColor4f(f1, f2, f3, 1.0F);
}
this.renderIcon(par4, par5, icon, 16, 16);
if (par3ItemStack.hasEffect(j1))
{
if (par3ItemStack.hasEffect(j1)) {
renderEffect(par2TextureManager, par4, par5);
}
}
GL11.glEnable(GL11.GL_LIGHTING);
}
else
{
} else {
GL11.glDisable(GL11.GL_LIGHTING);
ResourceLocation resourcelocation = par2TextureManager.getResourceLocation(par3ItemStack.getItemSpriteNumber());
ResourceLocation resourcelocation =
par2TextureManager.getResourceLocation(par3ItemStack.getItemSpriteNumber());
par2TextureManager.bindTexture(resourcelocation);
if (object == null)
{
object = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno");
if (object == null) {
object = ((TextureMap)
Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation))
.getAtlasSprite("missingno");
}
i1 = k.getColorFromItemStack(par3ItemStack, 0);
@@ -380,16 +377,14 @@ public class FancyItemRender extends Render
f1 = (float) (i1 >> 8 & 255) / 255.0F;
f2 = (float) (i1 & 255) / 255.0F;
if (this.renderWithColor)
{
if (this.renderWithColor) {
GL11.glColor4f(f, f1, f2, 1.0F);
}
this.renderIcon(par4, par5, (IIcon) object, 16, 16);
GL11.glEnable(GL11.GL_LIGHTING);
if (par3ItemStack.hasEffect(0))
{
if (par3ItemStack.hasEffect(0)) {
renderEffect(par2TextureManager, par4, par5);
}
}
@@ -397,8 +392,7 @@ public class FancyItemRender extends Render
GL11.glEnable(GL11.GL_CULL_FACE);
}
private void renderEffect (TextureManager manager, int x, int y)
{
private void renderEffect(TextureManager manager, int x, int y) {
GL11.glDepthFunc(GL11.GL_GREATER);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
@@ -418,12 +412,16 @@ public class FancyItemRender extends Render
/**
* Render the item's icon or block into the GUI, including the glint effect.
*/
public void renderItemAndEffectIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
if (par3ItemStack != null)
{
if (!ForgeHooksClient.renderInventoryItem(field_147909_c, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5))
{
public void renderItemAndEffectIntoGUI(
FontRenderer par1FontRenderer,
TextureManager par2TextureManager,
ItemStack par3ItemStack,
int par4,
int par5) {
if (par3ItemStack != null) {
if (!ForgeHooksClient.renderInventoryItem(
field_147909_c, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float)
par5)) {
this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true);
}
@@ -449,37 +447,51 @@ public class FancyItemRender extends Render
}
}
private void renderGlint (int par1, int par2, int par3, int par4, int par5)
{
for (int j1 = 0; j1 < 2; ++j1)
{
if (j1 == 0)
{
private void renderGlint(int par1, int par2, int par3, int par4, int par5) {
for (int j1 = 0; j1 < 2; ++j1) {
if (j1 == 0) {
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
}
if (j1 == 1)
{
if (j1 == 1) {
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
}
float f = 0.00390625F;
float f1 = 0.00390625F;
float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F;
float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873))
/ (3000.0F + (float) (j1 * 1873))
* 256.0F;
float f3 = 0.0F;
Tessellator tessellator = Tessellator.instance;
float f4 = 4.0F;
if (j1 == 1)
{
if (j1 == 1) {
f4 = -1.0F;
}
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1));
tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1));
tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1));
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1));
tessellator.addVertexWithUV(
(double) (par2 + 0),
(double) (par3 + par5),
(double) this.zLevel,
(double) ((f2 + (float) par5 * f4) * f),
(double) ((f3 + (float) par5) * f1));
tessellator.addVertexWithUV(
(double) (par2 + par4),
(double) (par3 + par5),
(double) this.zLevel,
(double) ((f2 + (float) par4 + (float) par5 * f4) * f),
(double) ((f3 + (float) par5) * f1));
tessellator.addVertexWithUV(
(double) (par2 + par4),
(double) (par3 + 0),
(double) this.zLevel,
(double) ((f2 + (float) par4) * f),
(double) ((f3 + 0.0F) * f1));
tessellator.addVertexWithUV(
(double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double)
((f3 + 0.0F) * f1));
tessellator.draw();
}
}
@@ -488,29 +500,42 @@ public class FancyItemRender extends Render
* Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the
* specified position.
*/
public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
public void renderItemOverlayIntoGUI(
FontRenderer par1FontRenderer,
TextureManager par2TextureManager,
ItemStack par3ItemStack,
int par4,
int par5) {
this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String) null);
}
public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str)
{
if (par3ItemStack != null)
{
if (par3ItemStack.stackSize > 1 || par6Str != null)
{
public void renderItemOverlayIntoGUI(
FontRenderer par1FontRenderer,
TextureManager par2TextureManager,
ItemStack par3ItemStack,
int par4,
int par5,
String par6Str) {
if (par3ItemStack != null) {
if (par3ItemStack.stackSize > 1 || par6Str != null) {
String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215);
par1FontRenderer.drawStringWithShadow(
s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
if (par3ItemStack.isItemDamaged())
{
int k = (int) Math.round(13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage());
int l = (int) Math.round(255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage());
if (par3ItemStack.isItemDamaged()) {
int k = (int) Math.round(13.0D
- (double) par3ItemStack.getItemDamageForDisplay()
* 13.0D
/ (double) par3ItemStack.getMaxDamage());
int l = (int) Math.round(255.0D
- (double) par3ItemStack.getItemDamageForDisplay()
* 255.0D
/ (double) par3ItemStack.getMaxDamage());
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
@@ -532,8 +557,7 @@ public class FancyItemRender extends Render
* Adds a quad to the tesselator at the specified position with the set width and height and color. Args:
* tessellator, x, y, width, height, color
*/
private void renderQuad (Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6)
{
private void renderQuad(Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6) {
par1Tessellator.startDrawingQuads();
par1Tessellator.setColorOpaque_I(par6);
par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + 0), 0.0D);
@@ -543,20 +567,29 @@ public class FancyItemRender extends Render
par1Tessellator.draw();
}
public void renderIcon (int par1, int par2, IIcon par3Icon, int par4, int par5)
{
public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV());
tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV());
tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV());
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV());
tessellator.addVertexWithUV(
(double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double)
par3Icon.getMaxV());
tessellator.addVertexWithUV(
(double) (par1 + par4),
(double) (par2 + par5),
(double) this.zLevel,
(double) par3Icon.getMaxU(),
(double) par3Icon.getMaxV());
tessellator.addVertexWithUV(
(double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double)
par3Icon.getMinV());
tessellator.addVertexWithUV(
(double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double)
par3Icon.getMinV());
tessellator.draw();
}
@Override
protected ResourceLocation getEntityTexture (Entity par1Entity)
{
protected ResourceLocation getEntityTexture(Entity par1Entity) {
return this.func_110796_a((EntityItem) par1Entity);
}
@@ -567,8 +600,7 @@ public class FancyItemRender extends Render
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
@Override
public void doRender (Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
this.doRenderItem((EntityItem) par1Entity, par2, par4, par6, par8, par9);
}
@@ -576,8 +608,7 @@ public class FancyItemRender extends Render
* Items should spread out when rendered in 3d?
* @return
*/
public boolean shouldSpreadItems ()
{
public boolean shouldSpreadItems() {
return true;
}
@@ -585,22 +616,16 @@ public class FancyItemRender extends Render
* Items should have a bob effect
* @return
*/
public boolean shouldBob ()
{
public boolean shouldBob() {
return true;
}
public byte getMiniBlockCount (ItemStack stack)
{
public byte getMiniBlockCount(ItemStack stack) {
byte ret = 1;
if (stack.stackSize > 1)
ret = 2;
if (stack.stackSize > 5)
ret = 3;
if (stack.stackSize > 20)
ret = 4;
if (stack.stackSize > 40)
ret = 5;
if (stack.stackSize > 1) ret = 2;
if (stack.stackSize > 5) ret = 3;
if (stack.stackSize > 20) ret = 4;
if (stack.stackSize > 40) ret = 5;
return ret;
}
@@ -610,15 +635,11 @@ public class FancyItemRender extends Render
* @param stack
* @return
*/
public byte getMiniItemCount (ItemStack stack)
{
public byte getMiniItemCount(ItemStack stack) {
byte ret = 1;
if (stack.stackSize > 1)
ret = 2;
if (stack.stackSize > 15)
ret = 3;
if (stack.stackSize > 31)
ret = 4;
if (stack.stackSize > 1) ret = 2;
if (stack.stackSize > 15) ret = 3;
if (stack.stackSize > 31) ret = 4;
return ret;
}
}
}
@@ -5,19 +5,17 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
public class FrypanRender implements ISimpleBlockRenderingHandler
{
public class FrypanRender implements ISimpleBlockRenderingHandler {
public static int frypanModelID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
{
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
// Inventory should be an item. This is not here!
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
{
public boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) {
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.0F, 0.125F, 0.0F, 0.125F, 0.25F, 1.0F);
@@ -34,36 +32,32 @@ public class FrypanRender implements ISimpleBlockRenderingHandler
return true;
}
public void renderHandle (IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer)
{
switch (world.getBlockMetadata(x, y, z))
{
case 0:
renderer.setRenderBounds(1F, 0.0F, 0.4375F, 2F, 0.125F, 0.5625F);
break;
case 1:
renderer.setRenderBounds(-1F, 0.0F, 0.4375F, 0F, 0.125F, 0.5625F);
break;
case 2:
renderer.setRenderBounds(0.4375F, 0.0F, -1F, 0.5625F, 0.125F, 0F);
break;
case 3:
renderer.setRenderBounds(0.4375F, 0.0F, 1F, 0.5625F, 0.125F, 2F);
break;
public void renderHandle(IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer) {
switch (world.getBlockMetadata(x, y, z)) {
case 0:
renderer.setRenderBounds(1F, 0.0F, 0.4375F, 2F, 0.125F, 0.5625F);
break;
case 1:
renderer.setRenderBounds(-1F, 0.0F, 0.4375F, 0F, 0.125F, 0.5625F);
break;
case 2:
renderer.setRenderBounds(0.4375F, 0.0F, -1F, 0.5625F, 0.125F, 0F);
break;
case 3:
renderer.setRenderBounds(0.4375F, 0.0F, 1F, 0.5625F, 0.125F, 2F);
break;
}
renderer.renderStandardBlock(block, x, y, z);
}
@Override
public boolean shouldRender3DInInventory (int modelid)
{
public boolean shouldRender3DInInventory(int modelid) {
return true;
}
@Override
public int getRenderId ()
{
public int getRenderId() {
return frypanModelID;
}
}
@@ -7,19 +7,16 @@ import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import tconstruct.tools.TinkerTools;
public class TableRender implements ISimpleBlockRenderingHandler
{
public class TableRender implements ISimpleBlockRenderingHandler {
public static int model = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
{
if (modelID == model)
{
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
if (modelID == model) {
// until we get the new model.. finally...
if(block == TinkerTools.toolStationWood && metadata >= 5 && metadata <= 9) {
if (block == TinkerTools.toolStationWood && metadata >= 5 && metadata <= 9) {
// pattern chest
renderer.setRenderBounds(0,0,0,1,0.875,1);
renderer.setRenderBounds(0, 0, 0, 1, 0.875, 1);
renderStandardInvBlock(renderer, block, metadata);
return;
}
@@ -38,16 +35,15 @@ public class TableRender implements ISimpleBlockRenderingHandler
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
{
if (modelID == model)
{
int metadata = world.getBlockMetadata(x,y,z);
public boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) {
if (modelID == model) {
int metadata = world.getBlockMetadata(x, y, z);
// until we get the new model.. finally...
if(block == TinkerTools.toolStationWood && metadata >= 5 && metadata <= 9) {
if (block == TinkerTools.toolStationWood && metadata >= 5 && metadata <= 9) {
// pattern chest
renderer.setRenderBounds(0,0,0,1,0.875,1);
renderer.renderStandardBlock(block, x,y,z);
renderer.setRenderBounds(0, 0, 0, 1, 0.875, 1);
renderer.renderStandardBlock(block, x, y, z);
return true;
}
@@ -67,19 +63,16 @@ public class TableRender implements ISimpleBlockRenderingHandler
}
@Override
public boolean shouldRender3DInInventory (int modelID)
{
public boolean shouldRender3DInInventory(int modelID) {
return true;
}
@Override
public int getRenderId ()
{
public int getRenderId() {
return model;
}
public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta)
{
public static void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta) {
Tessellator tessellator = Tessellator.instance;
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tessellator.startDrawingQuads();