aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/tileentities
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-01-06 18:18:27 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-01-06 18:18:27 +0000
commit05d2066fd364ddff525b9ac4b38771d196641a5e (patch)
tree11abbdf56d18c4cc542b9edeb6c73274c1675eee /src/Java/gtPlusPlus/core/tileentities
parentae46cb2fab01f82ab49b1e63172da88e0adde212 (diff)
downloadGT5-Unofficial-05d2066fd364ddff525b9ac4b38771d196641a5e.tar.gz
GT5-Unofficial-05d2066fd364ddff525b9ac4b38771d196641a5e.tar.bz2
GT5-Unofficial-05d2066fd364ddff525b9ac4b38771d196641a5e.zip
+ Added a new Alloy.
+ Added Recipes for the Fusion MK4 Components and the Deep Earth Drilling Platform components. + Added additional feature support to all Assembly Line recipes when TecTech is found. + Added initial work for future particle science. % Initial functions added for Multiblock Requirements. % More work on Multiblock Blueprints and Layers. % Updated lead lined chest significantly. % Improved Fish trap inventory handling and general logic, it's now slightly faster with slightly better loot rates. % Changed texture of Fish trap.
Diffstat (limited to 'src/Java/gtPlusPlus/core/tileentities')
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java268
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java47
2 files changed, 264 insertions, 51 deletions
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java
index 0a9a77a415..63ea1ac783 100644
--- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java
@@ -1,22 +1,40 @@
package gtPlusPlus.core.tileentities.general;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.inventories.Inventory_DecayablesChest;
+import gtPlusPlus.core.item.materials.DustDecayable;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.core.inventories.Inventory_DecayablesChest;
-import gtPlusPlus.core.item.materials.DustDecayable;
-import gtPlusPlus.core.util.minecraft.ItemUtils;
public class TileEntityDecayablesChest extends TileEntity implements ISidedInventory {
-
private final Inventory_DecayablesChest inventoryContents;
+
+ /** Determines if the check for adjacent chests has taken place. */
+ public boolean adjacentChestChecked;
+ /** Contains the chest tile located adjacent to this one (if any) */
+ public TileEntityDecayablesChest adjacentChestZNeg;
+ /** Contains the chest tile located adjacent to this one (if any) */
+ public TileEntityDecayablesChest adjacentChestXPos;
+ /** Contains the chest tile located adjacent to this one (if any) */
+ public TileEntityDecayablesChest adjacentChestXNeg;
+ /** Contains the chest tile located adjacent to this one (if any) */
+ public TileEntityDecayablesChest adjacentChestZPos;
+ /** The current angle of the lid (between 0 and 1) */
+ public float lidAngle;
+ /** The angle of the lid last tick */
+ public float prevLidAngle;
+ /** The number of players currently using this chest */
+ public int numPlayersUsing;
+ private int cachedChestType;
+
private String customName;
-
+
private int tickCount = 0;
public TileEntityDecayablesChest() {
@@ -29,12 +47,22 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven
@Override
public void updateEntity() {
- try{
+
+ // Try do chesty stuff
+ try {
+ this.updateEntityChest();
+ } catch (Throwable t) {
+
+ }
+
+ try {
if (!this.worldObj.isRemote) {
-
this.tickCount++;
-
- if ((this.tickCount % 20) == 0) {
+ if ((this.tickCount % 10) == 0) {
+ cachedChestType = 1;
+ }
+
+ if ((this.tickCount % 20) == 0) {
for (ItemStack inv : this.getInventory().getInventory()) {
if (inv == null) {
continue;
@@ -44,23 +72,23 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven
tryUpdateDecayable(D, inv, this.worldObj);
}
}
- }
+ }
+ updateSlots();
}
+ } catch (final Throwable t) {
}
- catch (final Throwable t){}
}
-
-
+
public void tryUpdateDecayable(final DustDecayable b, ItemStack iStack, final World world) {
if (world == null || iStack == null) {
return;
- }
+ }
if (world.isRemote) {
return;
}
-
- boolean a1, a2;
+
+ boolean a1, a2;
int u = 0;
a1 = b.getIsActive(world, iStack);
a2 = b.tickItemTag(world, iStack);
@@ -71,13 +99,22 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven
a1 = b.getIsActive(world, iStack);
a2 = b.tickItemTag(world, iStack);
u++;
- }
-
- if (!a1 && !a2) {
- ItemStack replacement = ItemUtils.getSimpleStack(b.getDecayResult());
- replacement.stackSize=1;
- iStack = replacement.copy();
- markDirty();
+ }
+ Logger.INFO("| "+b.getUnlocalizedName()+" | "+a1+"/"+a2);
+
+ if (!a1 && !a2) {
+ ItemStack replacement = ItemUtils.getSimpleStack(b.getDecayResult());
+ replacement.stackSize = 1;
+ //iStack = replacement.copy();
+ for (int fff = 0; fff < this.inventoryContents.getSizeInventory(); fff++) {
+ if (this.inventoryContents.getStackInSlot(fff) == iStack) {
+ this.inventoryContents.setInventorySlotContents(fff, replacement.copy());
+ }
+ }
+
+ updateSlots();
+ this.inventoryContents.
+ markDirty();
}
}
@@ -151,17 +188,28 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven
@Override
public void openInventory() {
- this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1);
+ if (this.numPlayersUsing < 0) {
+ this.numPlayersUsing = 0;
+ }
+ if (!this.worldObj.isRemote) {
+ this.numPlayersUsing++;
+ cachedChestType = 1;
+ }
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing);
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
this.getInventory().openInventory();
}
@Override
- public void closeInventory() {
- this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1);
+ public void closeInventory() {
+ if (!this.worldObj.isRemote) {
+ this.numPlayersUsing--;
+ cachedChestType = 1;
+ }
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing);
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
- this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
this.getInventory().closeInventory();
}
@@ -173,8 +221,8 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven
@Override
public int[] getAccessibleSlotsFromSide(final int p_94128_1_) {
final int[] accessibleSides = new int[this.getSizeInventory()];
- for (int r=0; r<this.getInventory().getSizeInventory(); r++){
- accessibleSides[r]=r;
+ for (int r = 0; r < this.getInventory().getSizeInventory(); r++) {
+ accessibleSides[r] = r;
}
return accessibleSides;
@@ -182,12 +230,12 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven
@Override
public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) {
- return true;
+ return this.getInventory().isItemValidForSlot(0, p_102007_2_);
}
@Override
public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) {
- return true;
+ return this.getInventory().isItemValidForSlot(0, p_102008_2_);
}
public String getCustomName() {
@@ -208,4 +256,160 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven
return (this.customName != null) && !this.customName.equals("");
}
+ /**
+ * Causes the TileEntity to reset all it's cached values for it's container
+ * Block, metadata and in the case of chests, the adjacent chest check
+ */
+ public void updateContainingBlockInfo() {
+ super.updateContainingBlockInfo();
+ this.adjacentChestChecked = false;
+ }
+
+ /**
+ * Performs the check for adjacent chests to determine if this chest is double
+ * or not.
+ */
+ public void checkForAdjacentChests() {
+ if (!this.adjacentChestChecked) {
+ this.adjacentChestChecked = true;
+ this.adjacentChestZNeg = null;
+ this.adjacentChestXPos = null;
+ this.adjacentChestXNeg = null;
+ this.adjacentChestZPos = null;
+ }
+ }
+
+ public void updateEntityChest() {
+ float f;
+ this.prevLidAngle = this.lidAngle;
+ f = 0.04F;
+ double d2;
+ if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null
+ && this.adjacentChestXNeg == null) {
+ double d1 = (double) this.xCoord + 0.5D;
+ d2 = (double) this.zCoord + 0.5D;
+ this.worldObj.playSoundEffect(d1, (double) this.yCoord + 0.5D, d2, "random.chestopen", 0.5F,
+ this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
+ }
+
+ if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
+ float f1 = this.lidAngle;
+ if (this.numPlayersUsing > 0) {
+ //this.lidAngle += f;
+ this.lidAngle += (float) (f * (1 + 0.10 * 0.01));
+ } else {
+ //this.lidAngle -= f;
+ this.lidAngle -= (float) (f * (1 + 0.10 * 0.01));
+ }
+ if (this.lidAngle > 1.0F) {
+ this.lidAngle = 1.0F;
+ }
+ float f2 = 0.5F;
+ if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
+ d2 = (double) this.xCoord + 0.5D;
+ double d0 = (double) this.zCoord + 0.5D;
+ this.worldObj.playSoundEffect(d2, (double) this.yCoord + 0.5D, d0, "random.chestclosed", 0.5F,
+ this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
+ }
+
+ if (this.lidAngle < 0.0F) {
+ this.lidAngle = 0.0F;
+ }
+ }
+ }
+
+ /**
+ * Called when a client event is received with the event number and argument,
+ * see World.sendClientEvent
+ */
+ public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) {
+ if (p_145842_1_ == 1)
+ {
+ this.numPlayersUsing = p_145842_2_;
+ return true;
+ }
+ else
+ {
+ return super.receiveClientEvent(p_145842_1_, p_145842_2_);
+ }
+ }
+
+ /**
+ * invalidates a tile entity
+ */
+ public final void invalidate() {
+ super.invalidate();
+ cachedChestType = 1;
+ this.updateContainingBlockInfo();
+ this.checkForAdjacentChests();
+ }
+
+ private final int updateSlots() {
+ //Have slots changed?
+ if (cachedChestType == 0) {
+ return 0;
+ }
+ ItemUtils.organiseInventory(getInventory());
+ cachedChestType = 0;
+ return cachedChestType;
+
+/* //Try merge stacks
+ for (int i = 0; i < this.getSizeInventory(); i++) {
+ for (int i2 = 0; i2 < this.getSizeInventory(); i2++) {
+ if (i != i2) {
+ ItemStack[] t1 = new ItemStack[] {this.getStackInSlot(i), this.getStackInSlot(i2)};
+ if (t1[0] == null || t1[1] == null) {
+ continue;
+ }
+ else if (!GT_Utility.areStacksEqual(t1[0], t1[1])) {
+ continue;
+ }
+ //Try Merge
+ else {
+
+ if (GT_Utility.areStacksEqual(t1[0], t1[1])) {
+ while ((t1[0].stackSize < 64 && t1[1].stackSize > 0)) {
+ t1[0].stackSize++;
+ t1[1].stackSize--;
+ if (t1[1].stackSize <= 0) {
+ t1[1] = null;
+ break;
+ }
+ if (t1[0].stackSize == 64) {
+ break;
+ }
+ }
+ this.setInventorySlotContents(i, t1[1]);
+ this.setInventorySlotContents(i2, t1[0]);
+
+ }
+ }
+ }
+ }
+ }
+
+ //Move nulls to end
+ int count2 = 0;
+ for (int i = 0; i < this.getSizeInventory(); i++)
+ if (this.getStackInSlot(i) != null)
+ this.setInventorySlotContents(count2++, this.getStackInSlot(i));
+ while (count2 < this.getSizeInventory())
+ this.setInventorySlotContents(count2++, null);
+
+ //Sort by name
+ int arraySlot = 0;
+ HashMap<Integer, Pair<String, ItemStack>> aNameMap = new HashMap<Integer, Pair<String, ItemStack>>();
+
+ for (ItemStack ggg : this.inventoryContents.getInventory()) {
+ aNameMap.put(arraySlot++, new Pair<String, ItemStack>(ggg != null ? ggg.getDisplayName() : "", ggg));
+ }
+ arraySlot = 0;
+ String[] aNameMapInternal = new String[aNameMap.size()];
+ for (Pair pp : aNameMap.values()) {
+ aNameMapInternal[arraySlot++] = pp.getKey().toString();
+ }
+ Arrays.sort(aNameMapInternal); */
+
+ }
+
}
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
index cafbbbe196..4220d57de6 100644
--- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
@@ -100,6 +100,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory {
public boolean tryAddLoot() {
if (this.getInventory().getInventory() != null) {
int checkingSlot = 0;
+ ItemUtils.organiseInventory(getInventory());
final ItemStack loot = this.generateLootForFishTrap().copy();
try {
//Utils.LOG_WARNING("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage());
@@ -203,9 +204,6 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory {
if ((this.tickCount % 20) == 0) {
this.isInWater = this.isSurroundedByWater();
}
- else {
-
- }
if (this.isInWater) {
this.calculateTickrate();
@@ -219,13 +217,20 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory {
// x["+this.locationX+"] y["+this.locationY+"]
// z["+this.locationZ+"] (Ticking for loot every
// "+this.baseTickRate+" ticks)");
- this.tryAddLoot();
+
+ int aExtraLootChance = MathUtils.randInt(1, 1000);
+ if (aExtraLootChance == 1000) {
+ this.tryAddLoot();
+ this.tryAddLoot();
+ this.tryAddLoot();
+ }
+ else {
+ this.tryAddLoot();
+ }
+
this.markDirty();
}
else {
- Logger.WARNING("This Trap does not have enough water around it.");
- Logger.WARNING("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY
- + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)");
this.markDirty();
}
this.tickCount = 0;
@@ -240,20 +245,24 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory {
}
public void calculateTickrate() {
- int calculateTickrate = 0;
- if (this.waterSides <= 2) {
- calculateTickrate = 0;
- }
- else if ((this.waterSides > 2) && (this.waterSides < 4)) {
- calculateTickrate = 4800;
- }
- else if ((this.waterSides >= 4) && (this.waterSides < 6)) {
- calculateTickrate = 3600;
+ int water = this.waterSides;
+ int variance = (int) ((MathUtils.randInt(200, 2000)/water)*0.5);
+ if (water <= 1) {
+ this.baseTickRate = 0;
+ } else if (water == 2) {
+ this.baseTickRate = 6800;
+ } else if (water == 3) {
+ this.baseTickRate = 5600;
+ } else if (water == 4) {
+ this.baseTickRate = 4400;
+ } else if (water == 5) {
+ this.baseTickRate = 3200;
+ } else {
+ this.baseTickRate = 1750;
}
- else if (this.waterSides == 6) {
- calculateTickrate = 2400;
+ if (water > 1) {
+ this.baseTickRate += variance;
}
- this.baseTickRate = calculateTickrate;
}
public boolean anyPlayerInRange() {