private static void addVertexAtWithTranslation(Tessellator tess, EnumFacing dir, double xpos, double ypos, double zpos, double rand, double l) { double freq = 20; double ampl = (0.15 * (Math.sin(l * 2F) * 0.5 + 0.5) + 0.1) * sizeAlpha; double randMul = 0.05; double x = xpos + Math.sin(l * freq) * ampl * Math.abs(Math.abs(dir.getXOffset()) - 1) + rand * randMul; double y = ypos + Math.cos(l * freq) * ampl * Math.abs(Math.abs(dir.getYOffset()) - 1) + rand * randMul; double z = zpos + (dir.getYOffset() == 0 ? Math.sin(l * freq) : Math.cos(l * freq)) * ampl * Math.abs(Math.abs(dir.getZOffset()) - 1) + rand * randMul; tess.getBuffer().pos(x, y, z).endVertex(); }
@Override public void onUpdate() { super.onUpdate(); if(supertile.getWorld().rand.nextInt(4) == 0) Botania.proxy.wispFX(supertile.getPos().getX() + Math.random(), supertile.getPos().getY() + Math.random(), supertile.getPos().getZ() + Math.random(), 0.05F, 0.05F, 0.05F, 0.25F + (float) Math.random() * 0.15F, orientation.getXOffset() * 0.1F, orientation.getYOffset() * 0.1F, orientation.getZOffset() * 0.1F); if(windTicks == 0 && mana > 0) { windTicks = 20; mana--; } if(windTicks > 0 && redstoneSignal == 0) { AxisAlignedBB axis = aabbForOrientation(); if(axis != null) { List<EntityItem> items = supertile.getWorld().getEntitiesWithinAABB(EntityItem.class, axis); int slowdown = getSlowdownFactor(); for(EntityItem item : items) { if(!item.isDead && item.age >= slowdown) { item.motionX += orientation.getXOffset() * 0.05; item.motionY += orientation.getYOffset() * 0.05; item.motionZ += orientation.getZOffset() * 0.05; } } } windTicks--; } }
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) { ItemStack stack = player.getHeldItem(hand); if(ManaItemHandler.requestManaExactForTool(stack, player, COST, false) && !world.provider.doesWaterVaporize()) { // Adapted from bucket code RayTraceResult mop = rayTrace(world, player, false); if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos hitPos = mop.getBlockPos(); if(!world.isBlockModifiable(player, hitPos)) return EnumActionResult.FAIL; BlockPos placePos = hitPos.offset(mop.sideHit); if(player.canPlayerEdit(placePos, mop.sideHit, stack)) { if (ManaItemHandler.requestManaExactForTool(stack, player, COST, true) && ((ItemBucket) Items.WATER_BUCKET).tryPlaceContainedLiquid(player, world, placePos)) { for(int i = 0; i < 6; i++) Botania.proxy.sparkleFX(pos.getX() + side.getXOffset() + Math.random(), pos.getY() + side.getYOffset() + Math.random(), pos.getZ() + side.getZOffset() + Math.random(), 0.2F, 0.2F, 1F, 1F, 5); return EnumActionResult.SUCCESS; } } } return EnumActionResult.FAIL; } return EnumActionResult.PASS; }
public static EnumActionResult place(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ, Block block, int cost, float r, float g, float b) { ItemStack stack = player.getHeldItem(hand); if(ManaItemHandler.requestManaExactForTool(stack, player, cost, false)) { int entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos.offset(side), pos.offset(side).add(1, 1, 1))).size(); if(entities == 0) { ItemStack stackToPlace = new ItemStack(block); player.setHeldItem(hand, stackToPlace); stackToPlace.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ); player.setHeldItem(hand, stack); if(stackToPlace.isEmpty()) { ManaItemHandler.requestManaExactForTool(stack, player, cost, true); for(int i = 0; i < 6; i++) Botania.proxy.sparkleFX(pos.getX() + side.getXOffset() + Math.random(), pos.getY() + side.getYOffset() + Math.random(), pos.getZ() + side.getZOffset() + Math.random(), r, g, b, 1F, 5); return EnumActionResult.SUCCESS; } } return EnumActionResult.FAIL; } return EnumActionResult.PASS; }
boolean silk = EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0; boolean thor = ItemThorRing.getThorRing(player) != null; boolean doX = thor || side.getXOffset() == 0; boolean doY = thor || side.getYOffset() == 0; boolean doZ = thor || side.getZOffset() == 0;
@Override public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { if(!isManaBlock && pos.entityHit == null && pos.getBlockPos() != null) { BlockPos coords = burst.getBurstSourceBlockPos(); if(!coords.equals(pos.getBlockPos())) { Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ); EnumFacing dir = pos.sideHit; Vector3 normalVector = new Vector3(dir.getXOffset(), dir.getYOffset(), dir.getZOffset()).normalize(); Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec); burst.setMotion(movementVec.x, movementVec.y, movementVec.z); dead = false; } } return dead; }
else if(!world.isRemote) { ItemStack stack = new ItemStack(ModBlocks.pistonRelay); world.spawnEntity(new EntityItem(world, x + dir.getXOffset(), y + dir.getYOffset(), z + dir.getZOffset(), stack));
for(int y = 0; y < yOff * 2 + 1; y++) { for(int z = -zOff; z < zOff + 1; z++) { int xp = pos.getX() + x + dir.getXOffset(); int yp = pos.getY() + y + dir.getYOffset(); int zp = pos.getZ() + z + dir.getZOffset();
Vector3 currentMovementVec = new Vector3(motionX, motionY, motionZ); EnumFacing dir = pos.sideHit; Vector3 normalVector = new Vector3(dir.getXOffset(), dir.getYOffset(), dir.getZOffset()).normalize(); Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec);
private int getWorldEventDataFrom(EnumFacing facingIn) { return facingIn.getXOffset() + 1 + (facingIn.getZOffset() + 1) * 3; } }
@Nonnull @Override public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { World world = source.getWorld(); EnumFacing enumfacing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING); double d0 = source.getX() + enumfacing.getXOffset() * 1.125F; double d1 = source.getY() + enumfacing.getYOffset() * 1.125F; double d2 = source.getZ() + enumfacing.getZOffset() * 1.125F; BlockPos pos = source.getBlockPos().offset(enumfacing); IBlockState state = world.getBlockState(pos); double d3; if(BlockRailBase.isRailBlock(state)) d3 = 0.0D; else { if(state.getMaterial() != Material.AIR || !BlockRailBase.isRailBlock(world.getBlockState(pos.down()))) return super.dispenseStack(source, stack); d3 = -1.0D; } EntityMinecart entityminecart = new EntityPoolMinecart(world, d0, d1 + d3, d2); if(stack.hasDisplayName()) entityminecart.setCustomNameTag(stack.getDisplayName()); world.spawnEntity(entityminecart); stack.splitStack(1); return stack; }
/** * Gets the X, Y, Z speeds for the smoke particles. * @param dir The dir * @return {double, double, double} */ private double[] getSmokeSpeeds(EnumFacing dir) { return new double[] { dir.getXOffset() * 0.2F, dir.getYOffset() * 0.2F, dir.getZOffset() * 0.2F }; }
private double getDispensePositionX() { return (double) pos.getX() + 0.5D + 0.8D * (double) getDirection().getXOffset(); }
public static void addTransformParticles(World worldIn, BlockPos pos, Random rand) { if (!shouldSpawnParticle(worldIn)) { return; } if (rand.nextFloat() >= 0.65F) { for (int i = 0; i < 3; i++) { EnumFacing facing = EnumFacing.HORIZONTALS[rand.nextInt(4)]; int xOffset = facing.getXOffset(); int zOffset = facing.getZOffset(); double x = pos.getX() + 0.5 + (xOffset * 8 + ((1 - MathHelper.abs(xOffset)) * (0.5 - rand.nextFloat()) * 8)) / 16.0; double y = pos.getY() + (0.75 + rand.nextFloat() * 14.5) / 16.0; double z = pos.getZ() + 0.5 + (zOffset * 8 + ((1 - MathHelper.abs(zOffset)) * (0.5 - rand.nextFloat()) * 8)) / 16.0; ParticleRender.addEntityTransformParticle(worldIn, x, y, z); } } }
public int findPathOptions(PathPoint[] pathOptions, PathPoint currentPoint, PathPoint targetPoint, float maxDistance) { int i = 0; for (EnumFacing enumfacing : EnumFacing.values()) { PathPoint pathpoint = this.getWaterNode(currentPoint.x + enumfacing.getXOffset(), currentPoint.y + enumfacing.getYOffset(), currentPoint.z + enumfacing.getZOffset()); if (pathpoint != null && !pathpoint.visited && pathpoint.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint; } } return i; }
/** * Get the position where the dispenser at the given Coordinates should dispense to. */ public IPosition getDispensePosition(IBlockSource coords) { EnumFacing enumfacing = this.getFacing(coords.getBlockState()); double d0 = coords.getX() + 0.7D * enumfacing.getXOffset(); double d1 = coords.getY() + 0.7D * enumfacing.getYOffset(); double d2 = coords.getZ() + 0.7D * enumfacing.getZOffset(); return new PositionImpl(d0, d1, d2); }
/** * Gets the X, Y, Z positions for the smoke particles. * @param dir The dir * @return {double, double, double} */ private double[] getSmokePositions(EnumFacing dir) { return new double[] { pos.getX() + getRandomOrSlight(dir.getXOffset()), pos.getY() + getRandomOrSlight(dir.getYOffset()), pos.getZ() + getRandomOrSlight(dir.getZOffset()) }; }
public void shootThisDirection(EnumFacing enumfacing) { BlockPos position = this.getPosition().up().offset(enumfacing, 2); EntityTippedArrow entitytippedarrow = new EntityTippedArrow(world, position.getX(), position.getY(), position.getZ()); entitytippedarrow.setPotionEffect(PotionUtils.addPotionToItemStack(new ItemStack(Items.TIPPED_ARROW), PotionType.getPotionTypeForName("slowness"))); entitytippedarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; entitytippedarrow.shoot(enumfacing.getXOffset(), YAW, enumfacing.getZOffset(), VELOCITY, INACCRACY); world.spawnEntity(entitytippedarrow); }
private boolean areCoordinatesOnSide(EnumFacing side, TileEntity target) { return source.getPos().getX() + side.getXOffset() == target.getPos().getX() && source.getPos().getY() + side.getYOffset() == target.getPos().getY() && source.getPos().getZ() + side.getZOffset() == target.getPos().getZ(); }
private boolean tryPlantingCocoa(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection farmDirection) { BlockPos.MutableBlockPos current = new BlockPos.MutableBlockPos(position); IBlockState blockState = world.getBlockState(current); while (isJungleTreeTrunk(blockState)) { for (EnumFacing direction : EnumFacing.HORIZONTALS) { BlockPos candidate = new BlockPos(current.getX() + direction.getXOffset(), current.getY(), current.getZ() + direction.getZOffset()); if (world.isBlockLoaded(candidate) && world.isAirBlock(candidate)) { return farmHousing.plantGermling(cocoa, world, candidate, farmDirection); } } current.move(EnumFacing.UP); if (current.getY() - position.getY() > 1) { break; } blockState = world.getBlockState(current); } return false; }