Java Code Examples for net.minecraft.util.EnumFacing#VALUES
The following examples show how to use
net.minecraft.util.EnumFacing#VALUES .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockAntCoveredCake.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
/** * Get a list of sides of a given block that ant particles can spawn on. * Ant particles can spawn on a face if any of the following are true: * -- the adjacent block returns false for doesSideBlockRendering (most blocks just call isOpaqueCube for this) * -- the given block's collision AABB does not fully extend to that side * @param world The world * @param pos The blockpos of the relevant block * @return A List of EnumFacings that ant particles can spawn on */ public static List<EnumFacing> getAntableSides(World world, BlockPos pos) { List<EnumFacing> out = new LinkedList<EnumFacing>(); AxisAlignedBB aabb = world.getBlockState(pos).getCollisionBoundingBox(world, pos); for (EnumFacing face : EnumFacing.VALUES) { if (!world.getBlockState(pos.offset(face)).doesSideBlockRendering(world, pos, face.getOpposite()) || !doesAABBExtendToFace(aabb, face)) { out.add(face); } } return out; }
Example 2
Source File: RailNetworkManager.java From Signals with GNU General Public License v3.0 | 6 votes |
/** * The initial nodes used to build out the network from. * Signals, Station Markers, rail links. Only used when force rebuilding the network. * @return */ private Set<MCPos> getStartNodes(){ Set<MCPos> nodes = new HashSet<>(); for(World world : DimensionManager.getWorlds()) { for(TileEntity te : world.loadedTileEntityList) { if(te instanceof TileEntityBase) { //Any Signals TE for testing purposes nodes.add(new MCPos(world, te.getPos())); for(EnumFacing facing : EnumFacing.VALUES) { BlockPos pos = te.getPos().offset(facing); nodes.add(new MCPos(world, pos)); } } } } return nodes; }
Example 3
Source File: GTModelWire.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) private Map<EnumFacing, BakedQuad> generateCoreQuads(GTBlockBaseConnect wire, int min, int max) { Vector3f minF = new Vector3f((float) min, (float) min, (float) min); Vector3f maxF = new Vector3f((float) max, (float) max, (float) max); BlockPartFace face = new BlockPartFace((EnumFacing) null, 0, "", new BlockFaceUV(new float[] { (float) min, (float) min, (float) max, (float) max }, 0)); Map<EnumFacing, BakedQuad> quads = new EnumMap(EnumFacing.class); EnumFacing[] var8 = EnumFacing.VALUES; int var9 = var8.length; for (int var10 = 0; var10 < var9; ++var10) { EnumFacing side = var8[var10]; quads.put(side, this.getBakery().makeBakedQuad(minF, maxF, face, wire.getTextureFromState(this.state, side), side, ModelRotation.X0_Y0, (BlockPartRotation) null, true, true)); } return quads; }
Example 4
Source File: PipeCoverableImplementation.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public void readInitialSyncData(PacketBuffer buf) { for (EnumFacing coverSide : EnumFacing.VALUES) { int coverId = buf.readVarInt(); if (coverId != -1) { CoverDefinition coverDefinition = CoverDefinition.getCoverByNetworkId(coverId); CoverBehavior coverBehavior = coverDefinition.createCoverBehavior(this, coverSide); coverBehavior.readInitialSyncData(buf); this.coverBehaviors[coverSide.getIndex()] = coverBehavior; } } }
Example 5
Source File: BlockSeal.java From AdvancedRocketry with MIT License | 5 votes |
public void removeSeal(World worldIn, BlockPos pos) { AtmosphereHandler atmhandler = AtmosphereHandler.getOxygenHandler(worldIn.provider.getDimension()); if(atmhandler == null) return; for(EnumFacing dir : EnumFacing.VALUES) { BlobHandler handler = blobList.remove(new HashedBlockPosition(pos.offset(dir))); if (handler != null) atmhandler.unregisterBlob(handler); } }
Example 6
Source File: BlockRotationModeTest.java From OpenModsLib with MIT License | 5 votes |
@Test public void toolRotationOnAnySideChangesFrontToClickedSideOrOpposite() { for (Orientation orientation : MODE.getValidDirections()) { for (EnumFacing rotatedSide : EnumFacing.VALUES) { checkFrontDirectionsAfterFourRotations(MODE, rotatedSide, orientation, rotatedSide, rotatedSide.getOpposite()); } } }
Example 7
Source File: InjectorTileEntity.java From EmergingTechnology with MIT License | 5 votes |
private void pushToFluidConsumers() { for (EnumFacing facing : EnumFacing.VALUES) { if (this.getNutrientFluid() < EmergingTechnologyConfig.HYDROPONICS_MODULE.INJECTOR.injectorFluidTransferRate) { return; } TileEntity neighbour = this.world.getTileEntity(this.pos.offset(facing)); // Return if no tile entity if (neighbour == null) { continue; } IFluidHandler neighbourFluidHandler = neighbour .getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite()); // Return if neighbour has no fluid tank if (neighbourFluidHandler == null) { continue; } // Fill the neighbour int filled = neighbourFluidHandler.fill(new FluidStack(ModFluids.NUTRIENT, EmergingTechnologyConfig.HYDROPONICS_MODULE.INJECTOR.injectorFluidTransferRate), true); this.nutrientFluidHandler.drain(filled, true); } }
Example 8
Source File: CapabilityMinecartDestination.java From Signals with GNU General Public License v3.0 | 5 votes |
/** * * @param cart * @return true if there was a valid hopper (not necessarily if extracted an item) */ private boolean extractFuelFromHopper(EntityMinecart cart, BlockPos pos){ boolean foundHopper = false; for(EnumFacing dir : EnumFacing.VALUES) { BlockPos neighbor = pos; for(int offsetTimes = 0; offsetTimes < (dir == EnumFacing.UP ? 2 : 1); offsetTimes++) { neighbor = neighbor.offset(dir); TileEntity te = cart.world.getTileEntity(neighbor); if(te instanceof TileEntityHopper) { EnumFacing hopperDir = cart.world.getBlockState(neighbor).getValue(BlockHopper.FACING); if(hopperDir.getOpposite() == dir) { TileEntityHopper hopper = (TileEntityHopper)te; for(int i = 0; i < hopper.getSizeInventory(); i++) { ItemStack stack = hopper.getStackInSlot(i); if(!stack.isEmpty() && getFuelInv().isItemValidForSlot(0, stack)) { ItemStack inserted = stack.copy(); inserted.setCount(1); ItemStack left = ItemHandlerHelper.insertItemStacked(getEngineItemHandler(), inserted, false); if(left.isEmpty()) { stack.shrink(1); hopper.markDirty(); return true; } } } foundHopper = true; } } } } return foundHopper; }
Example 9
Source File: SimpleMachineMetaTileEntity.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void receiveCustomData(int dataId, PacketBuffer buf) { super.receiveCustomData(dataId, buf); if (dataId == 100) { this.outputFacing = EnumFacing.VALUES[buf.readByte()]; getHolder().scheduleChunkForRenderUpdate(); } else if (dataId == 101) { this.autoOutputItems = buf.readBoolean(); getHolder().scheduleChunkForRenderUpdate(); } else if (dataId == 102) { this.autoOutputFluids = buf.readBoolean(); getHolder().scheduleChunkForRenderUpdate(); } }
Example 10
Source File: PipeCoverableImplementation.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public void updateInputRedstoneSignals() { for (EnumFacing side : EnumFacing.VALUES) { int redstoneValue = GTUtility.getRedstonePower(getWorld(), getPos(), side); int currentValue = sidedRedstoneInput[side.getIndex()]; if(redstoneValue != currentValue) { this.sidedRedstoneInput[side.getIndex()] = redstoneValue; CoverBehavior coverBehavior = getCoverAtSide(side); if(coverBehavior != null) { coverBehavior.onRedstoneInputSignalChange(redstoneValue); } } } }
Example 11
Source File: OrientedOverlayRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) public void render(CCRenderState renderState, Matrix4 translation, IVertexOperation[] ops, Cuboid6 bounds, EnumFacing frontFacing, boolean isActive) { for (EnumFacing renderSide : EnumFacing.VALUES) { OverlayFace overlayFace = OverlayFace.bySide(renderSide, frontFacing); if (sprites.containsKey(overlayFace)) { TextureAtlasSprite renderSprite = sprites.get(overlayFace).getSprite(isActive); Textures.renderFace(renderState, translation, ops, renderSide, bounds, renderSprite); } } }
Example 12
Source File: DirUtils.java From OpenModsLib with MIT License | 4 votes |
@Override protected EnumFacing convert(int bit) { return EnumFacing.VALUES[bit]; }
Example 13
Source File: BlockTextureTransformTest.java From OpenModsLib with MIT License | 4 votes |
public void testInversion(BlockTextureTransform t) { for (EnumFacing dir : EnumFacing.VALUES) testInversion(t, dir); }
Example 14
Source File: ModuleEffectPhase.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Override @SideOnly(Side.CLIENT) public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) { EnumFacing faceHit = spell.getFaceHit(); Set<BlockPos> blockSet = spell.getDataWithFallback(SpellData.DefaultKeys.BLOCK_SET, new BlockSet(new HashSet<>())).getBlockSet(); Map<BlockPos, IBlockState> blockStateCache = spell.getDataWithFallback(SpellData.DefaultKeys.BLOCKSTATE_CACHE, new BlockStateCache(new HashMap<>())).getBlockStateCache(); HashMap<BlockPos, IBlockState> tmpCache = new HashMap<>(blockStateCache); double duration = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 20; PhasedBlockRenderer.addPhase(world, blockSet, (int) duration); if (faceHit != null) { for (Map.Entry<BlockPos, IBlockState> entry : tmpCache.entrySet()) { IBlockState thisState = entry.getValue(); if (thisState.getBlock() != ModBlocks.FAKE_AIR) continue; ParticleBuilder glitter2 = new ParticleBuilder(10); glitter2.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED)); glitter2.disableRandom(); ParticleSpawner.spawn(glitter2, world, new StaticInterp<>(new Vec3d(entry.getKey()).add(0.5, 0.5, 0.5)), 5, (int) duration, (aFloat, build) -> { build.setColor(Color.CYAN); //build.setAlphaFunction(new InterpFloatInOut(1f, 0.1f)); build.setAlpha(RandUtil.nextFloat(0.05f, 0.2f)); build.setPositionOffset(new Vec3d( RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5) )); build.setMotion(new Vec3d( RandUtil.nextDouble(-0.001, 0.001), RandUtil.nextDouble(-0.001, 0.001), RandUtil.nextDouble(-0.001, 0.001) )); build.setLifetime(RandUtil.nextInt(20, 40)); build.setScaleFunction(new InterpFloatInOut(0.9f, 0.9f)); build.setScale(RandUtil.nextFloat(0.1f, 0.3f)); }); BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(entry.getKey()); for (EnumFacing facing : EnumFacing.VALUES) { mutable.move(facing); IBlockState adjState; if (!blockStateCache.containsKey(mutable)) { adjState = world.getBlockState(mutable); blockStateCache.put(mutable.toImmutable(), adjState); } else adjState = blockStateCache.get(mutable); if (adjState.getBlock() != Blocks.AIR && adjState.getBlock() != ModBlocks.FAKE_AIR) { Vec3d directionOffsetVec = new Vec3d(facing.getOpposite().getDirectionVec()).scale(0.5); Vec3d adjPos = new Vec3d(mutable).add(0.5, 0.5, 0.5).add(directionOffsetVec); for (EnumFacing subFacing : getPerpendicularFacings(facing)) { mutable.move(subFacing); IBlockState subState; if (!blockStateCache.containsKey(mutable)) { subState = world.getBlockState(mutable); blockStateCache.put(mutable.toImmutable(), subState); } else subState = blockStateCache.get(mutable); if (BlockUtils.isAnyAir(subState)) { Vec3d subPos = new Vec3d(mutable).add(0.5, 0.5, 0.5).add(directionOffsetVec); Vec3d midPointVec = new Vec3d( (adjPos.x + subPos.x) / 2.0, (adjPos.y + subPos.y) / 2.0, (adjPos.z + subPos.z) / 2.0); Vec3d sub = subPos.subtract(adjPos); EnumFacing adjSubFacing = EnumFacing.getFacingFromVector((float) sub.x, (float) sub.y, (float) sub.z); Vec3d cross = new Vec3d(adjSubFacing.getDirectionVec()).crossProduct(new Vec3d(facing.getDirectionVec())).normalize().scale(0.5); ParticleBuilder glitter = new ParticleBuilder(10); glitter.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED)); glitter.disableRandom(); ParticleSpawner.spawn(glitter, world, new StaticInterp<>(midPointVec), 50, (int) duration, (aFloat, build) -> { build.setColor(Color.CYAN); //build.setAlphaFunction(new InterpFloatInOut(1f, 0.1f)); build.setAlpha(RandUtil.nextFloat(0.3f, 0.7f)); build.setPositionOffset(cross.scale(RandUtil.nextFloat(-1, 1))); build.setLifetime(RandUtil.nextInt(20, 40)); build.setScaleFunction(new InterpFloatInOut(0.9f, 0.9f)); build.setScale(RandUtil.nextFloat(0.2f, 0.5f)); }); } mutable.move(subFacing.getOpposite()); } } mutable.move(facing.getOpposite()); } } } }
Example 15
Source File: BlockTextureTransformTest.java From OpenModsLib with MIT License | 4 votes |
@Test public void testInversionAfterMirrorVRotation() { for (EnumFacing dir : EnumFacing.VALUES) testInversion(BlockTextureTransform.builder().mirrorV(dir).build()); }
Example 16
Source File: BlockTextureTransformTest.java From OpenModsLib with MIT License | 4 votes |
@Test public void testInversionAfterMirrorURotation() { for (EnumFacing dir : EnumFacing.VALUES) testInversion(BlockTextureTransform.builder().mirrorU(dir).build()); }
Example 17
Source File: BlockTextureTransformTest.java From OpenModsLib with MIT License | 4 votes |
@Test public void testInversionAfterMirrorUVRotation() { for (EnumFacing dir : EnumFacing.VALUES) testInversion(BlockTextureTransform.builder().mirrorUV(dir).build()); }
Example 18
Source File: OptimiserHelper.java From EmergingTechnology with MIT License | 4 votes |
public static void pushPacketsToAdjacentMachines(World world, BlockPos pos, OptimiserPacket packet) { for (EnumFacing facing : EnumFacing.VALUES) { for (int i = 1; i < EmergingTechnologyConfig.ELECTRICS_MODULE.OPTIMISER.range; i++) { TileEntity tile = world.getTileEntity(pos.offset(facing, i)); if (tile == null) continue; if (tile instanceof IOptimisableTile == false) continue; IOptimisableTile machine = (IOptimisableTile) tile; machine.getPacket().merge(packet); } } }
Example 19
Source File: BlockSeal.java From AdvancedRocketry with MIT License | 4 votes |
public void fireCheckAllDirections(World worldIn, BlockPos startBlock, EnumFacing directionFrom) { for(EnumFacing dir : EnumFacing.VALUES) { if(directionFrom.getOpposite() != dir) fireCheck(worldIn, startBlock.offset(dir)); } }
Example 20
Source File: MultiLayerModel.java From OpenModsLib with MIT License | 4 votes |
private static void buildQuadsForLayer(List<BakedQuad> quads, IBakedModel model) { quads.addAll(model.getQuads(null, null, 0)); for (EnumFacing side : EnumFacing.VALUES) quads.addAll(model.getQuads(null, side, 0)); }