@Override public void updateEntity() { if (mixTime > 0) { --mixTime; if (mixTime == 0) { mixPotions(); this.markDirty(); } else if (!canMix() || emulsifer != getStackInSlot(EMULSIFIER_INDEX)) { mixTime = 0; this.markDirty(); } } else if (canMix()) { mixTime = 400; emulsifer = getStackInSlot(EMULSIFIER_INDEX); } /* //TODO after I have a custom model: do I actually need this or do I just handle this in the model rendering? //Updates the block. Most likely to update the rendered model depending on how many potions are in the slots int i = this.getFilledSlots(); if (i != this.filledSlots) { this.filledSlots = i; this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, i, 2); } */ // this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); super.updateEntity(); }
@Override public void updateEntity() { super.updateEntity(); if (!worldObj.isRemote) FluidUtils.drainContainers(this, inventory, 0, 1); energySource.updateEntity(); if (tank.getFluidAmount() > 0 && energySource.getCapacity() - energySource.getEnergyStored() >= euTick) { Integer euPerBucket = fluids.get(tank.getFluidType().getName()); // float totalTicks = (float)euPerBucket / 8f; //x eu per bucket / 8 eu per tick // float millibucketsPerTick = 1000f / totalTicks; float millibucketsPerTick = 8000f / (float) euPerBucket; pendingWithdraw += millibucketsPerTick; int currentWithdraw = (int) pendingWithdraw; // float --> int conversion floors the float pendingWithdraw -= currentWithdraw; tank.drain(currentWithdraw, true); energySource.addEnergy(euTick); } if (tank.getFluidType() != null && getStackInSlot(2) == null) { inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock())); } else if (tank.getFluidType() == null && getStackInSlot(2) != null) { setInventorySlotContents(2, null); } }
@Override public void updateEntity() { super.updateEntity(); if (!worldObj.isRemote && !isAddedToEnergyNet) { Util.postTileAttachEvent(this); this.isAddedToEnergyNet = true; Util.scheduleBlockUpdate(this); } }
public void updateEntity() { super.updateEntity(); if (shouldTick) { if (tickCount < 360) { tickCount = tickCount + increment; } else { tickCount = 0; } } }
@Override public void updateEntity() { if (!this.created) { this.created = true; NetworkHelper.requestInitialData(this); NetworkHelper.announceBlockUpdate(worldObj, xCoord, yCoord, zCoord); } super.updateEntity(); // if (worldObj!=null) // worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); }
public void updateEntity() { // itemIndex = 4; if (!this.worldObj.isRemote) { } else { if (pm == null) pm = new ParticleBehaviors( Vec3.createVectorHelper(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F)); tickAnimate(); } super.updateEntity(); }
@Override public void updateEntity() { super.updateEntity(); // On the first update, try to add our node to nearby networks. We do // this in the update logic, not in validate() because we need to access // neighboring tile entities, which isn't possible in validate(). // We could alternatively check node != null && node.network() == null, // but this has somewhat better performance, and makes it clearer. if (!addedToNetwork) { addedToNetwork = true; // Note that joinOrCreateNetwork will try to connect each of our // sided nodes to their respective neighbor (sided) node. Network.joinOrCreateNetwork(this); } }
@Override public void updateEntity() { super.updateEntity(); if (!worldObj.isRemote) { if (tank.getFluidAmount() >= 0 && !(tank.getFluidAmount() == prevAmount)) { prevAmount = tank.getFluidAmount(); markDirty(); } if (initPer >= 0 && tank.getFluid() != null) { initPer--; if (initPer <= 0) { markDirty(); } } } }
@Override public void updateEntity() { super.updateEntity(); if (!remove && ticks == 5) { if (ticks == 0) { updateConnections(); } if (getHost() == null) { getWorldObj().setBlockToAir(xCoord, yCoord, zCoord); } else { TileTaskTickHandler.INSTANCE.addTileToBeRemoved(this); } } ticks++; }
@Override public void updateEntity() { super.updateEntity(); if (!worldObj.isRemote) { if (hasMaster()) { if (isMaster()) { if (checkMultiBlockForm()) { // Put stuff you want the multiblock to do here! System.out.println("trueealas"); } else resetStructure(); } else { if (checkForMaster()) reset(); } } else { // Constantly check if structure is formed until it is. if (checkMultiBlockForm()) setupStructure(); } } }
@Override public void updateEntity() { super.updateEntity(); getHandler().updateEntity(); // PUSH pressure // This had me busy for two days. TileEntity receiver = worldObj.getBlockTileEntity( xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ); if (receiver != null && receiver instanceof IEnergyHandler) { IEnergyHandler recv = (IEnergyHandler) receiver; int energyPushed = recv.receiveEnergy( facing.getOpposite(), storage.extractEnergy(Constants.MAX_TRANSFER_RF, true), true); if (energyPushed > 0) { recv.receiveEnergy(facing.getOpposite(), storage.extractEnergy(energyPushed, false), false); } } }
@Override public void updateEntity() { super.updateEntity(); int stored = storage.getEnergyStored(); if (!worldObj.isRemote) { Light = worldObj.isDaytime() && ((!worldObj.isRaining() && !worldObj.isThundering())) && !worldObj.provider.hasNoSky && worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord); if (canWork()) { storage.setEnergyStored( stored += this.getSolarLight(this.worldObj, this.xCoord, this.yCoord, this.zCoord)); } } // if (!this.worldObj.provider.hasNoSky) { // // // MinestellarLog.info("Solar Light: " + this.getSolarLight(this.worldObj, this.xCoord, // this.yCoord, this.zCoord)); // storage.setEnergyStored(stored += this.getSolarLight(this.worldObj, this.xCoord, // this.yCoord, this.zCoord)); // } }
/** * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses * this to count ticks and creates a new spawn inside its implementation. */ public void updateEntity() { super.updateEntity(); ++this.ticksSinceSync; if (this.accessTicks > 0 && !this.worldObj.isRemote) { --this.accessTicks; this.updateAccessTicks(); } float f; if (this.id > 0) { myChest = BoundChestWorldData.get(this.worldObj, "id" + this.id, 0); } if (myChest != null) { if (this.chestContents != myChest.getChestContents()) { this.accessTicks = 80; this.updateAccessTicks(); } this.chestContents = myChest.getChestContents(); } if (!this.worldObj.isRemote && this.numUsingPlayers != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0) { this.numUsingPlayers = 0; f = 5.0F; List list = this.worldObj.getEntitiesWithinAABB( EntityPlayer.class, AxisAlignedBB.getAABBPool() .getAABB( (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 entityplayer = (EntityPlayer) iterator.next(); if (entityplayer.openContainer instanceof ContainerChest) { IInventory iinventory = ((ContainerChest) entityplayer.openContainer).getLowerChestInventory(); if (iinventory == this || iinventory instanceof InventoryLargeChest && ((InventoryLargeChest) iinventory).isPartOfLargeChest(this)) { ++this.numUsingPlayers; } } } } this.prevLidAngle = this.lidAngle; f = 0.1F; double d0; if (this.numUsingPlayers > 0 && this.lidAngle == 0.0F) { double d1 = (double) this.xCoord + 0.5D; d0 = (double) this.zCoord + 0.5D; this.worldObj.playSoundEffect( d1, (double) this.yCoord + 0.5D, d0, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (this.numUsingPlayers == 0 && this.lidAngle > 0.0F || this.numUsingPlayers > 0 && this.lidAngle < 1.0F) { float f1 = this.lidAngle; if (this.numUsingPlayers > 0) { this.lidAngle += f; } else { this.lidAngle -= f; } if (this.lidAngle > 1.0F) { this.lidAngle = 1.0F; } float f2 = 0.5F; if (this.lidAngle < f2 && f1 >= f2) { d0 = (double) this.xCoord + 0.5D; double d2 = (double) this.zCoord + 0.5D; this.worldObj.playSoundEffect( d0, (double) this.yCoord + 0.5D, d2, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (this.lidAngle < 0.0F) { this.lidAngle = 0.0F; } } }
@Override public void updateEntity() { super.updateEntity(); if (syncTick == 0) { if (this.tracker == null) Notifier.notifyCustomMod( "EssentialCraft", "[WARNING][SEVERE]TileEntity " + this + " at pos " + this.xCoord + "," + this.yCoord + "," + this.zCoord + " tries to sync itself, but has no TileTracker attached to it! SEND THIS MESSAGE TO THE DEVELOPER OF THE MOD!"); else if (!this.worldObj.isRemote && this.tracker.tileNeedsSyncing()) { MiscUtils.sendPacketToAllAround( worldObj, getDescriptionPacket(), xCoord, yCoord, zCoord, this.worldObj.provider.dimensionId, 32); } syncTick = 60; } else --this.syncTick; if (requestSync && this.worldObj.isRemote) { requestSync = false; ECUtils.requestScheduledTileSync(this, EssentialCraftCore.proxy.getClientPlayer()); } if (++ticksSinceSync % 20 * 4 == 0) { worldObj.addBlockEvent( xCoord, yCoord, zCoord, this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord), 1, numUsingPlayers); } prevLidAngle = lidAngle; float angleIncrement = 0.1F; if (numUsingPlayers > 0 && lidAngle == 0.0F) { worldObj.playSoundEffect( xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F) { float var8 = lidAngle; if (numUsingPlayers > 0) { lidAngle += angleIncrement; } else { lidAngle -= angleIncrement; } if (lidAngle > 1.0F) { lidAngle = 1.0F; } if (lidAngle < 0.5F && var8 >= 0.5F) { worldObj.playSoundEffect( xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (lidAngle < 0.0F) { lidAngle = 0.0F; } } }
@Override public void updateEntity() { super.updateEntity(); World world = this.worldObj; if (!world.isRemote) { ItemStack inputItem = getStackInSlot(0); ItemStack spice = getStackInSlot(1); ItemStack outputItem = getStackInSlot(2); // progress if (inputItem != null && world.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && world.getBlock(xCoord, yCoord + 1, zCoord) == Blocks.anvil) { if (outputItem == null) { if ((inputItem.getItem() == Items.coffeeBean && inputItem.getItemDamage() == 3) || (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool) && inputItem.getItemDamage() != 15)) { this.progressTime++; } if (this.progressTime == 600) { this.progressTime = 0; if (inputItem.getItem() == Items.coffeeBean && inputItem.getItemDamage() == 3) { if (inputItem.stackSize >= 3) { if (inputItem.stackSize == 3) { inputItem = null; } else { inputItem.stackSize -= 3; } outputItem = new ItemStack(Items.coffeePowder, 1); } else { outputItem = new ItemStack(Items.mixedPowder, inputItem.stackSize); inputItem = null; } } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool) && inputItem.getItemDamage() == 0) { if (inputItem.stackSize >= 5) { if (inputItem.stackSize == 5) { inputItem = null; } else { inputItem.stackSize -= 5; } outputItem = new ItemStack(net.minecraft.init.Items.string, 3 + world.rand.nextInt(8)); } else { outputItem = new ItemStack(Items.mixedPowder, inputItem.stackSize); inputItem = null; } } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool) && inputItem.getItemDamage() == 3) { if (inputItem.stackSize >= 3) { if (inputItem.stackSize == 3) { inputItem = null; } else { inputItem.stackSize -= 3; } outputItem = new ItemStack(Items.cocoaPowder, 2); } else { outputItem = new ItemStack(Items.mixedPowder, inputItem.stackSize); inputItem = null; } } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool) && inputItem.getItemDamage() != 15) { if (inputItem.stackSize >= 2) { if (inputItem.stackSize == 2) { inputItem = null; } else { inputItem.stackSize -= 2; } outputItem = new ItemStack( net.minecraft.init.Items.dye, 3 + world.rand.nextInt(13), 15 - inputItem.getItemDamage()); } else { outputItem = new ItemStack(Items.mixedPowder, inputItem.stackSize); inputItem = null; } } } } else { if (allowProgress(inputItem, outputItem)) { this.progressTime++; } if (this.progressTime == 600) { this.progressTime = 0; if (inputItem.getItem() == Items.coffeeBean && inputItem.getItemDamage() == 3) { if (inputItem.stackSize >= 3) { if (inputItem.stackSize == 3) { inputItem = null; } else { inputItem.stackSize -= 3; } outputItem.stackSize++; } } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool) && inputItem.getItemDamage() == 0) { if (inputItem.stackSize >= 5) { if (inputItem.stackSize == 5) { inputItem = null; } else { inputItem.stackSize -= 5; } outputItem.stackSize += 3 + world.rand.nextInt(8); } } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool) && inputItem.getItemDamage() == 3) { if (inputItem.stackSize >= 3) { if (inputItem.stackSize == 3) { inputItem = null; } else { inputItem.stackSize -= 3; } outputItem.stackSize += 2; } } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool) && inputItem.getItemDamage() != 15) { if (inputItem.stackSize >= 2) { if (inputItem.stackSize == 2) { inputItem = null; } else { inputItem.stackSize -= 2; } outputItem.stackSize += 3 + world.rand.nextInt(13); } } } } setInventorySlotContents(0, inputItem); setInventorySlotContents(2, outputItem); } else { this.progressTime = 0; } } }
@Override public void writeToWorld(IBuilderContext context) { if (mode == Mode.ClearIfInvalid) { if (!getSchematic().isAlreadyBuilt(context, x, y, z)) { if (BuildCraftBuilders.dropBrokenBlocks) { BlockUtils.breakBlock((WorldServer) context.world(), x, y, z); } else { context.world().setBlockToAir(x, y, z); } } } else { try { getSchematic().placeInWorld(context, x, y, z, stackConsumed); // This is slightly hackish, but it's a very important way to verify // the stored requirements. if (!context.world().isAirBlock(x, y, z) && getSchematic().getBuildingPermission() == BuildingPermission.ALL && getSchematic() instanceof SchematicBlock) { SchematicBlock sb = (SchematicBlock) getSchematic(); // Copy the old array of stored requirements. ItemStack[] oldRequirementsArray = sb.storedRequirements; List<ItemStack> oldRequirements = Arrays.asList(oldRequirementsArray); sb.storedRequirements = new ItemStack[0]; sb.storeRequirements(context, x, y, z); for (ItemStack s : sb.storedRequirements) { boolean contains = false; for (ItemStack ss : oldRequirements) { if (StackHelper.isMatchingItem(s, ss)) { contains = true; break; } } if (!contains) { BCLog.logger.warn( "Blueprint has MISMATCHING REQUIREMENTS! Potential corrupted/hacked blueprint! Removed mismatched block."); BCLog.logger.warn( "Location: " + x + ", " + y + ", " + z + " - ItemStack: " + s.toString()); context.world().removeTileEntity(x, y, z); context.world().setBlockToAir(x, y, z); return; } } // Restore the stored requirements. sb.storedRequirements = oldRequirementsArray; } // Once the schematic has been written, we're going to issue // calls // to various functions, in particular updating the tile entity. // If these calls issue problems, in order to avoid corrupting // the world, we're logging the problem and setting the block to // air. TileEntity e = context.world().getTileEntity(x, y, z); if (e != null) { e.updateEntity(); } } catch (Throwable t) { t.printStackTrace(); context.world().setBlockToAir(x, y, z); } } }
public void updateEntity() { super.updateEntity(); this.bookSpreadPrev = this.bookSpread; this.bookRotationPrev = this.bookRotation2; EntityPlayer var1 = this.worldObj.getClosestPlayer( (double) ((float) this.xCoord + 0.5F), (double) ((float) this.yCoord + 0.5F), (double) ((float) this.zCoord + 0.5F), 3.0D); if (var1 != null) { double var2 = var1.posX - (double) ((float) this.xCoord + 0.5F); double var4 = var1.posZ - (double) ((float) this.zCoord + 0.5F); this.bookRotation = (float) Math.atan2(var4, var2); this.bookSpread += 0.1F; if (this.bookSpread < 0.5F || rand.nextInt(40) == 0) { float var6 = this.bx; do { this.bx += (float) (rand.nextInt(4) - rand.nextInt(4)); } while (var6 == this.bx); } } else { this.bookRotation += 0.02F; this.bookSpread -= 0.1F; } while (this.bookRotation2 >= (float) Math.PI) { this.bookRotation2 -= ((float) Math.PI * 2F); } while (this.bookRotation2 < -(float) Math.PI) { this.bookRotation2 += ((float) Math.PI * 2F); } while (this.bookRotation >= (float) Math.PI) { this.bookRotation -= ((float) Math.PI * 2F); } while (this.bookRotation < -(float) Math.PI) { this.bookRotation += ((float) Math.PI * 2F); } float var7; for (var7 = this.bookRotation - this.bookRotation2; var7 >= (float) Math.PI; var7 -= ((float) Math.PI * 2F)) {; } while (var7 < -(float) Math.PI) { var7 += ((float) Math.PI * 2F); } this.bookRotation2 += var7 * 0.4F; if (this.bookSpread < 0.0F) { this.bookSpread = 0.0F; } if (this.bookSpread > 1.0F) { this.bookSpread = 1.0F; } ++this.tickCount; this.pageFlipPrev = this.pageFlip; float var3 = (this.bx - this.pageFlip) * 0.4F; float var8 = 0.2F; if (var3 < -var8) { var3 = -var8; } if (var3 > var8) { var3 = var8; } this.bz += (var3 - this.bz) * 0.9F; this.pageFlip += this.bz; }
public void updateEntity() { super.updateEntity(); ++this.ticksSinceSync; if (!this.worldObj.isRemote && this.numUsingPlayers != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0) { this.numUsingPlayers = 0; List list = this.worldObj.getEntitiesWithinAABB( EntityPlayer.class, AxisAlignedBB.getAABBPool() .getAABB( this.xCoord - 5, this.yCoord - 5, this.zCoord - 5, this.xCoord + 6, this.yCoord + 6, this.zCoord + 6)); Iterator iterator = list.iterator(); while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); if (entityplayer.openContainer instanceof ContainerPortableChest) { ++this.numUsingPlayers; } } } this.prevLidAngle = this.lidAngle; if (this.numUsingPlayers > 0 && this.lidAngle == 0.0F) { this.worldObj.playSoundEffect( ((double) this.xCoord + 0.5), (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (this.numUsingPlayers == 0 && this.lidAngle > 0.0F || this.numUsingPlayers > 0 && this.lidAngle < 1.0F) { float f1 = this.lidAngle; if (this.numUsingPlayers > 0) { this.lidAngle += 0.1F; } else { this.lidAngle -= 0.1F; } if (this.lidAngle > 1.0F) { this.lidAngle = 1.0F; } float f2 = 0.5F; if (this.lidAngle < f2 && f1 >= f2) { this.worldObj.playSoundEffect( (double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (this.lidAngle < 0.0F) { this.lidAngle = 0.0F; } } }