Just needs the transaction redone

This commit is contained in:
Cricket committed 2014-12-24 11:12:30 -05:00
1 parent 3eb7d90c89
commit 29293b01e6
6 files changed
+112 -100

No files matched your search

@@ -134,5 +134,11 @@ public class Crafting {
GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.jackolantern[x]), new Object[]{new ItemStack(ModBlocks.pumpkin[x], 1), new ItemStack(Item.getItemFromBlock(Blocks.torch), 1)});
}
}
if(Configurations.featureEnabled("chest")){
for(int x = 0; x < 16; x++){
GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.present[x]), new Object[]{new ItemStack(Blocks.chest, 1), new ItemStack(Items.dye, 1, x)});
}
}
}
}
@@ -1,9 +1,8 @@
package com.cricketcraft.chisel.block.tileentity;
import com.cricketcraft.chisel.block.BlockCarvable;
import com.cricketcraft.chisel.carving.CarvableHelper;
import com.cricketcraft.chisel.init.ModItems;
import net.minecraft.block.Block;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
@@ -15,8 +14,6 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityAutoChisel extends TileEntity implements ISidedInventory {
@@ -93,68 +90,61 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
if(isFaster){
if(!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0){
doTransaction();
}
} else {
if(!worldObj.isRemote && worldObj.getWorldTime() % 40 == 0){
doTransaction();
}
}
markDirty();
}
private void doTransaction(){
if(inventory[BASE] != null && inventory[TARGET] != null){
if(inventory[BASE].getItem() instanceof ItemBlock && inventory[TARGET].getItem() instanceof ItemBlock){
Block base = Block.getBlockFromItem(inventory[BASE].getItem());
Block target = Block.getBlockFromItem(inventory[TARGET].getItem());
if(base instanceof BlockCarvable){
BlockCarvable baseCarvable = (BlockCarvable) base;
if(baseCarvable.carverHelper.variations.contains(target)){
if(isStackMode){
if(inventory[BASE].stackSize == inventory[BASE].getMaxStackSize()){
if(inventory[BASE] != null && inventory[TARGET] != null){
if(inventory[BASE].getItem() instanceof ItemBlock && inventory[TARGET].getItem() instanceof ItemBlock){
if(inventory[BASE].getUnlocalizedName().equalsIgnoreCase(inventory[TARGET].getUnlocalizedName())){
if(isStackMode){
if(inventory[BASE].stackSize == inventory[BASE].getMaxStackSize()){
if(inventory[OUTPUT] == null){
inventory[OUTPUT] = inventory[BASE];
inventory[BASE] = null;
}
}
} else {
if(inventory[OUTPUT] == null){
inventory[OUTPUT] = inventory[BASE];
inventory[BASE].stackSize--;
} else if(inventory[BASE].stackSize != 0){
inventory[OUTPUT].stackSize++;
inventory[BASE].stackSize--;
} else {
inventory[BASE] = null;
}
}
} else {
if(inventory[OUTPUT] == null){
inventory[OUTPUT] = new ItemStack(base, 1, inventory[BASE].getItemDamage());
inventory[BASE].stackSize--;
} else if(inventory[BASE].stackSize != 0){
inventory[OUTPUT].stackSize++;
inventory[BASE].stackSize--;
}
}
}
} else if(target instanceof BlockCarvable){
BlockCarvable targetCarvable = (BlockCarvable) target;
if(targetCarvable.carverHelper.variations.contains(base)){
if(isStackMode){
if(inventory[BASE].stackSize == inventory[BASE].getMaxStackSize()){
}
}
} else {
if(!worldObj.isRemote && worldObj.getWorldTime() % 100 == 0){
if(inventory[BASE] != null && inventory[TARGET] != null){
if(inventory[BASE].getItem() instanceof ItemBlock && inventory[TARGET].getItem() instanceof ItemBlock){
if(inventory[BASE].getUnlocalizedName().equalsIgnoreCase(inventory[TARGET].getUnlocalizedName())){
if(isStackMode){
if(inventory[BASE].stackSize == inventory[BASE].getMaxStackSize()){
if(inventory[OUTPUT] == null){
inventory[OUTPUT] = inventory[BASE];
inventory[BASE] = null;
}
}
} else {
if(inventory[OUTPUT] == null){
inventory[OUTPUT] = inventory[BASE];
inventory[BASE].stackSize--;
} else if(inventory[BASE].stackSize != 0){
inventory[OUTPUT].stackSize++;
inventory[BASE].stackSize--;
} else {
inventory[BASE] = null;
}
}
} else {
if(inventory[OUTPUT] == null){
inventory[OUTPUT] = new ItemStack(base, 1, inventory[BASE].getItemDamage());
inventory[BASE].stackSize--;
} else if(inventory[BASE].stackSize != 0){
inventory[OUTPUT].stackSize++;
inventory[BASE].stackSize--;
}
}
}
}
}
}
markDirty();
}
@Override
@@ -5,6 +5,7 @@ import com.cricketcraft.chisel.inventory.ContainerPresent;
import com.cricketcraft.chisel.inventory.InventoryLargePresent;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB;
@@ -15,6 +16,7 @@ import java.util.List;
public class TileEntityPresent extends TileEntityChest {
public int type;
private int ticksSinceSync;
public TileEntityPresent(int type) {
this.type = type;
@@ -115,78 +117,96 @@ public class TileEntityPresent extends TileEntityChest {
@Override
public void updateEntity() {
super.updateEntity();
checkForAdjacentPresents();
this.checkForAdjacentChests();
++this.ticksSinceSync;
float f;
if (!worldObj.isRemote && numPlayersUsing != 0 && (+xCoord + yCoord + zCoord) % 200 == 0) {
numPlayersUsing = 0;
if (!this.worldObj.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0)
{
this.numPlayersUsing = 0;
f = 5.0F;
List<?> list = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord - f, yCoord - f, zCoord - f, (xCoord + 1) + f, (yCoord + 1) + f, (zCoord + 1) + f));
Iterator<?> iterator = list.iterator();
List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox((double)((float)this.xCoord - f), (double)((float)this.yCoord - f), (double)((float)this.zCoord - f), (double)((float)(this.xCoord + 1) + f), (double)((float)(this.yCoord + 1) + f), (double)((float)(this.zCoord + 1) + f)));
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
EntityPlayer player = (EntityPlayer) iterator.next();
while (iterator.hasNext())
{
EntityPlayer entityplayer = (EntityPlayer)iterator.next();
if (player.openContainer instanceof ContainerPresent) {
IInventory inventory = ((ContainerPresent) player.openContainer).getLowerPresentInventory();
if (entityplayer.openContainer instanceof ContainerPresent)
{
IInventory iinventory = ((ContainerChest)entityplayer.openContainer).getLowerChestInventory();
if (inventory == this || inventory instanceof InventoryLargePresent && ((InventoryLargePresent) inventory).isPartOfLargePresent(this)) {
++numPlayersUsing;
if (iinventory == this || iinventory instanceof InventoryLargePresent && ((InventoryLargePresent)iinventory).isPartOfLargePresent(this))
{
++this.numPlayersUsing;
}
}
}
}
prevLidAngle = lidAngle;
this.prevLidAngle = this.lidAngle;
f = 0.1F;
double d2;
if (numPlayersUsing > 0 && lidAngle == 0.0F && adjacentChestZNeg == null && adjacentChestXNeg == null) {
double d1 = xCoord + 0.5D;
d2 = xCoord + 0.5D;
if (adjacentChestZPos != null) {
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;
if (this.adjacentChestZPos != null)
{
d2 += 0.5D;
}
if (adjacentChestXPos != null) {
if (this.adjacentChestXPos != null)
{
d1 += 0.5D;
}
worldObj.playSoundEffect(d1, yCoord + 0.5D, d2, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
this.worldObj.playSoundEffect(d1, (double)this.yCoord + 0.5D, d2, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (numPlayersUsing == 0 && lidAngle > 0.0F || numPlayersUsing > 0 && lidAngle < 1.0F) {
float f1 = lidAngle;
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F)
{
float f1 = this.lidAngle;
if (numPlayersUsing > 0) {
lidAngle += f;
} else {
lidAngle -= f;
if (this.numPlayersUsing > 0)
{
this.lidAngle += f;
}
else
{
this.lidAngle -= f;
}
if (lidAngle > 1.0F) {
lidAngle = 1.0F;
if (this.lidAngle > 1.0F)
{
this.lidAngle = 1.0F;
}
float f2 = 0.5F;
if (lidAngle < f2 && f1 >= f2 && adjacentChestZNeg == null && adjacentChestXNeg == null) {
d2 = xCoord + 0.5D;
double d0 = zCoord + 0.5D;
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;
if (adjacentChestZPos != null) {
if (this.adjacentChestZPos != null)
{
d0 += 0.5D;
}
if (adjacentChestXPos != null) {
if (this.adjacentChestXPos != null)
{
d2 += 0.5D;
}
worldObj.playSoundEffect(d2, yCoord + 0.5D, d0, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
this.worldObj.playSoundEffect(d2, (double)this.yCoord + 0.5D, d0, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (lidAngle < 0.0F) {
lidAngle = 0.0F;
if (this.lidAngle < 0.0F)
{
this.lidAngle = 0.0F;
}
}
}
@@ -205,12 +225,10 @@ public class TileEntityPresent extends TileEntityChest {
@Override
public void closeInventory() {
if (getBlockType() instanceof BlockPresent) {
--numPlayersUsing;
worldObj.addBlockEvent(xCoord, yCoord, zCoord, getBlockType(), 1, numPlayersUsing);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, getBlockType());
}
numPlayersUsing = 0;
worldObj.addBlockEvent(xCoord, yCoord, zCoord, getBlockType(), 1, numPlayersUsing);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, getBlockType());
}
@Override
@@ -32,13 +32,13 @@ public class ItemPresentRenderer implements IItemRenderer {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Chisel.MOD_ID, present.getKindOfChest(meta) + ".png"));
switch (type) {
case ENTITY:
renderBlock(0.0F, 0.0F, 0.0F);
renderBlock(0.0F, 1.0F, 0.0F);
break;
case EQUIPPED:
renderBlock(0.0F, 0.0F, 0.0F);
renderBlock(0.5F, 1.5F, 0.5F);
break;
case EQUIPPED_FIRST_PERSON:
renderBlock(0.0F, 0.0F, 0.0F);
renderBlock(0.5F, 1.0F, 0.5F);
break;
case INVENTORY:
renderInventory(1.0F, 1.0F, 1.0F);
@@ -1343,7 +1343,6 @@ public class ModBlocks {
GameRegistry.registerBlock(present[x], "chest" + x);
Carving.chisel.addVariation("present", present[x], 0, (x + 1));
}
Carving.chisel.addVariation("chest", Blocks.chest, 0, 0);
Carving.chisel.registerOre("chest", "chest");
}
@@ -1,13 +1,12 @@
package com.cricketcraft.chisel.inventory;
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
public class ContainerAutoChisel extends Container {
public static TileEntityAutoChisel autoChisel;
@@ -21,10 +20,10 @@ public class ContainerAutoChisel extends Container {
addSlotToContainer(new Slot(tileEntityAutoChisel, 0, 53, 15));
addSlotToContainer(new Slot(tileEntityAutoChisel, 1, 78, 51));
addSlotToContainer(new Slot(tileEntityAutoChisel, 2, 103, 15));
for(int x = 0; x < 3; x++){
addSlotToContainer(new Slot(tileEntityAutoChisel, (x + 3), 200, 15 * 9 + 9));
}
addSlotToContainer(new Slot(tileEntityAutoChisel, 3, 151, 51));
addSlotToContainer(new Slot(tileEntityAutoChisel, 4, 151, 31));
addSlotToContainer(new Slot(tileEntityAutoChisel, 5, 151, 11));
bindPlayerInventory(player);
}