public World getWorld() { return this.machine.getWorld(); } }
public boolean isServer() { return !this.machine.getWorld().isRemote; }
private void addToEnergyNet() { World world = this.getMachine().getWorld(); if (world == null || world.isRemote) { return; } if (Mods.IC2.active()) { this.do_addToEnergyNet(); } }
private void removeFromEnergyNet() { World world = this.getMachine().getWorld(); if (world == null || world.isRemote) { return; } if (Mods.IC2.active()) { this.do_removeFromEnergyNet(); } }
@Override public void onDestruction() { IMachine machine = getMachine(); World world = machine.getWorld(); Random rand = world.rand; BlockPos pos = machine.getTileEntity().getPos(); for (InventorySlot slot : this.inventory.values()) { ItemStack stack = slot.getItemStack(); if (slot.isRecipe() || stack.isEmpty()) { continue; } final float xOffset = rand.nextFloat() * 0.8f + 0.1f; final float yOffset = rand.nextFloat() * 0.8f + 0.1f; final float zOffset = rand.nextFloat() * 0.8f + 0.1f; final EntityItem entityItem = new EntityItem(world, pos.getX() + xOffset, pos.getY() + yOffset, pos.getZ() + zOffset, stack.copy()); entityItem.motionX = (float) rand.nextGaussian() * ACCEL; entityItem.motionY = (float) rand.nextGaussian() * ACCEL + 0.2f; entityItem.motionZ = (float) rand.nextGaussian() * ACCEL; world.spawnEntity(entityItem); } }
@SideOnly(Side.CLIENT) @Override public void renderInWorld(final double x, final double y, final double z) { final ItemStack stack = this.getUtil().getStack(0); World world = this.getMachine().getWorld(); this.entityItemRenderer.renderInWorld(stack, world, x + 0.5, y + 0.8, z + 0.5); }
@SideOnly(Side.CLIENT) @Override public void renderInWorld(final double x, final double y, final double z) { if (!this.getUtil().getProcess().isInProgress()) { return; } final ItemStack stack = this.getUtil().getStack(9); World world = this.getMachine().getWorld(); this.entityItemRenderer.renderInWorld(stack, world, x + 0.5, y + 0.8, z + 0.5); }
@SideOnly(Side.CLIENT) @Override public void renderInWorld(double x, final double y, final double z) { if (!this.getUtil().getProcess().isInProgress()) { return; } final ItemStack stack = this.getUtil().getStack(9); World world = this.getMachine().getWorld(); this.entityItemRenderer.renderInWorld(stack, world, x + 0.5, y + 1, z + 0.5); }
@SideOnly(Side.CLIENT) @Override public void renderInWorld(final double x, final double y, final double z) { if (!this.getUtil().getProcess().isInProgress()) { return; } final ItemStack itemstack = this.getUtil().getStack(6); World world = this.getMachine().getWorld(); this.entityItemRenderer.renderInWorld(itemstack, world, x + 0.5f, y + 0.8f, z + 0.5f); }
@Override protected void onFinishTask() { super.onFinishTask(); ItemStack itemStack = this.getUtil().getStack(Analyser.SLOT_TARGET); itemStack = ManagerGenetics.analyse(itemStack, getMachine().getWorld(), getMachine().getOwner()); this.getInventory().setInventorySlotContents(Analyser.SLOT_TARGET, itemStack); }
@Override protected void onFinishTask() { super.onFinishTask(); final Random rand = this.getMachine().getWorld().rand; MachineUtil util = this.getUtil(); final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(util.getStack(Isolator.SLOT_TARGET)); if (root == null) { return; } final IIndividual individual = root.getMember(util.getStack(Isolator.SLOT_TARGET)); if (individual == null) { return; } IChromosomeType[] karyotype = root.getKaryotype(); IChromosomeType chromosome = karyotype[rand.nextInt(karyotype.length)]; IGenome genome = individual.getGenome(); IAllele allele = rand.nextBoolean() ? genome.getActiveAllele(chromosome) : genome.getInactiveAllele(chromosome); Gene gene = Gene.create(allele, chromosome, root); final ItemStack serum = ItemSequence.create(gene); util.setStack(Isolator.SLOT_RESULUT, serum); util.decreaseStack(Isolator.SLOT_SEQUENCER_VIAL, 1); if (rand.nextFloat() < TARGET_LOSS_CHANCE) { util.decreaseStack(Isolator.SLOT_TARGET, 1); } util.drainTank(Isolator.TANK_ETHANOL, ETHANOL_PER_PROCESS); }
@Override protected void onFinishTask() { super.onFinishTask(); this.updateSequence(); ItemStack stack = this.getUtil().getStack(Sequencer.SLOT_TARGET); Preconditions.checkState(!stack.isEmpty()); final SequencerItem seqItem = SequencerItem.create(stack); Preconditions.checkState(seqItem != null); GeneTracker.getTracker(this.getMachine().getWorld(), this.getMachine().getOwner()).registerGene(seqItem.getGene()); this.getUtil().decreaseStack(Sequencer.SLOT_TARGET, 1); if (this.getUtil().getStack(Sequencer.SLOT_DONE).isEmpty()) { this.getUtil().setStack(Sequencer.SLOT_DONE, GeneticsItems.EmptySequencer.get(1)); } else { this.getUtil().decreaseStack(Sequencer.SLOT_DONE, -1); } }