mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-11 15:57:31 +00:00
Merge branch 'master' of https://github.com/TheCricket/Chisel-2
This commit is contained in:
commit
7be3bb49ef
6 files changed
+21
-241
No files matched your search
@@ -1,6 +1,5 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
@@ -16,7 +15,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntityOcelot;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -48,15 +46,15 @@ public class BlockPresent extends BlockChest implements ICarvable {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
if (calendar.get(2) + 1 == 12 || calendar.get(2) + 1 == 1) {
|
||||
isChristmas = true;//The Christmas Season lasts for december and january
|
||||
isChristmas = true; //The Christmas Season lasts for december and january
|
||||
} else {
|
||||
isChristmas = false;
|
||||
isChristmas = false; //TODO: THESE NEED TO EXIST
|
||||
}
|
||||
}
|
||||
|
||||
public String getKindOfChest(int type){
|
||||
switch (type){
|
||||
case 0:
|
||||
case 0: //TODO: |----------these are fine-------------| |------these are missing-------|
|
||||
return isChristmas? "textures/blocks/present/presentChest0" : "textures/blocks/present/chest0";
|
||||
case 1:
|
||||
return isChristmas? "textures/blocks/present/presentChest1" : "textures/blocks/present/chest1";
|
||||
@@ -162,7 +160,7 @@ public class BlockPresent extends BlockChest implements ICarvable {
|
||||
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
|
||||
}
|
||||
|
||||
if ((left == this || right == this) && (metadata == 4 || metadata == 5)) {
|
||||
if ((left == this || right == this) && (metadata == 2 || metadata == 3)) {
|
||||
if (left == this) {
|
||||
world.setBlockMetadataWithNotify(x - 1, y, z, metadata, 3);
|
||||
} else {
|
||||
@@ -251,119 +249,6 @@ public class BlockPresent extends BlockChest implements ICarvable {
|
||||
super.breakBlock(world, x, y, z, this, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float x1, float y1, float z1) {
|
||||
if (!world.isRemote) {
|
||||
player.openGui(Chisel.instance, 2, world, x, y, z);
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
if (world.getBlock(x, y, z - 1) == this) {
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
|
||||
} else if (world.getBlock(x, y, z + 1) == this) {
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||
} else if (world.getBlock(x - 1, y, z) == this) {
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
|
||||
} else if (world.getBlock(x + 1, y, z) == this) {
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
|
||||
} else {
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
this.changeMetadataBasedOffSpecs(world, x, y, z);
|
||||
Block back = world.getBlock(x, y, z - 1);
|
||||
Block front = world.getBlock(x, y, z + 1);
|
||||
Block left = world.getBlock(x - 1, y, z);
|
||||
Block right = world.getBlock(x + 1, y, z);
|
||||
|
||||
if (back == this) {
|
||||
this.changeMetadataBasedOffSpecs(world, x, y, z - 1);
|
||||
}
|
||||
|
||||
if (front == this) {
|
||||
this.changeMetadataBasedOffSpecs(world, x, y, z + 1);
|
||||
}
|
||||
|
||||
if (left == this) {
|
||||
this.changeMetadataBasedOffSpecs(world, x - 1, y, z);
|
||||
}
|
||||
|
||||
if (right == this) {
|
||||
this.changeMetadataBasedOffSpecs(world, x + 1, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeMetadataBasedOffSpecs(World world, int x, int y, int z) {
|
||||
if (!world.isRemote) {
|
||||
Block back = world.getBlock(x, y, z - 1);
|
||||
Block front = world.getBlock(x, y, z + 1);
|
||||
Block left = world.getBlock(x - 1, y, z);
|
||||
Block right = world.getBlock(x + 1, y, z);
|
||||
boolean flag = true, flag1;
|
||||
byte metadata;
|
||||
int x1, blockMeta, z1;
|
||||
Block backLeft, frontRight;
|
||||
|
||||
if (front != this && back != this) {
|
||||
if (left != this && right != this) {
|
||||
metadata = 3;
|
||||
|
||||
if (front.func_149730_j() && !back.func_149730_j()) {
|
||||
metadata = 3;
|
||||
}
|
||||
|
||||
if (back.func_149730_j() && !front.func_149730_j()) {
|
||||
metadata = 2;
|
||||
}
|
||||
|
||||
if (left.func_149730_j() && !right.func_149730_j()) {
|
||||
metadata = 5;
|
||||
}
|
||||
|
||||
if (right.func_149730_j() && !left.func_149730_j()) {
|
||||
metadata = 4;
|
||||
}
|
||||
} else {
|
||||
x1 = back == this ? x - 1 : x + 1;
|
||||
backLeft = world.getBlock(x1, y, z - 1);
|
||||
z1 = back == this ? z - 1 : z + 1;
|
||||
frontRight = world.getBlock(x + 1, y, z1);
|
||||
metadata = 5;
|
||||
flag1 = true;
|
||||
|
||||
if (back == this) {
|
||||
blockMeta = world.getBlockMetadata(x, y, z - 1);
|
||||
} else {
|
||||
blockMeta = world.getBlockMetadata(x, y, z + 1);
|
||||
}
|
||||
|
||||
if (blockMeta == 4) {
|
||||
metadata = 4;
|
||||
}
|
||||
|
||||
if ((left.func_149730_j() || backLeft.func_149730_j()) && !right.func_149730_j() && !frontRight.func_149730_j()) {
|
||||
metadata = 5;
|
||||
}
|
||||
|
||||
if ((right.func_149730_j() || frontRight.func_149730_j()) && !left.func_149730_j() && !backLeft.func_149730_j()) {
|
||||
metadata = 4;
|
||||
}
|
||||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2) {
|
||||
return new TileEntityPresent(type);
|
||||
@@ -400,7 +285,7 @@ public class BlockPresent extends BlockChest implements ICarvable {
|
||||
}
|
||||
|
||||
public IInventory getInventory(World world, int x, int y, int z) {
|
||||
Object object = (TileEntityPresent) world.getTileEntity(x, y, z);
|
||||
Object object = world.getTileEntity(x, y, z);
|
||||
|
||||
if (object == null) {
|
||||
return null;
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityPresent extends TileEntityChest {
|
||||
|
||||
public int type;
|
||||
private int ticksSinceSync;
|
||||
|
||||
@@ -24,94 +23,7 @@ public class TileEntityPresent extends TileEntityChest {
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
public void checkIfAdjacentBlocksAreMe(TileEntityPresent tile, int meta) {
|
||||
if (tile.isInvalid()) {
|
||||
this.adjacentChestChecked = false;
|
||||
} else if (this.adjacentChestChecked) {
|
||||
switch (meta) {
|
||||
case 0:
|
||||
if (this.adjacentChestZPos != tile) {
|
||||
this.adjacentChestChecked = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
if (this.adjacentChestXNeg != tile) {
|
||||
this.adjacentChestChecked = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (this.adjacentChestZNeg != tile) {
|
||||
this.adjacentChestChecked = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case 3:
|
||||
if (this.adjacentChestXPos != tile) {
|
||||
this.adjacentChestChecked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkForAdjacentPresents() {
|
||||
if (!this.adjacentChestChecked) {
|
||||
TileEntityPresent zNeg = (TileEntityPresent) this.adjacentChestZNeg;
|
||||
TileEntityPresent xPos = (TileEntityPresent) this.adjacentChestXPos;
|
||||
TileEntityPresent xNeg = (TileEntityPresent) this.adjacentChestXNeg;
|
||||
TileEntityPresent zPos = (TileEntityPresent) this.adjacentChestZPos;
|
||||
this.adjacentChestChecked = true;
|
||||
|
||||
if (this.isBlockPresent(xCoord - 1, yCoord, zCoord)) {
|
||||
xNeg = (TileEntityPresent) this.worldObj.getTileEntity(xCoord - 1, yCoord, zCoord);
|
||||
}
|
||||
|
||||
if (this.isBlockPresent(xCoord + 1, yCoord, zCoord)) {
|
||||
xPos = (TileEntityPresent) this.worldObj.getTileEntity(xCoord + 1, yCoord, zCoord);
|
||||
}
|
||||
|
||||
if (this.isBlockPresent(xCoord, yCoord, zCoord - 1)) {
|
||||
zNeg = (TileEntityPresent) this.worldObj.getTileEntity(xCoord, yCoord, zCoord - 1);
|
||||
}
|
||||
|
||||
if (this.isBlockPresent(xCoord, yCoord, zCoord + 1)) {
|
||||
zPos = (TileEntityPresent) this.worldObj.getTileEntity(xCoord, yCoord, zCoord + 1);
|
||||
}
|
||||
|
||||
if (this.adjacentChestZNeg != null) {
|
||||
zNeg.checkIfAdjacentBlocksAreMe(this, 0);
|
||||
}
|
||||
|
||||
if (this.adjacentChestZPos != null) {
|
||||
zPos.checkIfAdjacentBlocksAreMe(this, 2);
|
||||
}
|
||||
|
||||
if (this.adjacentChestXPos != null) {
|
||||
xPos.checkIfAdjacentBlocksAreMe(this, 1);
|
||||
}
|
||||
|
||||
if (this.adjacentChestXNeg != null) {
|
||||
xNeg.checkIfAdjacentBlocksAreMe(this, 3);
|
||||
}
|
||||
|
||||
this.adjacentChestXNeg = xNeg;
|
||||
this.adjacentChestXPos = xPos;
|
||||
this.adjacentChestZPos = zPos;
|
||||
this.adjacentChestZNeg = zNeg;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBlockPresent(int x, int y, int z) {
|
||||
if (this.worldObj == null) {
|
||||
return false;
|
||||
} else {
|
||||
Block block = this.worldObj.getBlock(x, y, z);
|
||||
return block instanceof BlockPresent;
|
||||
}
|
||||
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,31 +122,4 @@ public class TileEntityPresent extends TileEntityChest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
if (numPlayersUsing < 0) {
|
||||
numPlayersUsing = 0;
|
||||
}
|
||||
|
||||
++numPlayersUsing;
|
||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, getBlockType(), 1, numPlayersUsing);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, getBlockType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
numPlayersUsing = 0;
|
||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, getBlockType(), 1, numPlayersUsing);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, getBlockType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
updateContainingBlockInfo();
|
||||
checkForAdjacentPresents();
|
||||
}
|
||||
}
|
||||
@@ -31,14 +31,14 @@ public class RenderPresent extends TileEntityChestRenderer {
|
||||
|
||||
if (block instanceof BlockPresent && i == 0) {
|
||||
try {
|
||||
((BlockPresent) block).changeMetadataBasedOffSpecs(present.getWorldObj(), present.xCoord, present.yCoord, present.zCoord);
|
||||
((BlockPresent) block).func_149954_e(present.getWorldObj(), present.xCoord, present.yCoord, present.zCoord);
|
||||
} catch (ClassCastException e) {
|
||||
FMLLog.severe("[Chisel 2] Attempted to render a present at %d, %d, %d that was not a present", present.xCoord, present.yCoord, present.zCoord);
|
||||
}
|
||||
i = present.getBlockMetadata();
|
||||
}
|
||||
|
||||
present.checkForAdjacentPresents();
|
||||
present.checkForAdjacentChests();
|
||||
}
|
||||
|
||||
if (present.adjacentChestZNeg == null && present.adjacentChestXNeg == null) {
|
||||
|
||||
Reference in new issue
Block a user