net.minecraft.world.ChunkPosition Java Examples
The following examples show how to use
net.minecraft.world.ChunkPosition.
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: ProgWidgetAreaItemBase.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
private void initializeVariableCache(){ areaVariableStates = new HashMap<String, ChunkPosition>(); ProgWidgetArea whitelistWidget = (ProgWidgetArea)getConnectedParameters()[0]; ProgWidgetArea blacklistWidget = (ProgWidgetArea)getConnectedParameters()[getParameters().length]; if(whitelistWidget == null) return; ProgWidgetArea widget = whitelistWidget; while(widget != null) { if(widget.type == ProgWidgetArea.EnumAreaType.RANDOM) canCache = false; if(!widget.getCoord1Variable().equals("")) areaVariableStates.put(widget.getCoord1Variable(), aiManager.getCoordinate(widget.getCoord1Variable())); if(!widget.getCoord2Variable().equals("")) areaVariableStates.put(widget.getCoord2Variable(), aiManager.getCoordinate(widget.getCoord2Variable())); widget = (ProgWidgetArea)widget.getConnectedParameters()[0]; } widget = blacklistWidget; while(widget != null) { if(widget.type == ProgWidgetArea.EnumAreaType.RANDOM) canCache = false; if(!widget.getCoord1Variable().equals("")) areaVariableStates.put(widget.getCoord1Variable(), aiManager.getCoordinate(widget.getCoord1Variable())); if(!widget.getCoord2Variable().equals("")) areaVariableStates.put(widget.getCoord2Variable(), aiManager.getCoordinate(widget.getCoord2Variable())); widget = (ProgWidgetArea)widget.getConnectedParameters()[0]; } }
Example #2
Source File: ProgWidgetAreaItemBase.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static IBlockAccess getCache(Collection<ChunkPosition> area, World world){ if(area.size() == 0) return world; int minX, minY, minZ, maxX, maxY, maxZ; Iterator<ChunkPosition> iterator = area.iterator(); ChunkPosition p = iterator.next(); minX = maxX = p.chunkPosX; minY = maxY = p.chunkPosY; minZ = maxZ = p.chunkPosZ; while(iterator.hasNext()) { p = iterator.next(); minX = Math.min(minX, p.chunkPosX); minY = Math.min(minY, p.chunkPosY); minZ = Math.min(minZ, p.chunkPosZ); maxX = Math.max(maxX, p.chunkPosX); maxY = Math.max(maxY, p.chunkPosY); maxZ = Math.max(maxZ, p.chunkPosZ); } return new ChunkCache(world, minX, minY, minZ, maxX, maxY, maxZ, 0); }
Example #3
Source File: MobileChunk.java From archimedes-ships with MIT License | 6 votes |
/** * Gets the TileEntity for a given block in this chunk */ @Override public TileEntity getTileEntity(int x, int y, int z) { ChunkPosition chunkposition = new ChunkPosition(x, y, z); TileEntity tileentity = chunkTileEntityMap.get(chunkposition); if (tileentity == null) { Block block = getBlock(x, y, z); int meta = getBlockMetadata(x, y, z); if (block == null || !block.hasTileEntity(meta)) { return null; } tileentity = block.createTileEntity(worldObj, meta); setTileEntity(x, y, z, tileentity); tileentity = chunkTileEntityMap.get(chunkposition); } return tileentity; }
Example #4
Source File: MobileChunk.java From archimedes-ships with MIT License | 6 votes |
public MobileChunk(World world, EntityShip entityship) { worldObj = world; entityShip = entityship; blockStorageMap = new HashMap<ChunkPosition, ExtendedBlockStorage>(1); chunkTileEntityMap = new HashMap<ChunkPosition, TileEntity>(2); isChunkLoaded = false; isModified = false; boundsInit = false; minX = minY = minZ = maxX = maxY = maxZ = -1; blockCount = 0; creationSpotBiome = BiomeGenBase.ocean; }
Example #5
Source File: ItemGPSTool.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static ChunkPosition getGPSLocation(ItemStack gpsTool){ NBTTagCompound compound = gpsTool.stackTagCompound; if(compound != null) { String var = getVariable(gpsTool); if(!var.equals("") && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { ChunkPosition pos = GlobalVariableManager.getInstance().getPos(var); setGPSLocation(gpsTool, pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); } int x = compound.getInteger("x"); int y = compound.getInteger("y"); int z = compound.getInteger("z"); if(x != 0 || y != 0 || z != 0) { return new ChunkPosition(x, y, z); } else { return null; } } else { return null; } }
Example #6
Source File: GuiDroneDebuggerOptions.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void drawScreen(int x, int y, float partialTicks){ if(selectedDrone != null) { Minecraft.getMinecraft().fontRenderer.drawString("Drone name: " + selectedDrone.getCommandSenderName(), 20, screenHeight - 15, 0xFFFFFFFF, true); Minecraft.getMinecraft().fontRenderer.drawString("Routine: " + selectedDrone.getLabel(), screenWidth / 2, screenHeight - 15, 0xFFFFFFFF, true); } programmerUnit.render(x, y, true, true, true); programmerUnit.renderForeground(x, y, null); if(selectedDrone == null) { drawCenteredString(Minecraft.getMinecraft().fontRenderer, "Press '" + Keyboard.getKeyName(KeyHandler.getInstance().keybindDebuggingDrone.getKeyCode()) + "' on a Drone when tracked by an Entity Tracker to debug the Drone.", screenWidth / 2, screenHeight / 2, 0xFFFF0000); } IProgWidget widget = programmerUnit.getHoveredWidget(x, y); if(widget == null) widget = areaShowingWidget; upgradeHandler.getShowingPositions().clear(); if(widget != null) { int widgetId = selectedDrone.getProgWidgets().indexOf(widget); for(DebugEntry entry : selectedDrone.getDebugEntries()) { if(entry.getProgWidgetId() == widgetId && !entry.getPos().equals(new ChunkPosition(0, 0, 0))) { upgradeHandler.getShowingPositions().add(entry.getPos()); } } } }
Example #7
Source File: DroneAICC.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public DroneAICC(EntityDrone drone, ProgWidgetCC widget, boolean targetAI){ this.drone = drone; this.widget = widget; Set<ChunkPosition> area = widget.getInterfaceArea(); for(ChunkPosition pos : area) { TileEntity te = drone.worldObj.getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); if(te instanceof TileEntityDroneInterface) { TileEntityDroneInterface inter = (TileEntityDroneInterface)te; if(targetAI) { if(inter.getDrone() == drone) { droneInterface = inter; return; } } else { if(inter.getDrone() == null) { droneInterface = inter; droneInterface.setDrone(drone); return; } } } } droneInterface = null; }
Example #8
Source File: ProgWidgetArea.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
private AxisAlignedBB getAABB(){ ChunkPosition[] areaPoints = getAreaPoints(); if(areaPoints[0] == null) return null; int minX; int minY; int minZ; int maxX; int maxY; int maxZ; if(areaPoints[1] != null) { minX = Math.min(areaPoints[0].chunkPosX, areaPoints[1].chunkPosX); minY = Math.min(areaPoints[0].chunkPosY, areaPoints[1].chunkPosY); minZ = Math.min(areaPoints[0].chunkPosZ, areaPoints[1].chunkPosZ); maxX = Math.max(areaPoints[0].chunkPosX, areaPoints[1].chunkPosX); maxY = Math.max(areaPoints[0].chunkPosY, areaPoints[1].chunkPosY); maxZ = Math.max(areaPoints[0].chunkPosZ, areaPoints[1].chunkPosZ); } else { minX = maxX = areaPoints[0].chunkPosX; minY = maxY = areaPoints[0].chunkPosY; minZ = maxZ = areaPoints[0].chunkPosZ; } return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1); }
Example #9
Source File: AmadronOfferCustom.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static AmadronOfferCustom fromJson(JsonObject json){ AmadronOffer offer = AmadronOffer.fromJson(json); if(offer != null) { AmadronOfferCustom custom = new AmadronOfferCustom(offer.input, offer.output, json.get("offeringPlayerName").getAsString(), json.get("offeringPlayerId").getAsString()); custom.inStock = json.get("inStock").getAsInt(); custom.maxTrades = json.get("maxTrades").getAsInt(); custom.pendingPayments = json.get("pendingPayments").getAsInt(); if(json.has("providingDimensionId")) { custom.providingDimensionId = json.get("providingDimensionId").getAsInt(); custom.providingPosition = new ChunkPosition(json.get("providingX").getAsInt(), json.get("providingY").getAsInt(), json.get("providingZ").getAsInt()); } if(json.has("returningDimensionId")) { custom.returningDimensionId = json.get("returningDimensionId").getAsInt(); custom.returningPosition = new ChunkPosition(json.get("returningX").getAsInt(), json.get("returningY").getAsInt(), json.get("returningZ").getAsInt()); } return custom; } else { return null; } }
Example #10
Source File: ShipHandlerServer.java From archimedes-ships with MIT License | 6 votes |
@Override public void onChunkUpdate() { super.onChunkUpdate(); Collection<ChunkPosition> list = ((MobileChunkServer) ship.getShipChunk()).getSendQueue(); if (firstChunkUpdate) { ship.getCapabilities().spawnSeatEntities(); } else { MsgChunkBlockUpdate msg = new MsgChunkBlockUpdate(ship, list); ArchimedesShipMod.instance.pipeline.sendToAllAround(msg, new TargetPoint(ship.worldObj.provider.dimensionId, ship.posX, ship.posY, ship.posZ, 64D)); } list.clear(); firstChunkUpdate = false; }
Example #11
Source File: ProgWidgetBlockCondition.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget){ return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase)widget){ @Override protected boolean evaluate(ChunkPosition pos){ if(checkingForAir && drone.getWorld().isAirBlock(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) return true; if(checkingForLiquids && PneumaticCraftUtils.isBlockLiquid(drone.getWorld().getBlock(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ))) return true; if(!checkingForAir && !checkingForLiquids || getConnectedParameters()[1] != null) { return DroneAIDig.isBlockValidForFilter(drone.getWorld(), drone, pos, widget); } else { return false; } } }; }
Example #12
Source File: SemiBlockManager.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@SubscribeEvent public void onChunkSave(ChunkDataEvent.Save event){ Map<ChunkPosition, ISemiBlock> map = semiBlocks.get(event.getChunk()); if(map != null && map.size() > 0) { NBTTagList tagList = new NBTTagList(); for(Map.Entry<ChunkPosition, ISemiBlock> entry : map.entrySet()) { NBTTagCompound t = new NBTTagCompound(); entry.getValue().writeToNBT(t); t.setInteger("x", entry.getKey().chunkPosX); t.setInteger("y", entry.getKey().chunkPosY); t.setInteger("z", entry.getKey().chunkPosZ); t.setString("type", getKeyForSemiBlock(entry.getValue())); tagList.appendTag(t); } event.getData().setTag("SemiBlocks", tagList); } }
Example #13
Source File: AmadronOfferManager.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public void tryRestockCustomOffers(){ for(AmadronOffer offer : allOffers) { if(offer instanceof AmadronOfferCustom) { AmadronOfferCustom custom = (AmadronOfferCustom)offer; TileEntity input = custom.getProvidingTileEntity(); TileEntity output = custom.getReturningTileEntity(); int possiblePickups = ContainerAmadron.capShoppingAmount(custom.invert(), 50, input instanceof IInventory ? (IInventory)input : null, output instanceof IInventory ? (IInventory)output : null, input instanceof IFluidHandler ? (IFluidHandler)input : null, output instanceof IFluidHandler ? (IFluidHandler)output : null, null); if(possiblePickups > 0) { ChunkPosition pos = new ChunkPosition(input.xCoord, input.yCoord, input.zCoord); EntityDrone drone = ContainerAmadron.retrieveOrderItems(custom, possiblePickups, input.getWorldObj(), pos, input.getWorldObj(), pos); if(drone != null) { drone.setHandlingOffer(custom.copy(), possiblePickups, null, "Restock"); } } custom.invert(); custom.payout(); } } }
Example #14
Source File: ProgWidgetPressureCondition.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget){ return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase)widget){ @Override protected boolean evaluate(ChunkPosition pos){ TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); if(te instanceof IPneumaticMachine) { IAirHandler airHandler = ((IPneumaticMachine)te).getAirHandler(); float pressure = Float.MIN_VALUE; for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { if(getSides()[d.ordinal()]) { pressure = Math.max(airHandler.getPressure(d), pressure); } } return ((ICondition)widget).getOperator() == ICondition.Operator.EQUALS ? pressure == ((ICondition)widget).getRequiredCount() : pressure >= ((ICondition)widget).getRequiredCount(); } return false; } }; }
Example #15
Source File: TileEntityKeroseneLamp.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); managingLights.clear(); NBTTagList lights = tag.getTagList("lights", 10); for(int i = 0; i < lights.tagCount(); i++) { NBTTagCompound t = lights.getCompoundTagAt(i); managingLights.add(new ChunkPosition(t.getInteger("x"), t.getInteger("y"), t.getInteger("z"))); } tank.readFromNBT(tag.getCompoundTag("tank")); redstoneMode = tag.getByte("redstoneMode"); targetRange = tag.getByte("targetRange"); range = tag.getByte("range"); sideConnected = ForgeDirection.getOrientation(tag.getByte("sideConnected")); readInventoryFromNBT(tag, inventory); }
Example #16
Source File: ActionWidgetButton.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void readFromNBT(NBTTagCompound tag, int guiLeft, int guiTop){ super.readFromNBT(tag, guiLeft, guiTop); widget = new GuiButtonSpecial(-1, tag.getInteger("x") + guiLeft, tag.getInteger("y") + guiTop, tag.getInteger("width"), tag.getInteger("height"), tag.getString("text")); settingCoordinate = new ChunkPosition(tag.getInteger("settingX"), tag.getInteger("settingY"), tag.getInteger("settingZ")); widget.setTooltipText(tag.getString("tooltip")); }
Example #17
Source File: BlockMetadataSensor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public int getRedstoneValue(World world, int x, int y, int z, int sensorRange, String textBoxText, Set<ChunkPosition> positions){ int metadata = 0; for(ChunkPosition pos : positions) { metadata = Math.max(metadata, world.getBlockMetadata(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)); } return metadata; }
Example #18
Source File: TileEntityKeroseneLamp.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void invalidate(){ super.invalidate(); for(ChunkPosition pos : managingLights) { if(isLampLight(pos)) { worldObj.setBlockToAir(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); } } }
Example #19
Source File: DroneAIManager.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public void writeToNBT(NBTTagCompound tag){ NBTTagList tagList = new NBTTagList(); for(Map.Entry<String, ChunkPosition> entry : coordinateVariables.entrySet()) { NBTTagCompound t = new NBTTagCompound(); t.setString("key", entry.getKey()); t.setInteger("x", entry.getValue().chunkPosX); t.setInteger("y", entry.getValue().chunkPosY); t.setInteger("z", entry.getValue().chunkPosZ); tagList.appendTag(t); } tag.setTag("coords", tagList); GlobalVariableManager.getInstance().writeItemVars(tag, itemVariables); }
Example #20
Source File: ProgWidgetAreaItemBase.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private boolean updateVariables(){ boolean varChanged = false; for(Map.Entry<String, ChunkPosition> entry : areaVariableStates.entrySet()) { ChunkPosition newValue = aiManager.getCoordinate(entry.getKey()); if(!newValue.equals(entry.getValue())) { varChanged = true; entry.setValue(newValue); } } return varChanged; }
Example #21
Source File: CommandSetGlobalVariable.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] args){ if(args.length != 4) throw new WrongUsageException("command.deliverAmazon.args"); String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0]; ChunkPosition newPos = new ChunkPosition(parseInt(sender, args[1]), parseInt(sender, args[2]), parseInt(sender, args[3])); GlobalVariableManager.getInstance().set(varName, newPos); sender.addChatMessage(new ChatComponentTranslation("command.setGlobalVariable.output", varName, newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ)); }
Example #22
Source File: DroneAILogistics.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean shouldExecute(){ manager.clearLogistics(); Set<ChunkPosition> area = widget.getCachedAreaSet(); if(area.size() == 0) return false; int minX = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, minZ = Integer.MAX_VALUE, maxZ = Integer.MIN_VALUE; for(ChunkPosition pos : area) { minX = Math.min(minX, pos.chunkPosX); maxX = Math.max(maxX, pos.chunkPosX); minZ = Math.min(minZ, pos.chunkPosZ); maxZ = Math.max(maxZ, pos.chunkPosZ); } for(int x = minX; x < maxX + 16; x += 16) { for(int z = minZ; z < maxZ + 16; z += 16) { Chunk chunk = drone.getWorld().getChunkFromBlockCoords(x, z); Map<ChunkPosition, ISemiBlock> map = SemiBlockManager.getInstance(drone.getWorld()).getSemiBlocks().get(chunk); if(map != null) { for(Map.Entry<ChunkPosition, ISemiBlock> entry : map.entrySet()) { if(entry.getValue() instanceof SemiBlockLogistics && area.contains(entry.getKey())) { SemiBlockLogistics logisticsBlock = (SemiBlockLogistics)entry.getValue(); manager.addLogisticFrame(logisticsBlock); } } } } } curTask = null; return doLogistics(); }
Example #23
Source File: ProgWidgetCoordinateCondition.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean evaluate(IDroneBase drone, IProgWidget widget){ ChunkPosition pos1 = ProgWidgetCoordinateOperator.calculateCoordinate(widget, 0, EnumOperator.PLUS_MINUS); ChunkPosition pos2 = ProgWidgetCoordinateOperator.calculateCoordinate(widget, 1, EnumOperator.PLUS_MINUS); if(checkingAxis[0] && !evaluate(pos1.chunkPosX, pos2.chunkPosX)) return false; if(checkingAxis[1] && !evaluate(pos1.chunkPosY, pos2.chunkPosY)) return false; if(checkingAxis[2] && !evaluate(pos1.chunkPosZ, pos2.chunkPosZ)) return false; return true; }
Example #24
Source File: AreaShowManager.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public AreaShowHandler showArea(Set<ChunkPosition> area, int color, TileEntity areaShower){ if(areaShower == null) return null; removeHandlers(areaShower); AreaShowHandler handler = new AreaShowHandler(area, color); showHandlers.put(new ChunkPosition(areaShower.xCoord, areaShower.yCoord, areaShower.zCoord), handler); return handler; }
Example #25
Source File: ContainerLogistics.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static SemiBlockLogistics getLogistics(EntityPlayer player, ItemStack itemRequester){ if(itemRequester != null && itemRequester.getItem() instanceof ItemLogisticsFrame) { SemiBlockLogistics logistics = (SemiBlockLogistics)SemiBlockManager.getSemiBlockForKey(((ItemLogisticsFrame)itemRequester.getItem()).semiBlockId); logistics.initialize(player.worldObj, new ChunkPosition(0, 0, 0)); logistics.onPlaced(player, itemRequester); return logistics; } else { return null; } }
Example #26
Source File: ItemSeismicSensor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){ if(!world.isRemote) { int testingY = y; while(testingY > 0) { testingY--; if(world.getBlock(x, testingY, z) == FluidRegistry.getFluid(Fluids.oil.getName()).getBlock()) { Set<ChunkPosition> oilPositions = new HashSet<ChunkPosition>(); Stack<ChunkPosition> pendingPositions = new Stack<ChunkPosition>(); pendingPositions.add(new ChunkPosition(x, testingY, z)); while(!pendingPositions.empty()) { ChunkPosition checkingPos = pendingPositions.pop(); for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { ChunkPosition newPos = new ChunkPosition(checkingPos.chunkPosX + d.offsetX, checkingPos.chunkPosY + d.offsetY, checkingPos.chunkPosZ + d.offsetZ); if(world.getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ) == Fluids.oil.getBlock() && world.getBlockMetadata(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ) == 0 && oilPositions.add(newPos)) { pendingPositions.add(newPos); } } } player.addChatComponentMessage(new ChatComponentTranslation("message.seismicSensor.foundOilDetails", EnumChatFormatting.GREEN.toString() + (y - testingY), EnumChatFormatting.GREEN.toString() + oilPositions.size() / 10 * 10)); return true; } } player.addChatComponentMessage(new ChatComponentTranslation("message.seismicSensor.noOilFound")); } return true; // we don't want to use the item. }
Example #27
Source File: DroneInteractRFImport.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean doInteract(ChunkPosition pos, IDrone drone, IBlockInteractHandler interactHandler, boolean simulate){ IEnergyStorage droneEnergy = CoFHCore.getEnergyStorage(drone); if(droneEnergy.getEnergyStored() == droneEnergy.getMaxEnergyStored()) { interactHandler.abort(); return false; } else { TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); if(te instanceof IEnergyProvider) { IEnergyProvider provider = (IEnergyProvider)te; for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { if(interactHandler.getSides()[d.ordinal()]) { int transferedEnergy = droneEnergy.receiveEnergy(provider.extractEnergy(d, interactHandler.useCount() ? interactHandler.getRemainingCount() : Integer.MAX_VALUE, true), true); if(transferedEnergy > 0) { if(!simulate) { interactHandler.decreaseCount(transferedEnergy); droneEnergy.receiveEnergy(transferedEnergy, false); provider.extractEnergy(d, transferedEnergy, false); } return true; } } } } return false; } }
Example #28
Source File: BlockLightLevelSensor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public int getRedstoneValue(World world, int x, int y, int z, int sensorRange, String textBoxText, Set<ChunkPosition> positions){ int lightValue = 0; for(ChunkPosition pos : positions) { lightValue = Math.max(lightValue, world.getBlockLightValue(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)); } return lightValue; }
Example #29
Source File: HeatBehaviourLiquidTransition.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
protected void transformSourceBlock(Block turningBlockSource, Block turningBlockFlowing){ if(FluidUtils.isSourceBlock(getWorld(), getX(), getY(), getZ())) { getWorld().setBlock(getX(), getY(), getZ(), turningBlockSource); onLiquidTransition(getX(), getY(), getZ()); } else { Set<ChunkPosition> traversed = new HashSet<ChunkPosition>(); Stack<ChunkPosition> pending = new Stack<ChunkPosition>(); pending.push(new ChunkPosition(getX(), getY(), getZ())); while(!pending.isEmpty()) { ChunkPosition pos = pending.pop(); for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { ChunkPosition newPos = new ChunkPosition(pos.chunkPosX + d.offsetX, pos.chunkPosY + d.offsetY, pos.chunkPosZ + d.offsetZ); Block checkingBlock = getWorld().getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ); if((checkingBlock == getBlock() || getBlock() == Blocks.flowing_water && checkingBlock == Blocks.water || getBlock() == Blocks.flowing_lava && checkingBlock == Blocks.lava) && traversed.add(newPos)) { if(FluidUtils.isSourceBlock(getWorld(), newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ)) { getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockSource); onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ); return; } else { getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockFlowing); onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ); pending.push(newPos); } } } } } }
Example #30
Source File: BlockRedstoneSensor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public int getRedstoneValue(World world, int x, int y, int z, int sensorRange, String textBoxText, Set<ChunkPosition> positions){ int redstonePower = 0; for(ChunkPosition pos : positions) { redstonePower = Math.max(redstonePower, world.getStrongestIndirectPower(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)); for(int i = 0; i < 6 && redstonePower < 15; i++) redstonePower = Math.max(redstonePower, world.getIndirectPowerLevelTo(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ, i)); if(redstonePower == 15) return 15; } return redstonePower; }