diff options
author | draknyte1 <draknyte1@hotmail.com> | 2017-02-15 18:12:06 +1000 |
---|---|---|
committer | draknyte1 <draknyte1@hotmail.com> | 2017-02-15 18:12:06 +1000 |
commit | 3022f3f4f96d8892b6d8c073eea7f852dcf1d71c (patch) | |
tree | 9eff729af8fb949111db54050138047f4ff3caed /src/Java/gtPlusPlus | |
parent | 099ad908e559e0d4753fe265462b2263dc6f3ba3 (diff) | |
download | GT5-Unofficial-3022f3f4f96d8892b6d8c073eea7f852dcf1d71c.tar.gz GT5-Unofficial-3022f3f4f96d8892b6d8c073eea7f852dcf1d71c.tar.bz2 GT5-Unofficial-3022f3f4f96d8892b6d8c073eea7f852dcf1d71c.zip |
$ Fixed GT material blast smelter recipes not using GT dusts.
+ Added Double Clay Plates.
+ Added the TileEntity for a Fish Trap.
Diffstat (limited to 'src/Java/gtPlusPlus')
6 files changed, 323 insertions, 11 deletions
diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryFishtrap.java b/src/Java/gtPlusPlus/core/inventories/InventoryFishtrap.java new file mode 100644 index 0000000000..d7a9d6bfa5 --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/InventoryFishtrap.java @@ -0,0 +1,188 @@ +package gtPlusPlus.core.inventories; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class InventoryFishtrap implements IInventory{ + + private String name = "Fishtrap"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 16; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryFishtrap() + { + + } + + public void readFromNBT(NBTTagCompound nbt) + { + NBTTagList list = nbt.getTagList("Items", 10); + inventory = new ItemStack[INV_SIZE]; + for(int i = 0;i<list.tagCount();i++) + { + NBTTagCompound data = list.getCompoundTagAt(i); + int slot = data.getInteger("Slot"); + if(slot >= 0 && slot < INV_SIZE) + { + inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(NBTTagCompound nbt) + { + NBTTagList list = new NBTTagList(); + for(int i = 0;i<INV_SIZE;i++) + { + ItemStack stack = inventory[i]; + if(stack != null) + { + NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() + { + return inventory.length; + } + + public ItemStack[] getInventory(){ + return inventory; + } + + @Override + public ItemStack getStackInSlot(int slot) + { + return inventory[slot]; + } + + @Override + public ItemStack decrStackSize(int slot, int amount) + { + ItemStack stack = getStackInSlot(slot); + if(stack != null) + { + if(stack.stackSize > amount) + { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + ItemStack stack = getStackInSlot(slot); + setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + inventory[slot] = stack; + + if (stack != null && stack.stackSize > getInventoryStackLimit()) + { + stack.stackSize = getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() + { + for (int i = 0; i < getSizeInventory(); ++i) + { + ItemStack temp = getStackInSlot(i); + if (temp != null){ + //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if (temp != null && temp.stackSize == 0) { + inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) + { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) + { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index ce5f8a2bce..0eb0cbb3b8 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -13,6 +13,7 @@ import gtPlusPlus.core.item.base.foods.BaseItemFood; import gtPlusPlus.core.item.base.foods.BaseItemHotFood; import gtPlusPlus.core.item.base.ingots.BaseItemIngotOLD; import gtPlusPlus.core.item.base.plates.BaseItemPlate; +import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; import gtPlusPlus.core.item.effects.RarityUncommon; import gtPlusPlus.core.item.general.*; import gtPlusPlus.core.item.init.ItemsFoods; @@ -182,18 +183,16 @@ public final class ModItems { public static Item dustLiFBeF2ZrF4U235; public static Item dustLiFBeF2ThF4UF4; - private static Item dustCalciumSulfate; + public static Item dustCalciumSulfate; - private static BaseItemPlate itemPlateClay; - - private static Item dustFertUN18; - - private static Item dustFertUN32; + public static BaseItemPlate itemPlateClay; + public static BaseItemPlateDouble itemDoublePlateClay; + + public static Item dustFertUN18; + public static Item dustFertUN32; - //@SuppressWarnings("unused") - @SuppressWarnings("unused") public static final void init(){ //Default item used when recipes fail, handy for debugging. @@ -511,6 +510,7 @@ public final class ModItems { //Just an unusual plate needed for some black magic. itemPlateClay = new BaseItemPlate(MaterialUtils.generateMaterialFromGtENUM(Materials.Clay)); + itemDoublePlateClay = new BaseItemPlateDouble(MaterialUtils.generateMaterialFromGtENUM(Materials.Clay)); //EnderIO Resources if (LoadedMods.EnderIO || LOAD_ALL_CONTENT){ diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 66c881763a..adba7444b8 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -27,7 +27,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.4.9.35-alpha"; + public static final String VERSION = "1.4.9.39-alpha"; public static final String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static boolean isModUpToDate = Utils.isModUpToDate(); public static boolean DEBUG = false; diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java new file mode 100644 index 0000000000..61cacb06e8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -0,0 +1,115 @@ +package gtPlusPlus.core.tileentities.general; + +import java.util.UUID; + +import gtPlusPlus.core.inventories.*; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityFishTrap extends TileEntity{ + + private UUID ownerUUID; + private int tickCount = 0; + private boolean isInWater = false; + private InventoryFishtrap inventoryChest; + private int locationX = this.xCoord; + private int locationY = this.yCoord;; + private int locationZ = this.zCoord;; + + public TileEntityFishTrap(){ + this.inventoryChest = new InventoryFishtrap();//number of slots - without product slot + this.canUpdate(); + } + + public boolean setTileLocation(){ + if (this.hasWorldObj()){ + locationX = this.xCoord; + locationY = this.yCoord; + locationZ = this.zCoord; + return true; + + } + return false; + } + + public final boolean isSurroundedByWater(){ + Block[] surroundingBlocks = new Block[6]; + if (this.hasWorldObj()){ + surroundingBlocks[0] = worldObj.getBlock(locationX, locationY+1, locationZ); //Above + surroundingBlocks[1] = worldObj.getBlock(locationX, locationY-1, locationZ); //Below + surroundingBlocks[2] = worldObj.getBlock(locationX+1, locationY, locationZ); + surroundingBlocks[3] = worldObj.getBlock(locationX-1, locationY, locationZ); + surroundingBlocks[4] = worldObj.getBlock(locationX, locationY, locationZ+1); + surroundingBlocks[5] = worldObj.getBlock(locationX, locationY, locationZ-1); + int waterCount = 0; + for (Block checkBlock : surroundingBlocks){ + if (checkBlock == Blocks.water || checkBlock == Blocks.flowing_water){ + waterCount++; + } + } + if (waterCount >= 5){ + return true; + } + return false; + } + return false; + } + + @Override + public void updateEntity(){ + //if (anyPlayerInRange()){ + this.tickCount += 1; + if (this.worldObj.isRemote){ + this.isInWater = isSurroundedByWater(); + + if (this.isInWater){ + //Add Loot + } + //Add some Loot + } + //} + } + + public boolean anyPlayerInRange(){ + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public UUID getOwnerUUID() { + return ownerUUID; + } + + public void setOwnerUUID(UUID ownerUUID) { + this.ownerUUID = ownerUUID; + markDirty(); + } + + public NBTTagCompound getTag(NBTTagCompound nbt, String tag){ + if(!nbt.hasKey(tag)){ + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + + @Override + public void writeToNBT(NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + inventoryChest.writeToNBT(getTag(tagCompound, "ContentsChest")); + UUID ownerUUID = getOwnerUUID(); + if (ownerUUID != null){ + tagCompound.setLong("OwnerUUIDMost", ownerUUID.getMostSignificantBits()); + tagCompound.setLong("OwnerUUIDLeast", ownerUUID.getLeastSignificantBits()); + } + } + + @Override + public void readFromNBT(NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + + inventoryChest.readFromNBT(tagCompound.getCompoundTag("ContentsChest")); + setOwnerUUID(new UUID(tagCompound.getLong("OwnerUUIDMost"), tagCompound.getLong("OwnerUUIDLeast"))); + } + +} diff --git a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index 1f597302ba..da199c2be6 100644 --- a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -256,6 +256,15 @@ public class ItemUtils { Utils.LOG_INFO(oredictName+" was not valid."); return null; } + + public static ItemStack getGregtechDust(Materials material, int amount){ + ItemStack returnValue = GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L); + if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() || returnValue.getItem() != ModItems.AAA_Broken){ + return returnValue; + } + Utils.LOG_INFO(material+" was not valid."); + return null; + } public static Item[] generateDusts(String unlocalizedName, String materialName, int materialTier, Material matInfo, int Colour){ int radioactive = getRadioactivityLevel(materialName); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT.java index 94827738ce..e5262ac645 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT.java @@ -61,7 +61,7 @@ public class RecipeGen_BlastSmelterGT implements Runnable{ //Make a simple one Material Materialstack[] and log it for validity. tMaterial = new MaterialStack[]{new MaterialStack(M, 1)}; circuitGT = ItemUtils.getGregtechCircuit(1); - ItemStack[] tItemStackTest = new ItemStack[]{circuitGT, ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dust"+M, 1)}; + ItemStack[] tItemStackTest = new ItemStack[]{circuitGT, ItemUtils.getGregtechDust(M, 1)}; inputStackCount = 1; fluidAmount = 144*inputStackCount; Utils.LOG_WARNING("Adding an Alloy Blast Smelter Recipe for "+M+". Gives "+fluidAmount+"L of molten metal."); @@ -120,7 +120,7 @@ public class RecipeGen_BlastSmelterGT implements Runnable{ for (MaterialStack aOutputPart : tempStack){ if (aOutputPart != null){ Utils.LOG_WARNING("Finding dust: "+aOutputPart.mMaterial); - ItemStack rStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dust"+aOutputPart.mMaterial, (int) aOutputPart.mAmount); + ItemStack rStack = ItemUtils.getGregtechDust(aOutputPart.mMaterial, (int) aOutputPart.mAmount); if (rStack != null){ Utils.LOG_WARNING("Found dust: "+aOutputPart.mMaterial); components[counter] = rStack; |