Skip to content

Commit

Permalink
Merge remote-tracking branch 'Gordon-Frohman/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Jun 28, 2024
2 parents a1c06c3 + 874fc2c commit a9c994f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
22 changes: 22 additions & 0 deletions src/main/java/twilightforest/block/BlockTFChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.minecraft.block.BlockChest;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;
Expand Down Expand Up @@ -62,4 +64,24 @@ public TileEntity createNewTileEntity(World worldIn, int meta) {
return tileentitychest;
}

/**
* Called when a tile entity on a side of this block changes is created or is destroyed.
*
* @param world The world
* @param x The x position of this block instance
* @param y The y position of this block instance
* @param z The z position of this block instance
* @param tileX The x position of the tile that changed
* @param tileY The y position of the tile that changed
* @param tileZ The z position of the tile that changed
*/
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) {
super.onNeighborChange(world, x, y, z, tileX, tileY, tileZ);
TileEntityChest tileentitychest = (TileEntityChest) world.getTileEntity(x, y, z);

if (tileentitychest != null) {
tileentitychest.updateContainingBlockInfo();
}
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package twilightforest.client.renderer;

import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
Expand Down Expand Up @@ -47,9 +46,9 @@ public void renderTileEntityAt(TileEntityChest tileEntity, double x, double y, d
Block block = tileEntity.getBlockType();
i = tileEntity.getBlockMetadata();

if (block instanceof BlockChest && i == 0) {
if (block instanceof BlockTFChest && i == 0) {
try {
((BlockChest) block).func_149954_e(
((BlockTFChest) block).func_149954_e(
tileEntity.getWorldObj(),
tileEntity.xCoord,
tileEntity.yCoord,
Expand All @@ -64,13 +63,17 @@ public void renderTileEntityAt(TileEntityChest tileEntity, double x, double y, d
i = tileEntity.getBlockMetadata();
}

tileEntity.checkForAdjacentChests();
((TileEntityTFChest) tileEntity).checkForAdjacentChests();
}

BlockTFChest.WoodType type = (((TileEntityTFChest) tileEntity).cachedMaterial == WoodType.NULL)
? ((BlockTFChest) tileEntity.getWorldObj()
.getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord)).getWoodType()
: ((TileEntityTFChest) tileEntity).cachedMaterial;
WoodType type = WoodType.CANOPY;
if (tileEntity instanceof TileEntityTFChest) {
if (((TileEntityTFChest) tileEntity).cachedMaterial == WoodType.NULL) {
Block block = tileEntity.getWorldObj()
.getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
if (block instanceof BlockTFChest) type = ((BlockTFChest) block).getWoodType();
} else type = ((TileEntityTFChest) tileEntity).cachedMaterial;
}

if (tileEntity.adjacentChestZNeg == null && tileEntity.adjacentChestXNeg == null) {
ModelChest modelchest;
Expand Down Expand Up @@ -150,6 +153,6 @@ public void renderTileEntityAt(TileEntityChest tileEntity, double x, double y, d

public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_,
float p_147500_8_) {
this.renderTileEntityAt((TileEntityChest) p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_);
this.renderTileEntityAt((TileEntityTFChest) p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_);
}
}
12 changes: 6 additions & 6 deletions src/main/java/twilightforest/tileentity/TileEntityTFChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ public void checkForAdjacentChests() {
this.adjacentChestZPos = null;

if (this.func_145977_a(this.xCoord - 1, this.yCoord, this.zCoord)) {
this.adjacentChestXNeg = (TileEntityChest) this.worldObj
this.adjacentChestXNeg = (TileEntityTFChest) this.worldObj
.getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord);
}

if (this.func_145977_a(this.xCoord + 1, this.yCoord, this.zCoord)) {
this.adjacentChestXPos = (TileEntityChest) this.worldObj
this.adjacentChestXPos = (TileEntityTFChest) this.worldObj
.getTileEntity(this.xCoord + 1, this.yCoord, this.zCoord);
}

if (this.func_145977_a(this.xCoord, this.yCoord, this.zCoord - 1)) {
this.adjacentChestZNeg = (TileEntityChest) this.worldObj
this.adjacentChestZNeg = (TileEntityTFChest) this.worldObj
.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 1);
}

if (this.func_145977_a(this.xCoord, this.yCoord, this.zCoord + 1)) {
this.adjacentChestZPos = (TileEntityChest) this.worldObj
this.adjacentChestZPos = (TileEntityTFChest) this.worldObj
.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 1);
}

Expand All @@ -77,13 +77,13 @@ private boolean func_145977_a(int p_145977_1_, int p_145977_2_, int p_145977_3_)
return false;
} else {
Block block = this.worldObj.getBlock(p_145977_1_, p_145977_2_, p_145977_3_);
Block thisBlock = this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord);
Block thisBlock = this.getBlockType();
return block instanceof BlockTFChest && thisBlock instanceof BlockTFChest
&& ((BlockTFChest) block).getWoodType() == ((BlockTFChest) thisBlock).getWoodType();
}
}

private void func_145978_a(TileEntityChest p_145978_1_, int p_145978_2_) {
private void func_145978_a(TileEntityTFChest p_145978_1_, int p_145978_2_) {
if (p_145978_1_.isInvalid()) {
this.adjacentChestChecked = false;
} else if (this.adjacentChestChecked) {
Expand Down

0 comments on commit a9c994f

Please sign in to comment.