x -= vec.getX() * this.thickness; y -= vec.getY() * this.thickness; z -= vec.getZ() * this.thickness; vertex.vec[0] = x; vertex.vec[1] = y;
public static BlockPos getRandomPositionInArea(Random random, Vec3i area) { int x = random.nextInt(area.getX()); int y = random.nextInt(area.getY()); int z = random.nextInt(area.getZ()); return new BlockPos(x, y, z); }
private static BlockPos transform(Vec3i pos, Vec3i vec3i, Vec3i vec3i1, Vec3i vec3i2) { return new BlockPos( vec3i1.getX() * -pos.getY() + vec3i2.getX() * pos.getZ() + vec3i.getX() * pos.getX(), vec3i1.getY() * -pos.getY() + vec3i2.getY() * pos.getZ() + vec3i.getY() * pos.getX(), vec3i1.getZ() * -pos.getY() + vec3i2.getZ() * pos.getZ() + vec3i.getZ() * pos.getX() ); }
public void setupStructureBuilder(World world, BlockPos pos, TileStructureBuilder tb, String name, EnumFacing face) { StructureTemplateManager.getTemplate(name).ifPresent(t -> { BlockPos p = pos.offset(face, t.getSize().getZ() - 1 - t.getOffset().getZ() + 1); tb.setBuilder(new StructureBuilderTicked(world, t, face, p)); }); }
@Override public Vec3i getOffset() { if (offset == null) { Vec3i area = getArea(); offset = new Vec3i(-area.getX() / 2, -2, -area.getZ() / 2); } return offset; }
public static EntityItem ejectItemInDirection(World world, double x, double y, double z, EnumFacing direction, @Nonnull ItemStack stack) { EntityItem item = BlockUtils.dropItemStackInWorld(world, x, y, z, stack); final Vec3i v = direction.getDirectionVec(); item.motionX = v.getX() / 5F; item.motionY = v.getY() / 5F; item.motionZ = v.getZ() / 5F; return item; }
@Override public Vec3i getOffset() { if (offset == null) { Vec3i area = getArea(); offset = new Vec3i(-area.getX() / 2, -2, -area.getZ() / 2); } return offset; }
public static BlockPos add(Vec3i... vects) { int x = 0; int y = 0; int z = 0; for (Vec3i vect : vects) { x += vect.getX(); y += vect.getY(); z += vect.getZ(); } return new BlockPos(x, y, z); }
@Override public void renderParticle(@Nonnull BufferBuilder buffer, @Nonnull Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { // Move the particle against the face of the block, and counteract the scaling so that it grows from the center buffer.setTranslation(-0.08 * facing.getDirectionVec().getX() * offset, -particleScale * height, -0.08 * facing.getDirectionVec().getZ() * offset); // Lie about rotation so that it always renders facing outwards from the machine super.renderParticle(buffer, entityIn, partialTicks, facing.getDirectionVec().getZ(), 1, facing.getDirectionVec().getX(), 0, 0); buffer.setTranslation(0, 0, 0); } }
public float getPercentDoneWithPass() { float max = (float) template.getSize().getX() * template.getSize().getZ() * template.getSize().getY(); float current = (float) curTempPos.getY() * (template.getSize().getX() * template.getSize().getZ());//add layers done current += curTempPos.getZ() * template.getSize().getX();//add rows done current += curTempPos.getX();//add blocks done return current / max; }
public NonNullList<ItemStack> getResourceList() { if (resourceList == null) { NonNullList<ItemStack> stacks = NonNullList.create(); MathUtils.getAllVecsInBox(Vec3i.NULL_VECTOR, new Vec3i(size.getX() - 1, size.getY() - 1, size.getZ() - 1)) .forEach(pos -> getRuleAt(pos).ifPresent(r -> r.addResources(stacks))); resourceList = InventoryTools.compactStackList(stacks); } return resourceList; }
private static void renderPreviewAt(StructureTemplate structure, StructureBB bb, int turns, BufferBuilder buffer, Map<BlockPos, TemplateRuleBlock> dynamicRenderRules, TemplateBlockAccess blockAccess, BlockPos pos) { BlockPos translateTo = BlockTools.rotateInArea(pos, structure.getSize().getX(), structure.getSize().getZ(), turns).add(bb.min); structure.getBlockRuleAt(pos).ifPresent(r -> { r.renderRule(turns, translateTo, blockAccess, buffer); if (r.isDynamicallyRendered(turns)) { dynamicRenderRules.put(translateTo, r); } }); }
public <T extends Entity> List<T> getEntities(Class<T> eClass, IBeeGenome genome, IBeeHousing housing) { final Vec3i area = genome.getTerritory(); BlockPos coordinates = housing.getCoordinates(); int[] offset = {-Math.round(area.getX() / 2), -Math.round(area.getY() / 2), -Math.round(area.getZ() / 2)}; int[] min = {coordinates.getX() + offset[0], coordinates.getY() + offset[1], coordinates.getZ() + offset[2]}; int[] max = {coordinates.getX() + offset[0] + area.getX(), coordinates.getY() + offset[1] + area.getY(), coordinates.getZ() + offset[2] + area.getZ()}; AxisAlignedBB box = new AxisAlignedBB(min[0], min[1], min[2], max[0], max[1], max[2]); return housing.getWorldObj().getEntitiesWithinAABB(eClass, box); }
@Override public void onImpactWorld(World world, float x, float y, float z, MissileBase missile, RayTraceResult hit) { if (!world.isRemote) { Vec3i dirVec = hit.sideHit.getDirectionVec(); Vec3d hitVec = hit.hitVec.addVector(dirVec.getX() * 0.2d, dirVec.getY() * 0.2d, dirVec.getZ() * 0.2d); createExplosion(world, missile, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, 0.6f); } }
@Override public int getAdjustedSpawnY(World world, int x, int y, int z, EnumFacing face, StructureTemplate template, StructureBB bb) { testMin = new BlockPos(x, y, z).offset(face, template.getOffset().getZ()); return WorldStructureGenerator.getTargetY(world, testMin.getX(), testMin.getZ(), false) + 1; }
@Override protected void preRotate(TileColossalBloodChest chestTile) { if(chestTile.canWork()) { Vec3i renderOffset = chestTile.getRenderOffset(); GlStateManager.translate(-renderOffset.getX(), renderOffset.getY(), renderOffset.getZ()); } GlStateManager.translate(0.5F, 0, 0.5F); GlStateManager.scale(3, 3, 3); }
public void calculateTranslation(LPRoutedFluid fluid, float partialTicks) { //double itemTicks = item.ticks; float fluidTicks = fluid.ticks + partialTicks; double newX = (fluid.getHeading().getDirectionVec().getX() * (fluidTicks / fluid.TICK_MAX - 0.5)); double newY = (fluid.getHeading().getDirectionVec().getY() * (fluidTicks / fluid.TICK_MAX - 0.5)); double newZ = (fluid.getHeading().getDirectionVec().getZ() * (fluidTicks / fluid.TICK_MAX - 0.5)); //System.out.println("Translating: " + newX + ", " + newY + ", " + newZ + " : PartialTicks=" + partialTicks); GlStateManager.translate(newX, newY, newZ); } }
void addVecWithUV(BufferBuilder tes, Vector3d vec, double u, double v, float cm, EnumFacing normal) { tes.pos(vec.x, vec.y, vec.z).tex(u, v).color(cm, cm, cm, 1) .normal(normal.getDirectionVec().getX(), normal.getDirectionVec().getY(), normal.getDirectionVec().getZ()).endVertex(); }
@Override public Iterator<BlockPos.MutableBlockPos> getAreaIterator(IBeeHousing beeHousing, IBee bee) { IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing); Vec3i area = getArea(bee.getGenome(), beeModifier); BlockPos minPos = beeHousing.getCoordinates().add(-area.getX() / 2, -area.getY() / 2, -area.getZ() / 2); BlockPos maxPos = minPos.add(area); World world = beeHousing.getWorldObj(); return VectUtil.getAllInBoxFromCenterMutable(world, minPos, beeHousing.getCoordinates(), maxPos); }