public static BlockVector3 adapt(BlockPos pos) { return BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()); }
@Override public void recieveMana(int mana) { if(mana > 0) for(int i = 0; i < 10; i++) Botania.proxy.sparkleFX(pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0.2F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5); }
boolean checkAll(BlockPos[] relPositions, Block block) { for (BlockPos position : relPositions) { if(!checkPlatform(position.getX(), position.getZ(), block)) return false; } return true; }
private boolean inRange(BlockPos pos, BlockPos srcPos, int range, double heightscale, boolean pointy) { if(pos.getY() >= srcPos.getY()) return MathHelper.pointDistanceSpace(pos.getX(), 0, pos.getZ(), srcPos.getX(), 0, srcPos.getZ()) < range; else if(!pointy) return MathHelper.pointDistanceSpace(pos.getX(), pos.getY() / heightscale, pos.getZ(), srcPos.getX(), srcPos.getY() / heightscale, srcPos.getZ()) < range; else return MathHelper.pointDistanceSpace(pos.getX(), 0, pos.getZ(), srcPos.getX(), 0, srcPos.getZ()) < range - (srcPos.getY() - pos.getY()) / heightscale; }
@SideOnly(Side.CLIENT) @Override public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { int hex = state.getValue(BotaniaStateProps.COLOR).getColorValue(); int r = (hex & 0xFF0000) >> 16; int g = (hex & 0xFF00) >> 8; int b = hex & 0xFF; if(rand.nextDouble() < ConfigHandler.flowerParticleFrequency) Botania.proxy.sparkleFX(pos.getX() + 0.3 + rand.nextFloat() * 0.5, pos.getY() + 0.5 + rand.nextFloat() * 0.5, pos.getZ() + 0.3 + rand.nextFloat() * 0.5, r / 255F, g / 255F, b / 255F, rand.nextFloat(), 5); }
private static int getGaiaGuardiansAround(World world, BlockPos source) { float range = 15F; List l = world.getEntitiesWithinAABB(EntityDoppleganger.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range)); return l.size(); }
@Override public ISparkEntity getAttachedSpark() { List<Entity> sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX(), pos.getY() + 1, pos.getZ(), pos.getX() + 1, pos.getY() + 2, pos.getZ() + 1), Predicates.instanceOf(ISparkEntity.class)); if(sparks.size() == 1) { Entity e = sparks.get(0); return (ISparkEntity) e; } return null; }
@Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { state = getActualState(state, world, pos); int hex = state.getValue(second ? BotaniaStateProps.DOUBLEFLOWER_VARIANT_2 : BotaniaStateProps.DOUBLEFLOWER_VARIANT_1).getColorValue(); int r = (hex & 0xFF0000) >> 16; int g = (hex & 0xFF00) >> 8; int b = hex & 0xFF; if(rand.nextDouble() < ConfigHandler.flowerParticleFrequency) Botania.proxy.sparkleFX(pos.getX() + 0.3 + rand.nextFloat() * 0.5, pos.getY() + 0.5 + rand.nextFloat() * 0.5, pos.getZ() + 0.3 + rand.nextFloat() * 0.5, r / 255F, g / 255F, b / 255F, rand.nextFloat(), 5); }
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { TileEntity tile = world.getTileEntity(pos); if(tile instanceof TileTinyPotato) { ((TileTinyPotato) tile).interact(player, hand, player.getHeldItem(hand), par6); world.spawnParticle(EnumParticleTypes.HEART, pos.getX() + AABB.minX + Math.random() * (AABB.maxX - AABB.minX), pos.getY() + AABB.maxY, pos.getZ() + AABB.minZ + Math.random() * (AABB.maxZ - AABB.minZ), 0, 0 ,0); } return true; }
private void particles(World world, BlockPos pos, Entity entity) { if(world instanceof WorldServer) { WorldServer ws = (WorldServer) world; ws.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, entity.posX + entity.width / 2, entity.posY + entity.height / 2, entity.posZ + entity.width / 2, 100, entity.width, entity.height, entity.width, 0.05); ws.spawnParticle(EnumParticleTypes.PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 40, 0, 0, 0, 0.6); } }
@Override public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { TileEnchanter enchanter = (TileEnchanter) world.getTileEntity(pos); if(!enchanter.itemToEnchant.isEmpty()) { world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), enchanter.itemToEnchant)); } world.updateComparatorOutputLevel(pos, state.getBlock()); super.breakBlock(world, pos, state); }
@Nonnull @Override public NBTTagCompound writeToNBT(NBTTagCompound par1nbtTagCompound) { NBTTagCompound ret = super.writeToNBT(par1nbtTagCompound); ret.setInteger(TAG_FLOWER_X, flowerPos.getX()); ret.setInteger(TAG_FLOWER_Y, flowerPos.getY()); ret.setInteger(TAG_FLOWER_Z, flowerPos.getZ()); return ret; }
private void keepInsideArena(EntityPlayer player) { if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(player.posX, player.posY, player.posZ, source.getX() + 0.5, source.getY() + 0.5, source.getZ() + 0.5) >= ARENA_RANGE) { Vector3 sourceVector = new Vector3(source.getX() + 0.5, source.getY() + 0.5, source.getZ() + 0.5); Vector3 playerVector = Vector3.fromEntityCenter(player); Vector3 motion = sourceVector.subtract(playerVector).normalize(); player.motionX = motion.x; player.motionY = 0.2; player.motionZ = motion.z; player.velocityChanged = true; } }
@Override public void writePacketNBT(NBTTagCompound cmp) { cmp.setInteger(TAG_BIND_X, bindPos.getX()); cmp.setInteger(TAG_BIND_Y, bindPos.getY()); cmp.setInteger(TAG_BIND_Z, bindPos.getZ()); }
/** * Returns the multiblock component for the coordinates, adjusted based on the anchor */ private MultiblockComponent getComponent(BlockPos pos) { return multiblock.getComponentForLocation(pos.add(new BlockPos(-anchorPos.getX(), -anchorPos.getY(), -anchorPos.getZ()))); } }
public long getSortValue() { final TileEntity te = this.iHost.getTileEntity(); return ( te.getPos().getZ() << 24 ) ^ ( te.getPos().getX() << 8 ) ^ te.getPos().getY(); }
@Override public void writeToPacketNBT(NBTTagCompound cmp) { super.writeToPacketNBT(cmp); cmp.setInteger(TAG_BIND_X, bindPos.getX()); cmp.setInteger(TAG_BIND_Y, bindPos.getY()); cmp.setInteger(TAG_BIND_Z, bindPos.getZ()); }
public static void dispatchTEToNearbyPlayers(TileEntity tile) { SPacketUpdateTileEntity packet = tile.getUpdatePacket(); if(packet != null && tile.getWorld() instanceof WorldServer) { PlayerChunkMapEntry chunk = ((WorldServer) tile.getWorld()).getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4); if(chunk != null) { chunk.sendPacket(packet); } } }
public static void dropInventory(TileSimpleInventory inv, World world, IBlockState state, BlockPos pos) { if(inv != null) { for(int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { ItemStack itemstack = inv.getItemHandler().getStackInSlot(j1); if(!itemstack.isEmpty()) { net.minecraft.inventory.InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } world.updateComparatorOutputLevel(pos, state.getBlock()); } }