1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
package gregtech.common.blocks;
import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_ItsNotMyFaultException;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
public class GT_Item_Machines
extends ItemBlock
{
public GT_Item_Machines(Block par1)
{
super(par1);
setMaxDamage(0);
setHasSubtypes(true);
setCreativeTab(GregTech_API.TAB_GREGTECH);
}
public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4)
{
try
{
int tDamage = getDamage(aStack);
if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) {
return;
}
if (tDamage == 0)
{
aList.add("WARNING, THE EXISTENCE OF THIS ITEM IS A BUG");
aList.add("IF YOU GOT IT IN SURVIVAL THEN PLEASE REPORT IT");
}
else
{
TileEntity temp = GregTech_API.sBlockMachines.createTileEntity(aPlayer == null ? GT_Values.DW : aPlayer.worldObj, GregTech_API.METATILEENTITIES[tDamage] == null ? 0 : GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType());
if (temp != null)
{
temp.setWorldObj(aPlayer == null ? GT_Values.DW : aPlayer.worldObj);temp.xCoord = 0;temp.yCoord = 0;temp.zCoord = 0;
if ((temp instanceof IGregTechTileEntity))
{
IGregTechTileEntity tTileEntity = (IGregTechTileEntity)temp;
tTileEntity.setInitialValuesAsNBT(new NBTTagCompound(), (short)tDamage);
if (tTileEntity.getDescription() != null)
{
int i = 0;
for (String tDescription : tTileEntity.getDescription()) {
if (GT_Utility.isStringValid(tDescription)) {
aList.add(GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished));
}
}
}
if (tTileEntity.getEUCapacity() > 0L)
{
if (tTileEntity.getInputVoltage() > 0L) {
aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + EnumChatFormatting.GRAY);
}
if (tTileEntity.getOutputVoltage() > 0L) {
aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" + EnumChatFormatting.GRAY);
}
if (tTileEntity.getOutputAmperage() > 1L) {
aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished) + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY);
}
aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished) + EnumChatFormatting.BLUE + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY);
}
}
}
}
NBTTagCompound aNBT = aStack.getTagCompound();
if (aNBT != null)
{
if (aNBT.getBoolean("mMuffler")) {
aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished));
}
if (aNBT.getBoolean("mSteamConverter")) {
aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade", !GregTech_API.sPostloadFinished));
}
int tAmount = 0;
if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) {
aList.add(tAmount + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades", !GregTech_API.sPostloadFinished));
}
}
}
catch (Throwable e)
{
e.printStackTrace(GT_Log.err);
}
}
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
return false;
}
public String getUnlocalizedName(ItemStack aStack)
{
short tDamage = (short)getDamage(aStack);
if ((tDamage < 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) {
return "";
}
if (GregTech_API.METATILEENTITIES[tDamage] != null) {
return getUnlocalizedName() + "." + GregTech_API.METATILEENTITIES[tDamage].getMetaName();
}
return "";
}
public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer)
{
super.onCreated(aStack, aWorld, aPlayer);
short tDamage = (short)getDamage(aStack);
if ((tDamage < 0) || ((tDamage >= GregTech_API.METATILEENTITIES.length) && (GregTech_API.METATILEENTITIES[tDamage] != null))) {
GregTech_API.METATILEENTITIES[tDamage].onCreated(aStack, aWorld, aPlayer);
}
}
public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta)
{
short tDamage = (short)getDamage(aStack);
if (tDamage > 0)
{
if (GregTech_API.METATILEENTITIES[tDamage] == null) {
return false;
}
int tMetaData = GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType();
if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tMetaData, 3)) {
return false;
}
if (aWorld.getBlock(aX, aY, aZ) != this.field_150939_a) {
throw new GT_ItsNotMyFaultException("Failed to place Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don't report this Bug to me, I don't know how to fix it.");
}
if (aWorld.getBlockMetadata(aX, aY, aZ) != tMetaData) {
throw new GT_ItsNotMyFaultException("Failed to set the MetaValue of the Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don't report this Bug to me, I don't know how to fix it.");
}
IGregTechTileEntity tTileEntity = (IGregTechTileEntity)aWorld.getTileEntity(aX, aY, aZ);
if (tTileEntity != null)
{
tTileEntity.setInitialValuesAsNBT(tTileEntity.isServerSide() ? aStack.getTagCompound() : null, tDamage);
if (aPlayer != null) {
tTileEntity.setOwnerName(aPlayer.getDisplayName());
}
tTileEntity.getMetaTileEntity().initDefaultModes(aStack.getTagCompound());
}
}
else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3))
{
return false;
}
if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a)
{
this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack);
this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage);
}
return true;
}
}
|