public EnergyFx( final World par1World, final double par2, final double par4, final double par6, final Item par8Item ) { super( par1World, par2, par4, par6, par8Item ); this.particleGravity = 0; this.particleBlue = 1; this.particleGreen = 1; this.particleRed = 1; this.particleAlpha = 1.4f; this.particleScale = 3.5f; this.particleTextureIndex = ParticleTextures.BlockEnergyParticle; this.startBlkX = MathHelper.floor( this.posX ); this.startBlkY = MathHelper.floor( this.posY ); this.startBlkZ = MathHelper.floor( this.posZ ); }
public CraftingFx( final World par1World, final double par2, final double par4, final double par6, final Item par8Item ) { super( par1World, par2, par4, par6, par8Item ); this.particleGravity = 0; this.particleBlue = 1; this.particleGreen = 0.9f; this.particleRed = 1; this.particleAlpha = 1.3f; this.particleScale = 1.5f; this.particleTextureIndex = ParticleTextures.BlockEnergyParticle; this.particleMaxAge /= 1.2; this.startBlkX = MathHelper.floor( this.posX ); this.startBlkY = MathHelper.floor( this.posY ); this.startBlkZ = MathHelper.floor( this.posZ ); }
@Override public ISparkAttachable getAttachedTile() { int x = MathHelper.floor(posX); int y = MathHelper.floor(posY) - 1; int z = MathHelper.floor(posZ); TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile != null && tile instanceof ISparkAttachable) return (ISparkAttachable) tile; return null; }
@SideOnly(Side.CLIENT) public int getEntityScale(int targetSize) { float entity_size = dummyEntity.width; if(dummyEntity.width < dummyEntity.height) entity_size = dummyEntity.height; return MathHelper.floor(size / entity_size); }
@Override public void onUpdate() { super.onUpdate(); if(world.isRemote) { double particleChance = 1F - (double) getMana() / (double) TilePool.MAX_MANA * 0.1; Color color = TilePool.PARTICLE_COLOR; double x = MathHelper.floor(posX); double y = MathHelper.floor(posY); double z = MathHelper.floor(posZ); if(Math.random() > particleChance) Botania.proxy.wispFX(x + 0.3 + Math.random() * 0.5, y + 0.85 + Math.random() * 0.25, z + Math.random(), color.getRed(), color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 3F, (float) -Math.random() / 25F, 2F); } }
@Override public final void onPlacement( final EntityPlayer player, final EnumHand hand, final ItemStack held, final AEPartLocation side ) { super.onPlacement( player, hand, held, side ); final byte rotation = (byte) ( MathHelper.floor( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 ); if( side == AEPartLocation.UP ) { this.spin = rotation; } else if( side == AEPartLocation.DOWN ) { this.spin = rotation; } }
private void smashCheatyBlocks() { int radius = 1; int posXInt = MathHelper.floor(posX); int posYInt = MathHelper.floor(posY); int posZInt = MathHelper.floor(posZ); for(int i = -radius; i < radius + 1; i++) for(int j = -radius; j < radius + 1; j++) for(int k = -radius; k < radius + 1; k++) { int xp = posXInt + i; int yp = posYInt + j; int zp = posZInt + k; BlockPos posp = new BlockPos(xp, yp, zp); if(isCheatyBlock(world, posp)) { world.destroyBlock(posp, true); } } }
@Override public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { if(!world.isRemote) { int x = MathHelper.floor(entity.posX); int z = MathHelper.floor(entity.posZ); boolean slime = SubTileNarslimmus.isSlimeChunk(world, x, z); int meta = stack.getItemDamage(); int newMeta = slime ? 1 : 0; if(meta != newMeta) stack.setItemDamage(newMeta); } }
private void clearPotions(EntityPlayer player) { int posXInt = MathHelper.floor(posX); int posZInt = MathHelper.floor(posZ); List<Potion> potionsToRemove = player.getActivePotionEffects().stream() .filter(effect -> effect.getDuration() < 160 && effect.getIsAmbient() && !effect.getPotion().isBadEffect()) .map(PotionEffect::getPotion) .distinct() .collect(Collectors.toList()); potionsToRemove.forEach(potion -> { player.removePotionEffect(potion); ((WorldServer) world).getPlayerChunkMap().getEntry(posXInt >> 4, posZInt >> 4).sendPacket(new SPacketRemoveEntityEffect(player.getEntityId(), potion)); }); }
protected int calculateAmountToSend() { double amount = this.getChannel().transferFactor(); switch( this.getInstalledUpgrades( Upgrades.SPEED ) ) { case 4: amount = amount * 1.5; case 3: amount = amount * 2; case 2: amount = amount * 4; case 1: amount = amount * 8; case 0: default: return MathHelper.floor( amount ); } }
@SubscribeEvent public static void onSpawn(LivingSpawnEvent.CheckSpawn event) { if(event.getEntityLiving() instanceof EntitySlime && event.getResult() != Result.DENY && isSlimeChunk(event.getEntityLiving().world, MathHelper.floor(event.getX()), MathHelper.floor(event.getZ()))) event.getEntityLiving().getEntityData().setBoolean(TAG_WORLD_SPAWNED, true); }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) { Vector3 playerVec = Vector3.fromEntityCenter(player); Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3); Vector3 placeVec = playerVec.add(lookVec); int x = MathHelper.floor(placeVec.x); int y = MathHelper.floor(placeVec.y) + 1; int z = MathHelper.floor(placeVec.z); int entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1)).size(); if(entities == 0) { ItemStack stackToPlace = new ItemStack(Blocks.DIRT); player.setHeldItem(hand, stackToPlace); stackToPlace.onItemUse(player, world, new BlockPos(x, y, z), hand, EnumFacing.DOWN, 0F, 0F, 0F); player.setHeldItem(hand, stack); if(stackToPlace.isEmpty()) { ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true); for(int i = 0; i < 6; i++) Botania.proxy.sparkleFX(x + Math.random(), y + Math.random(), z + Math.random(), 0.35F, 0.2F, 0.05F, 1F, 5); } } } if(world.isRemote) player.swingArm(hand); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); }
public static double calculateRadius(ItemStack stack, EntityPlayer player) { int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); Vector3 source = new Vector3(x, y, z); Botania.proxy.wispFX(source.x + 0.5, source.y + 1, source.z + 0.5, 1F, 0F, 0F, 0.2F, -0.1F); Vector3 centerVec = Vector3.fromEntityCenter(player); Vector3 diffVec = source.subtract(centerVec); Vector3 lookVec = new Vector3(player.getLookVec()); double mul = diffVec.y / lookVec.y; lookVec = lookVec.multiply(mul).add(centerVec); lookVec = new Vector3(net.minecraft.util.math.MathHelper.floor(lookVec.x), lookVec.y, net.minecraft.util.math.MathHelper.floor(lookVec.z)); return MathHelper.pointDistancePlane(source.x, source.z, lookVec.x, lookVec.z); }
@Override @SideOnly(Side.CLIENT) public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { prepDummy(); int text_x = gui.getLeft() + 16; int text_y = gui.getTop() + gui.getHeight() - 40; int entity_scale = getEntityScale(size); int entity_x = gui.getLeft() + gui.getWidth() / 2; int entity_y = gui.getTop() + gui.getHeight() / 2 + MathHelper.floor(dummyEntity.height * entity_scale / 2); renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); PageText.renderText(text_x, text_y, gui.getWidth() - 30, gui.getHeight(), getUnlocalizedName()); }
int entity_scale = getEntityScale(size); int entity_x = gui.getLeft() + gui.getWidth() / 2; int entity_y = gui.getTop() + gui.getHeight() / 2 + MathHelper.floor(dummyEntity.height * entity_scale / 2) - 29;
final int placeTicks = net.minecraft.util.math.MathHelper.floor(targetDistance / speed); spawnBurst(entity.world, new BlockPos(x, y, z), lens); } else if(burst.getTicksExisted() == placeTicks) { int x = net.minecraft.util.math.MathHelper.floor(entity.posX); int y = ItemNBTHelper.getInt(lens, TAG_Y_START, -1) + targetDistance; int z = net.minecraft.util.math.MathHelper.floor(entity.posZ); BlockPos pos = new BlockPos(x, y, z);