@Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { if (pos.getY() == neighbor.getY() && world instanceof World) { neighborChanged( world.getBlockState(pos), (World) world, pos, world.getBlockState(neighbor).getBlock()); } }
/** returns whether or not there is space for a tree to grow at a certain position */ private boolean isSpaceAt(World worldIn, BlockPos leavesPos, int height) { boolean flag = true; if (leavesPos.getY() >= 1 && leavesPos.getY() + height + 1 <= 256) { for (int i = 0; i <= 1 + height; ++i) { int j = 2; if (i == 0) { j = 1; } else if (i >= 1 + height - 2) { j = 2; } for (int k = -j; k <= j && flag; ++k) { for (int l = -j; l <= j && flag; ++l) { if (leavesPos.getY() + i < 0 || leavesPos.getY() + i >= 256 || !this.isReplaceable(worldIn, leavesPos.add(k, i, l))) { flag = false; } } } } return flag; } else { return false; } }
public static void playBlockBreakParticles(BlockPos pos, IBlockState state) { ParticleManager pm = Minecraft.getMinecraft().effectRenderer; for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { double d0 = (double) pos.getX() + ((double) j + 0.5D) / 4D; double d1 = (double) pos.getY() + ((double) k + 0.5D) / 4D; double d2 = (double) pos.getZ() + ((double) l + 0.5D) / 4D; Particle digging = diggingFactory.getEntityFX( 0, Minecraft.getMinecraft().theWorld, d0, d1, d2, d0 - (double) pos.getX() - 0.5D, d1 - (double) pos.getY() - 0.5D, d2 - (double) pos.getZ() - 0.5D, Block.getStateId(state)); pm.addEffect(digging); } } } }
/** Returns if the supplied Coordinate is completely inside the bounding box */ public boolean isVecInside(BlockPos c) { return c.getX() >= this.minX && c.getX() < this.maxX && (c.getY() >= this.minY && c.getY() < this.maxY && c.getZ() >= this.minZ && c.getZ() < this.maxZ); }
@Override public void onUpdate() { super.onUpdate(); positionAt++; if (positionAt == POSITIONS.length) positionAt = 0; BlockPos acoords = POSITIONS[positionAt]; BlockPos coords = supertile.getPos().add(acoords); World world = supertile.getWorld(); if (!world.isAirBlock(coords)) { IBlockState state = world.getBlockState(coords); RecipePureDaisy recipe = null; for (RecipePureDaisy recipe_ : BotaniaAPI.pureDaisyRecipes) if (recipe_.matches(world, coords, this, state)) { recipe = recipe_; break; } if (recipe != null) { if (ticksRemaining[positionAt] == -1) ticksRemaining[positionAt] = recipe.getTime(); ticksRemaining[positionAt]--; Botania.proxy.sparkleFX( supertile.getWorld(), coords.getX() + Math.random(), coords.getY() + Math.random(), coords.getZ() + Math.random(), 1F, 1F, 1F, (float) Math.random(), 5); if (ticksRemaining[positionAt] <= 0) { ticksRemaining[positionAt] = -1; if (recipe.set(world, coords, this)) { for (int i = 0; i < 25; i++) { double x = coords.getX() + Math.random(); double y = coords.getY() + Math.random() + 0.5; double z = coords.getZ() + Math.random(); Botania.proxy.wispFX( supertile.getWorld(), x, y, z, 1F, 1F, 1F, (float) Math.random() / 2F); } if (ConfigHandler.blockBreakParticles) supertile .getWorld() .playEvent(2001, coords, Block.getStateId(recipe.getOutputState())); } } } else ticksRemaining[positionAt] = -1; } }
public boolean contains(BlockPos pos) { BlockPos from = cluster.getFrom(); if (pos.getX() < from.getX() || pos.getY() < from.getY() || pos.getZ() < from.getZ()) { return false; } BlockPos to = cluster.getTo(); if (pos.getX() >= to.getX() || pos.getY() >= to.getY() || pos.getZ() >= to.getZ()) { return false; } return true; }
/** * Returns true iff the given Predicate evaluates to true for all cubes for block positions within * blockRadius from centerPos. Only cubes that exist are tested. If some cubes within that range * aren't loaded - returns false. */ default boolean testForCubes( BlockPos centerPos, int blockRadius, @Nullable Predicate<Cube> test) { return testForCubes( centerPos.getX() - blockRadius, centerPos.getY() - blockRadius, centerPos.getZ() - blockRadius, centerPos.getX() + blockRadius, centerPos.getY() + blockRadius, centerPos.getZ() + blockRadius, test); }
/* Straight from InventoryHelper in vanilla code */ public static void spawnInWorld(World world, BlockPos pos, ItemStack itemStack) { float f = RANDOM.nextFloat() * 0.8F + 0.1F; float f1 = RANDOM.nextFloat() * 0.8F + 0.1F; float f2 = RANDOM.nextFloat() * 0.8F + 0.1F; while (itemStack.stackSize > 0) { int i = RANDOM.nextInt(21) + 10; if (i > itemStack.stackSize) i = itemStack.stackSize; itemStack.stackSize -= i; EntityItem entityitem = new EntityItem( world, pos.getX() + (double) f, pos.getY() + (double) f1, pos.getZ() + (double) f2, new ItemStack(itemStack.getItem(), i, itemStack.getMetadata())); if (itemStack.hasTagCompound()) entityitem .getEntityItem() .setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); float f3 = 0.05F; entityitem.motionX = RANDOM.nextGaussian() * (double) f3; entityitem.motionY = RANDOM.nextGaussian() * (double) f3 + 0.20000000298023224D; entityitem.motionZ = RANDOM.nextGaussian() * (double) f3; world.spawnEntityInWorld(entityitem); } }
/** * Return an {@link AxisAlignedBB} that controls the visible scope of a {@link * TileEntitySpecialRenderer} associated with this {@link TileEntity} Defaults to the collision * bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated * with the block at this location. * * @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity} */ @SideOnly(Side.CLIENT) public net.minecraft.util.math.AxisAlignedBB getRenderBoundingBox() { net.minecraft.util.math.AxisAlignedBB bb = INFINITE_EXTENT_AABB; Block type = getBlockType(); BlockPos pos = getPos(); if (type == Blocks.ENCHANTING_TABLE) { bb = new net.minecraft.util.math.AxisAlignedBB(pos, pos.add(1, 1, 1)); } else if (type == Blocks.CHEST || type == Blocks.TRAPPED_CHEST) { bb = new net.minecraft.util.math.AxisAlignedBB(pos.add(-1, 0, -1), pos.add(2, 2, 2)); } else if (type != null && type != Blocks.BEACON) { net.minecraft.util.math.AxisAlignedBB cbb = null; try { cbb = worldObj .getBlockState(getPos()) .getCollisionBoundingBox(worldObj, pos) .addCoord(pos.getX(), pos.getY(), pos.getZ()); } catch (Exception e) { // We have to capture any exceptions that may occur here because BUKKIT servers like to send // the tile entity data BEFORE the chunk data, you know, the OPPOSITE of what vanilla does! // So we can not GARENTEE that the world state is the real state for the block... // So, once again in the long line of US having to accommodate BUKKIT breaking things, // here it is, assume that the TE is only 1 cubic block. Problem with this is that it may // cause the TileEntity renderer to error further down the line! But alas, nothing we can // do. cbb = new net.minecraft.util.math.AxisAlignedBB( getPos().add(-1, 0, -1), getPos().add(1, 1, 1)); } if (cbb != null) bb = cbb; } return bb; }
private void dropRecord(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof BlockJukebox.TileEntityJukebox) { BlockJukebox.TileEntityJukebox blockjukebox$tileentityjukebox = (BlockJukebox.TileEntityJukebox) tileentity; ItemStack itemstack = blockjukebox$tileentityjukebox.getRecord(); if (itemstack != null) { worldIn.playEvent(1010, pos, 0); worldIn.playRecord(pos, (SoundEvent) null); blockjukebox$tileentityjukebox.setRecord((ItemStack) null); float f = 0.7F; double d0 = (double) (worldIn.rand.nextFloat() * 0.7F) + 0.15000000596046448D; double d1 = (double) (worldIn.rand.nextFloat() * 0.7F) + 0.06000000238418579D + 0.6D; double d2 = (double) (worldIn.rand.nextFloat() * 0.7F) + 0.15000000596046448D; ItemStack itemstack1 = itemstack.copy(); EntityItem entityitem = new EntityItem( worldIn, (double) pos.getX() + d0, (double) pos.getY() + d1, (double) pos.getZ() + d2, itemstack1); entityitem.setDefaultPickupDelay(); worldIn.spawnEntityInWorld(entityitem); } } } }
@Override public void toBytes(ByteBuf buf) { buf.writeInt(pos.getX()); buf.writeInt(pos.getY()); buf.writeInt(pos.getZ()); ByteBufUtils.writeItemStack(buf, activeItem); MagicAmounts.writeAmounts(buf, remaining); }
@Override public boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { TilePedestal te = getTE(world, pos); if (heldItem != null && player.isSneaking()) { if (heldItem.getItem() == ModItems.PEARL_MANA) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("link_x", pos.getX()); compound.setInteger("link_y", pos.getY()); compound.setInteger("link_z", pos.getZ()); heldItem.setTagCompound(compound); return true; } } if (te.getStack() == null && heldItem != null) { te.setStack(heldItem); player.inventory.setInventorySlotContents(player.inventory.currentItem, null); player.openContainer.detectAndSendChanges(); } else if (te.getStack() != null && heldItem == null) { ItemStack stack = te.getStack(); te.setStack(null); if (!player.inventory.addItemStackToInventory(stack)) { EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), stack); world.spawnEntityInWorld(entityItem); } else { player.openContainer.detectAndSendChanges(); } } } return true; }
@Nullable private EntityItemFrame findItemFrame(World worldIn, final EnumFacing facing, BlockPos pos) { List<EntityItemFrame> list = worldIn.<EntityItemFrame>getEntitiesWithinAABB( EntityItemFrame.class, new AxisAlignedBB( (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), (double) (pos.getX() + 1), (double) (pos.getY() + 1), (double) (pos.getZ() + 1)), new Predicate<Entity>() { public boolean apply(@Nullable Entity p_apply_1_) { return p_apply_1_ != null && p_apply_1_.getHorizontalFacing() == facing; } }); return list.size() == 1 ? (EntityItemFrame) list.get(0) : null; }
@Override public void doEffect( World world, BlockPos pos, List<ItemStack> inventory, List<ItemStack> incenses) { inventory.clear(); List<EntityMob> enemies = (List<EntityMob>) world.getEntitiesWithinAABB( EntityMob.class, new AxisAlignedBB( pos.getX() - 22, pos.getY() - 8, pos.getZ() - 22, pos.getX() + 23, pos.getY() + 9, pos.getZ() + 23)); float drainedHealth = 0; if (enemies.size() > 0) { for (int i = 0; i < enemies.size(); i++) { enemies.get(i).attackEntityFrom(DamageSource.cactus, 9); drainedHealth += 9; } } List<EntityPlayer> players = (List<EntityPlayer>) world.getEntitiesWithinAABB( EntityPlayer.class, new AxisAlignedBB( pos.getX() - 22, pos.getY() - 8, pos.getZ() - 22, pos.getX() + 23, pos.getY() + 9, pos.getZ() + 23)); float numPlayers = players.size(); for (int i = 0; i < numPlayers; i++) { players.get(i).heal(drainedHealth / (numPlayers * 2.5f)); if (drainedHealth / (numPlayers * 2.5f) > 20.0) { if (!players.get(i).hasAchievement(RegistryManager.achieveVampire)) { PlayerManager.addAchievement(players.get(i), RegistryManager.achieveVampire); } } } }
@Override public boolean matches(World world, BlockPos pos) { if (super.matches(world, pos)) { List<EntityMob> enemies = (List<EntityMob>) world.getEntitiesWithinAABB( EntityMob.class, new AxisAlignedBB( pos.getX() - 22, pos.getY() - 8, pos.getZ() - 22, pos.getX() + 23, pos.getY() + 9, pos.getZ() + 23)); if (enemies.isEmpty() == false) { return true; } } return false; }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state, EntityPlayer player) { for (int i = 0; i < inventory.size(); i++) { if (!world.isRemote) { world.spawnEntityInWorld( new EntityItem( world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, inventory.get(i))); } } this.invalidate(); }
public static void DropItems(TileEntity tileEntity, int min, int max) { if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; World world = tileEntity.getWorld(); BlockPos blockPos = tileEntity.getPos(); for (int i = min; i <= max; i++) { ItemStack itemStack = inventory.getStackInSlot(i); if (itemStack != null && itemStack.stackSize > 0) { Random rand = new Random(); float dX = rand.nextFloat() * 0.8F + 0.1F; float dY = rand.nextFloat() * 0.8F + 0.1F; float dZ = rand.nextFloat() * 0.8F + 0.1F; EntityItem entityItem = new EntityItem( world, blockPos.getX() + dX, blockPos.getY() + dY, blockPos.getZ() + dZ, itemStack.copy()); if (itemStack.hasTagCompound()) { entityItem .getEntityItem() .setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); } float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; world.spawnEntityInWorld(entityItem); itemStack.stackSize = 0; inventory.setInventorySlotContents(i, null); } } inventory.markDirty(); }
@Override public EnumActionResult onItemUse( ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { HelicopterBaseEntity helicopter = new HelicopterBaseEntity(world, UUID.randomUUID()); helicopter.setPosition(pos.getX() + hitX, pos.getY() + hitY, pos.getZ() + hitZ); world.spawnEntityInWorld(helicopter); } return EnumActionResult.SUCCESS; }
@Override public boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack held, EnumFacing facing, float fx, float par8, float par9) { System.out.println("Im awake!"); if (world.isRemote == false) { player.openGui(LabStuffMain.instance, 0, world, pos.getX(), pos.getY(), pos.getZ()); return true; } return false; }
@Override public boolean onBlockActivated( World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) playerIn.openGui( CoreInit.modInstance, GuiIDs.electricFurnaceAdv.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; }
@Override public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { EnumDyeColor color = state.getValue(BotaniaStateProps.COLOR); int hex = color.getMapColor().colorValue; int r = (hex & 0xFF0000) >> 16; int g = (hex & 0xFF00) >> 8; int b = (hex & 0xFF); Botania.proxy.setSparkleFXNoClip(true); Botania.proxy.sparkleFX( world, pos.getX() + 0.3 + rand.nextFloat() * 0.5, pos.getY() + 0.1 + rand.nextFloat() * 0.1, pos.getZ() + 0.3 + rand.nextFloat() * 0.5, r / 255F, g / 255F, b / 255F, rand.nextFloat(), 5); Botania.proxy.setSparkleFXNoClip(false); }
@Override public EnumActionResult onItemUse( ItemStack itemstack, EntityPlayer entityplayer, World world, BlockPos pos, EnumHand hand, EnumFacing side, float posX, float posY, float posZ) { TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof TileEntityChargepad) { TileEntityChargepad chargepad = (TileEntityChargepad) tileEntity; if (!chargepad.isActive) { if (!world.isRemote) { EntityRobit robit = new EntityRobit(world, pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5); robit.setHome(Coord4D.get(chargepad)); robit.setEnergy(getEnergy(itemstack)); robit.setOwner(entityplayer.getName()); robit.setInventory(getInventory(itemstack)); robit.setCustomNameTag(getName(itemstack)); world.spawnEntityInWorld(robit); } entityplayer.setHeldItem(hand, null); return EnumActionResult.SUCCESS; } } return EnumActionResult.PASS; }
/** * returns whether or not there is dirt underneath the block where the tree will be grown. It also * generates dirt around the block in a 2x2 square if there is dirt underneath the blockpos. */ private boolean ensureDirtsUnderneath(BlockPos pos, World worldIn) { BlockPos blockpos = pos.down(); IBlockState state = worldIn.getBlockState(blockpos); boolean isSoil = state .getBlock() .canSustainPlant( state, worldIn, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling) Blocks.SAPLING)); if (isSoil && pos.getY() >= 2) { this.onPlantGrow(worldIn, blockpos, pos); this.onPlantGrow(worldIn, blockpos.east(), pos); this.onPlantGrow(worldIn, blockpos.south(), pos); this.onPlantGrow(worldIn, blockpos.south().east(), pos); return true; } else { return false; } }
public boolean activate( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (heldItem == null && !player.isSneaking() && this.progress == 0) { if (inventory.size() > 0) { if (!world.isRemote) { world.spawnEntityInWorld( new EntityItem( world, pos.getX() + 0.5, pos.getY() + 1.0, pos.getZ() + 0.5, inventory.remove(inventory.size() - 1))); } else { inventory.remove(inventory.size() - 1); } markDirty(); this.getWorld().notifyBlockUpdate(getPos(), state, world.getBlockState(pos), 3); return true; } } else if (player.isSneaking() && heldItem == null && this.progress == 0) { ritualName = null; ritual = null; for (int i = 0; i < RitualManager.rituals.size(); i++) { if (RitualManager.rituals.get(i).matches(getWorld(), getPos())) { ritualName = RitualManager.rituals.get(i).name; ritual = RitualManager.rituals.get(i); incenses = RitualManager.getIncenses(world, getPos()); progress = 200; markDirty(); this.getWorld().notifyBlockUpdate(getPos(), state, world.getBlockState(pos), 3); return true; } } if (ritualName == null) { if (world.isRemote) { player.addChatMessage( new TextComponentString( TextFormatting.RED + I18n.format("roots.error.noritual.name"))); } markDirty(); this.getWorld().notifyBlockUpdate(getPos(), state, world.getBlockState(pos), 3); return true; } } else { if (inventory.size() < 3) { ItemStack toAdd = new ItemStack(heldItem.getItem(), 1, heldItem.getItemDamage()); if (heldItem.hasTagCompound()) { toAdd.setTagCompound(heldItem.getTagCompound()); } inventory.add(toAdd); heldItem.stackSize--; markDirty(); this.getWorld().notifyBlockUpdate(getPos(), state, world.getBlockState(pos), 3); return true; } } return false; }
@Override public boolean generate(World world, Random rand, BlockPos blockPos) { return this.generate(world, rand, blockPos.getX(), blockPos.getY(), blockPos.getZ()); }
/** * Creates a vector from the coordinates defined by blockPos. * * @param blockPos The vanilla blockPos */ public Vector(BlockPos blockPos) { this(blockPos.getX(), blockPos.getY(), blockPos.getZ()); }
@Override public boolean displaceIfPossible(World world, BlockPos pos) { if (!world.isRemote) { if (!world.provider.isSurfaceWorld()) { if (world.getBlockState(pos).getBlock() == Blocks.WATER && AbyssalCraft.shouldSpread == false) return false; if (world.getBlockState(pos).getMaterial().isLiquid() && world.getBlockState(pos).getBlock() != this && world.getBlockState(pos).getBlock() != ACBlocks.liquid_antimatter) world.setBlockState(pos, getDefaultState()); if (AbyssalCraft.breakLogic == true && world .getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())) .getMaterial() .isLiquid() && world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())).getBlock() != this && world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())).getBlock() != ACBlocks.liquid_antimatter) world.setBlockState( new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), getDefaultState()); } else { if (BiomeDictionary.isBiomeOfType(world.getBiomeGenForCoords(pos), Type.OCEAN) && world.getBlockState(pos).getBlock() == this) if (AbyssalCraft.destroyOcean) world.setBlockState(pos, getDefaultState()); else world.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState()); if (AbyssalCraft.shouldSpread) { if (world.getBlockState(pos).getMaterial().isLiquid() && world.getBlockState(pos).getBlock() != this && world.getBlockState(pos).getBlock() != ACBlocks.liquid_antimatter) world.setBlockState(pos, getDefaultState()); if (AbyssalCraft.breakLogic == true && world .getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())) .getMaterial() .isLiquid() && world .getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())) .getBlock() != this && world .getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())) .getBlock() != ACBlocks.liquid_antimatter) world.setBlockState( new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), getDefaultState()); } } if (dusts.contains(world.getBlockState(pos)) && world.getBlockState(pos) != ACBlocks.abyssal_nitre_ore.getDefaultState() && world.getBlockState(pos) != ACBlocks.abyssal_coralium_ore) if (oresToBlocks(OreDictionary.getOres("oreSaltpeter")).contains(world.getBlockState(pos))) world.setBlockState(pos, ACBlocks.abyssal_nitre_ore.getDefaultState()); else world.setBlockState(pos, ACBlocks.abyssal_coralium_ore.getDefaultState()); else if (metalloids.contains(world.getBlockState(pos)) && !metals.contains(world.getBlockState(pos))) if (oresToBlocks(OreDictionary.getOres("oreIron")).contains(world.getBlockState(pos))) world.setBlockState(pos, ACBlocks.abyssal_iron_ore.getDefaultState()); else if (oresToBlocks(OreDictionary.getOres("oreGold")).contains(world.getBlockState(pos))) world.setBlockState(pos, ACBlocks.abyssal_gold_ore.getDefaultState()); else if (oresToBlocks(OreDictionary.getOres("oreTin")).contains(world.getBlockState(pos))) world.setBlockState(pos, ACBlocks.abyssal_tin_ore.getDefaultState()); else if (oresToBlocks(OreDictionary.getOres("oreCopper")) .contains(world.getBlockState(pos))) world.setBlockState(pos, ACBlocks.abyssal_copper_ore.getDefaultState()); else world.setBlockState(pos, ACBlocks.liquified_coralium_ore.getDefaultState()); else if (gems.contains(world.getBlockState(pos)) && world.getBlockState(pos) != ACBlocks.abyssal_diamond_ore.getDefaultState()) if (oresToBlocks(OreDictionary.getOres("oreDiamond")).contains(world.getBlockState(pos))) world.setBlockState(pos, ACBlocks.abyssal_diamond_ore.getDefaultState()); else world.setBlockState(pos, ACBlocks.pearlescent_coralium_ore.getDefaultState()); else if (stones.contains(world.getBlockState(pos))) if (BiomeDictionary.isBiomeOfType(world.getBiomeGenForCoords(pos), Type.OCEAN)) { if (world.getBlockState(pos).getBlock() != Blocks.COBBLESTONE) world.setBlockState(pos, ACBlocks.abyssal_stone.getDefaultState()); } else world.setBlockState(pos, ACBlocks.abyssal_stone.getDefaultState()); else if (bricks.contains(world.getBlockState(pos))) world.setBlockState(pos, ACBlocks.abyssal_stone_brick.getDefaultState()); } return super.displaceIfPossible(world, pos); }
@Override public void update() { ticker += 3.0; if (ticker > 360) { ticker = 0; } if (progress > 0 && ritual != null) { progress--; if (getWorld().isRemote) { if (ritual.positions.size() > 0) { BlockPos pos = ritual .positions .get(random.nextInt(ritual.positions.size())) .up() .add(getPos().getX(), getPos().getY(), getPos().getZ()); Roots.proxy.spawnParticleMagicAltarLineFX( getWorld(), pos.getX() + 0.5, pos.getY() + 0.125, pos.getZ() + 0.5, getPos().getX() + 0.5, getPos().getY() + 0.875, getPos().getZ() + 0.5, ritual.color.xCoord, ritual.color.yCoord, ritual.color.zCoord); } Roots.proxy.spawnParticleMagicAltarFX( getWorld(), getPos().getX() + 0.5, getPos().getY() + 0.875, getPos().getZ() + 0.5, 0.125 * Math.sin(Math.toRadians(360.0 * (progress % 100) / 100.0)), 0, 0.125 * Math.cos(Math.toRadians(360.0 * (progress % 100) / 100.0)), ritual.color.xCoord, ritual.color.yCoord, ritual.color.zCoord); Roots.proxy.spawnParticleMagicAltarFX( getWorld(), getPos().getX() + 0.5, getPos().getY() + 0.875, getPos().getZ() + 0.5, 0.125 * Math.sin(Math.toRadians(90.0 + 360.0 * (progress % 100) / 100.0)), 0, 0.125 * Math.cos(Math.toRadians(90.0 + 360.0 * (progress % 100) / 100.0)), ritual.color.xCoord, ritual.color.yCoord, ritual.color.zCoord); Roots.proxy.spawnParticleMagicAltarFX( getWorld(), getPos().getX() + 0.5, getPos().getY() + 0.875, getPos().getZ() + 0.5, 0.125 * Math.sin(Math.toRadians(180.0 + 360.0 * (progress % 100) / 100.0)), 0, 0.125 * Math.cos(Math.toRadians(180.0 + 360.0 * (progress % 100) / 100.0)), ritual.color.xCoord, ritual.color.yCoord, ritual.color.zCoord); Roots.proxy.spawnParticleMagicAltarFX( getWorld(), getPos().getX() + 0.5, getPos().getY() + 0.875, getPos().getZ() + 0.5, 0.125 * Math.sin(Math.toRadians(270.0 + 360.0 * (progress % 100) / 100.0)), 0, 0.125 * Math.cos(Math.toRadians(270.0 + 360.0 * (progress % 100) / 100.0)), ritual.color.xCoord, ritual.color.yCoord, ritual.color.zCoord); } if (progress % 40 == 0) { incenses = RitualManager.getIncenses(getWorld(), getPos()); boolean doesMatch = false; for (int i = 0; i < RitualManager.rituals.size(); i++) { if (RitualManager.rituals.get(i).matches(getWorld(), getPos())) { doesMatch = true; } } if (!doesMatch) { ritual = null; ritualName = null; } } if (progress == 0) { ritual.doEffect(getWorld(), getPos(), inventory, incenses); ritualName = null; ritual = null; markDirty(); this.getWorld() .notifyBlockUpdate( getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3); } } }
@Override public boolean generate(World world, Random rand, BlockPos pos) { int i1 = rand.nextInt(2) + 2; int j1 = -i1 - 1; int k1 = i1 + 1; int i2 = rand.nextInt(2) + 2; int j2 = -i2 - 1; int k2 = i2 + 1; int count = 0; for (int x = j1; x <= k1; ++x) { for (int y = -1; y <= 4; ++y) { for (int z = j2; z <= k2; ++z) { BlockPos blockpos = pos.add(x, y, z); Material material = world.getBlockState(blockpos).getMaterial(); boolean flag = material.isSolid(); if (y == -1 && !flag) { return false; } if (y == 4 && !flag) { return false; } if ((x == j1 || x == k1 || z == j2 || z == k2) && y == 0 && world.isAirBlock(blockpos) && world.isAirBlock(blockpos.up())) { ++count; } } } } if (count >= 1 && count <= 5) { int type = rand.nextInt(2); IBlockState state1; IBlockState state2; switch (type) { case 1: state1 = Blocks.STONEBRICK.getDefaultState(); state2 = Blocks.STONEBRICK .getDefaultState() .withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.MOSSY); default: state1 = Blocks.COBBLESTONE.getDefaultState(); state2 = Blocks.MOSSY_COBBLESTONE.getDefaultState(); } for (int x = j1; x <= k1; ++x) { for (int y = 3; y >= -1; --y) { for (int z = j2; z <= k2; ++z) { BlockPos blockpos = pos.add(x, y, z); if (x != j1 && y != -1 && z != j2 && x != k1 && y != 4 && z != k2) { if (world.getBlockState(blockpos).getBlock() != Blocks.CHEST) { world.setBlockToAir(blockpos); } } else if (blockpos.getY() >= 0 && !world.getBlockState(blockpos.down()).getMaterial().isSolid()) { world.setBlockToAir(blockpos); } else if (world.getBlockState(blockpos).getMaterial().isSolid() && world.getBlockState(blockpos).getBlock() != Blocks.CHEST) { if (y == -1 && rand.nextInt(4) != 0) { world.setBlockState(blockpos, state2, 2); } else { world.setBlockState(blockpos, state1, 2); } } } } } for (int i = 0; i < 2; ++i) { for (int j = 0; j < 3; ++j) { int x = pos.getX() + rand.nextInt(i1 * 2 + 1) - i1; int y = pos.getY(); int z = pos.getZ() + rand.nextInt(i2 * 2 + 1) - i2; BlockPos blockpos = new BlockPos(x, y, z); if (world.isAirBlock(blockpos)) { count = 0; for (EnumFacing face : EnumFacing.Plane.HORIZONTAL) { if (world.getBlockState(blockpos.offset(face)).getMaterial().isSolid()) { ++count; } } if (count == 1) { world.setBlockState( blockpos, Blocks.CHEST.correctFacing(world, blockpos, Blocks.CHEST.getDefaultState()), 2); TileEntity tile = world.getTileEntity(blockpos); if (tile != null && tile instanceof TileEntityChest) { ((TileEntityChest) tile) .setLootTable(LootTableList.CHESTS_SIMPLE_DUNGEON, rand.nextLong()); } break; } } } } world.setBlockState(pos, Blocks.MOB_SPAWNER.getDefaultState(), 2); TileEntity tile = world.getTileEntity(pos); if (tile != null && tile instanceof TileEntityMobSpawner) { ((TileEntityMobSpawner) tile).getSpawnerBaseLogic().setEntityName(pickMobSpawner(rand)); } else { CaveLog.warning( "Failed to fetch mob spawner entity at (" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + ")"); } return true; } return false; }