diff options
6 files changed, 108 insertions, 17 deletions
diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderPotionthrow.java b/src/Java/gtPlusPlus/core/client/renderer/RenderPotionthrow.java index 0f5e2f08c8..378d03f1df 100644 --- a/src/Java/gtPlusPlus/core/client/renderer/RenderPotionthrow.java +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderPotionthrow.java @@ -18,13 +18,13 @@ import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) public class RenderPotionthrow extends Render { - private Item field_94151_a; - private int field_94150_f; + private Item mRenderItem; + private int mDamage; public RenderPotionthrow(Item p_i1259_1_, int p_i1259_2_) { - this.field_94151_a = p_i1259_1_; - this.field_94150_f = p_i1259_2_; + this.mRenderItem = p_i1259_1_; + this.mDamage = p_i1259_2_; } public RenderPotionthrow(Item p_i1260_1_) @@ -40,7 +40,7 @@ public class RenderPotionthrow extends Render */ public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - IIcon iicon = this.field_94151_a.getIconFromDamage(this.field_94150_f); + IIcon iicon = this.mRenderItem.getIconFromDamage(this.mDamage); if (iicon != null) { diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java b/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java index 6f4c57f294..b12dc7e0a8 100644 --- a/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java @@ -1,9 +1,15 @@ package gtPlusPlus.core.entity.projectile; +import gregtech.common.GT_Pollution; +import gtPlusPlus.core.util.PollutionUtils; +import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.player.PlayerUtils; +import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.init.Blocks; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -26,10 +32,18 @@ public class EntitySulfuricAcidPotion extends EntityThrowable { * Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition object) { + int xBlock = object.blockX; + int yBlock = object.blockY; + int zBlock = object.blockZ; if (object.entityHit != null) { byte b0 = 6; object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) b0); EntityUtils.setEntityOnFire(object.entityHit, 10); + object.entityHit.fireResistance = 0; + ravage(new BlockPos(xBlock, yBlock, zBlock)); + } + if (object.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ + ravage(new BlockPos(xBlock, yBlock, zBlock)); } String mParticleType = "reddust"; @@ -48,4 +62,48 @@ public class EntitySulfuricAcidPotion extends EntityThrowable { this.setDead(); } } + + private boolean ravage(BlockPos blockpos){ + + for (int i=(blockpos.xPos-1);i<(blockpos.xPos+1);i++){ + for (int j=(blockpos.yPos-1);j<(blockpos.yPos+1);j++){ + for (int h=(blockpos.zPos-1);h<(blockpos.zPos+1);h++){ + + Block mBlockhit = worldObj.getBlock(i, j, h); + this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(0, 2), this.posY+MathUtils.randDouble(0, 2), this.posZ+MathUtils.randDouble(0, 2), 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(0, 2), this.posY+MathUtils.randDouble(0, 2), this.posZ+MathUtils.randDouble(0, 2), 0.0D, 0.0D, 0.0D); + + int mPol = 500000000; + + GT_Pollution.addPollution(worldObj.getChunkFromBlockCoords(blockpos.xPos, blockpos.zPos), mPol); + + if (mBlockhit == Blocks.grass || mBlockhit == Blocks.mycelium){ + worldObj.setBlock(i, j+1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } + else if (mBlockhit == Blocks.leaves || mBlockhit == Blocks.leaves2){ + worldObj.setBlock(i, j, h, Blocks.fire); + } + else if (mBlockhit == Blocks.tallgrass){ + worldObj.setBlock(i, j, h, Blocks.fire); + if (worldObj.getBlock(i, j-1, h) == Blocks.grass){ + worldObj.setBlock(i, j-1, h, Blocks.dirt); + } + } + else if (mBlockhit == Blocks.carrots || mBlockhit == Blocks.melon_block || mBlockhit == Blocks.pumpkin || mBlockhit == Blocks.potatoes){ + worldObj.setBlock(i, j+1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } + else if (mBlockhit == Blocks.air){ + worldObj.setBlock(i, j, h, Blocks.fire); + } + } + } + } + + + return true; + } + + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java index c2bb478f85..5b55bbd84f 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java @@ -1,12 +1,14 @@ package gtPlusPlus.core.item.base.itemblock; -import gtPlusPlus.core.util.nbt.NBTUtils; +import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.block.Block; -import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class ItemBlockNBT extends ItemBlock { @@ -17,14 +19,39 @@ public class ItemBlockNBT extends ItemBlock { @Override public void onCreated(ItemStack item, World world, EntityPlayer player) { - if (player != null){ - NBTUtils.setString(item, "mOwner", player.getDisplayName()); - NBTUtils.setString(item, "mUUID", ""+player.getUniqueID()); - boolean mOP = PlayerUtils.isPlayerOP(player); - NBTUtils.setBoolean(item, "mOP", mOP); - } + addNBT(player, item); super.onCreated(item, world, player); } + @Override + public void onUpdate(ItemStack item, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) { + if (entity instanceof EntityPlayerMP) { + EntityPlayerMP mPlayer = (EntityPlayerMP) entity; + + NBTTagCompound rNBT = item.getTagCompound(); + rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT); + if (!rNBT.hasKey("mOwner")){ + addNBT(mPlayer, item); + } + } + super.onUpdate(item, world, entity, p_77663_4_, p_77663_5_); + } + + private void addNBT(EntityPlayer player, ItemStack item) { + NBTTagCompound rNBT = item.getTagCompound(); + rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT); + if (player != null) { + boolean mOP = PlayerUtils.isPlayerOP(player); + rNBT.setString("mOwner", player.getDisplayName()); + rNBT.setString("mUUID", ""+player.getUniqueID()); + rNBT.setBoolean("mOP", mOP); + } + else if (player == null) { + rNBT.setString("mOwner", "fakeplayer"); + rNBT.setString("mUUID", "00000000"); + rNBT.setBoolean("mOP", false); + } + GT_Utility.ItemNBT.setNBT(item, rNBT); + } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java index 77b845260a..9451f65469 100644 --- a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java @@ -94,6 +94,7 @@ public class ClientProxy extends CommonProxy implements Runnable{ RenderingRegistry.registerEntityRenderingHandler(EntitySickBlaze.class, new RenderSickBlaze()); RenderingRegistry.registerEntityRenderingHandler(EntityStaballoyConstruct.class, new RenderIronGolem()); RenderingRegistry.registerEntityRenderingHandler(EntityToxinballSmall.class, new RenderToxinball(1F)); + Utils.LOG_INFO("Registering Custom Renderer for Sulfuric potion."); RenderingRegistry.registerEntityRenderingHandler(EntitySulfuricAcidPotion.class, new RenderPotionthrow(ModItems.itemSulfuricPotion)); diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java index 6a40e893cb..8d65ad8926 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java @@ -120,6 +120,7 @@ public class TileEntityTradeTable extends TileEntity implements INetworkDataProv if (slot0 != null && slot0.hasTagCompound()){ NBTUtils.tryIterateNBTData(slot0); this.inventoryOutputs.setInventorySlotContents(0, null); + this.inventoryOutputs.setInventorySlotContents(1, slot0); } } diff --git a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java index 72784c29a7..27dffd315c 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java @@ -173,9 +173,14 @@ public class NBTUtils { NBTTagCompound tNBT = getNBT(aStack); return tNBT.getString(aTag); } + + public static boolean doesStringExist(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.hasKey(aTag); + } public static boolean tryIterateNBTData(ItemStack aStack) { - /*try { + try { NBTTagCompound aNBT = NBTUtils.getNBT(aStack); if (aNBT != null) { if (!aNBT.hasNoTags()) { @@ -183,7 +188,7 @@ public class NBTUtils { Map<?, ?> mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); if (mInternalMap != null) { - mInternalMap.forEach((k, v) -> System.out.println("Key: " + k + ": Value: " + v)); + mInternalMap.forEach((k, v) -> Utils.LOG_INFO("Key: " + k + ": Value: " + v)); } else { Utils.LOG_INFO("Data map reflected from NBTTagCompound was not valid."); return false; @@ -197,8 +202,7 @@ public class NBTUtils { return true; } catch (Throwable t) { return false; - }*/ - return false; + } } } |