Search in sources :

Example 1 with WorkHandler

use of net.roguelogix.biggerreactors.api.WorkHandler in project BiggerReactors by BiggerSeries.

the class CyaniteReprocessorTile method clearContent.

/**
 * Clears all data and inventory for this tile.
 */
@Override
public void clearContent() {
    // Reset work.
    this.workHandler = new WorkHandler(Config.CONFIG.CyaniteReprocessor.TotalWorkTime);
    // Reset items.
    this.itemHandler = new CyaniteReprocessorItemHandler();
    this.itemHandler.setSize(2);
    // Reset energy.
    this.energyStorage = new EnergyStorage(Config.CONFIG.CyaniteReprocessor.EnergyTankCapacity);
    // Reset fluids.
    this.fluidTank = new FluidTank(Config.CONFIG.CyaniteReprocessor.WaterTankCapacity, fluid -> fluid.getFluid() == Fluids.WATER);
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) IFluidTank(net.minecraftforge.fluids.IFluidTank) IItemHandler(net.minecraftforge.items.IItemHandler) Items(net.minecraft.world.item.Items) Direction(net.minecraft.core.Direction) AbstractContainerMenu(net.minecraft.world.inventory.AbstractContainerMenu) CyaniteReprocessorState(net.roguelogix.biggerreactors.machine.state.CyaniteReprocessorState) IHasUpdatableState(net.roguelogix.phosphophyllite.client.gui.api.IHasUpdatableState) BlockState(net.minecraft.world.level.block.state.BlockState) FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) Inventory(net.minecraft.world.entity.player.Inventory) LazyOptional(net.minecraftforge.common.util.LazyOptional) ServerPlayer(net.minecraft.server.level.ServerPlayer) IWorkHandler(net.roguelogix.biggerreactors.api.IWorkHandler) CyaniteReprocessor(net.roguelogix.biggerreactors.machine.blocks.CyaniteReprocessor) BlutoniumIngot(net.roguelogix.biggerreactors.items.ingots.BlutoniumIngot) CyaniteReprocessorItemHandler(net.roguelogix.biggerreactors.machine.tiles.impl.CyaniteReprocessorItemHandler) net.minecraft.world(net.minecraft.world) Fluids(net.minecraft.world.level.material.Fluids) BiggerReactors(net.roguelogix.biggerreactors.BiggerReactors) Nonnull(javax.annotation.Nonnull) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Nullable(javax.annotation.Nullable) CapabilityEnergy(net.minecraftforge.energy.CapabilityEnergy) EnergyStorage(net.minecraftforge.energy.EnergyStorage) CyaniteReprocessorContainer(net.roguelogix.biggerreactors.machine.containers.CyaniteReprocessorContainer) RegisterTile(net.roguelogix.phosphophyllite.registry.RegisterTile) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) Component(net.minecraft.network.chat.Component) CapabilityFluidHandler(net.minecraftforge.fluids.capability.CapabilityFluidHandler) DebugTool(net.roguelogix.phosphophyllite.debug.DebugTool) BlockHitResult(net.minecraft.world.phys.BlockHitResult) Capability(net.minecraftforge.common.capabilities.Capability) Player(net.minecraft.world.entity.player.Player) Objects(java.util.Objects) TextComponent(net.minecraft.network.chat.TextComponent) CompoundTag(net.minecraft.nbt.CompoundTag) WorkHandler(net.roguelogix.biggerreactors.api.WorkHandler) BlockPos(net.minecraft.core.BlockPos) BlockEntityType(net.minecraft.world.level.block.entity.BlockEntityType) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) Config(net.roguelogix.biggerreactors.Config) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidTank(net.minecraftforge.fluids.IFluidTank) ItemStack(net.minecraft.world.item.ItemStack) IEnergyStorage(net.minecraftforge.energy.IEnergyStorage) Level(net.minecraft.world.level.Level) BaseContainerBlockEntity(net.minecraft.world.level.block.entity.BaseContainerBlockEntity) NetworkHooks(net.minecraftforge.network.NetworkHooks) CyaniteReprocessorItemHandler(net.roguelogix.biggerreactors.machine.tiles.impl.CyaniteReprocessorItemHandler) IWorkHandler(net.roguelogix.biggerreactors.api.IWorkHandler) WorkHandler(net.roguelogix.biggerreactors.api.WorkHandler) EnergyStorage(net.minecraftforge.energy.EnergyStorage) IEnergyStorage(net.minecraftforge.energy.IEnergyStorage)

Example 2 with WorkHandler

use of net.roguelogix.biggerreactors.api.WorkHandler in project BiggerReactors by BiggerSeries.

the class CyaniteReprocessorTile method load.

/**
 * Read NBT data from the world.
 *
 * @param parentCompound The parent compound to read from.
 */
@Override
public void load(@Nonnull CompoundTag parentCompound) {
    super.load(parentCompound);
    CompoundTag childCompound = parentCompound.getCompound("cyaniteReprocessorState");
    // Read work.
    this.workHandler = new WorkHandler(childCompound.getInt("workTimeTotal"), childCompound.getInt("workTime"));
    // Read items.
    this.itemHandler.deserializeNBT(childCompound.getCompound("inventory"));
    // Read energy.
    this.energyStorage = new EnergyStorage(childCompound.getInt("energyCapacity"), Config.CONFIG.CyaniteReprocessor.TransferRate, Config.CONFIG.CyaniteReprocessor.TransferRate, childCompound.getInt("energyStored"));
    // Read fluids.
    this.fluidTank = this.fluidTank.readFromNBT(childCompound.getCompound("fluidStorage"));
}
Also used : IWorkHandler(net.roguelogix.biggerreactors.api.IWorkHandler) WorkHandler(net.roguelogix.biggerreactors.api.WorkHandler) EnergyStorage(net.minecraftforge.energy.EnergyStorage) IEnergyStorage(net.minecraftforge.energy.IEnergyStorage) CompoundTag(net.minecraft.nbt.CompoundTag)

Aggregations

CompoundTag (net.minecraft.nbt.CompoundTag)2 EnergyStorage (net.minecraftforge.energy.EnergyStorage)2 IEnergyStorage (net.minecraftforge.energy.IEnergyStorage)2 IWorkHandler (net.roguelogix.biggerreactors.api.IWorkHandler)2 WorkHandler (net.roguelogix.biggerreactors.api.WorkHandler)2 Objects (java.util.Objects)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 BlockPos (net.minecraft.core.BlockPos)1 Direction (net.minecraft.core.Direction)1 Component (net.minecraft.network.chat.Component)1 TextComponent (net.minecraft.network.chat.TextComponent)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 ServerPlayer (net.minecraft.server.level.ServerPlayer)1 net.minecraft.world (net.minecraft.world)1 Inventory (net.minecraft.world.entity.player.Inventory)1 Player (net.minecraft.world.entity.player.Player)1 AbstractContainerMenu (net.minecraft.world.inventory.AbstractContainerMenu)1 ItemStack (net.minecraft.world.item.ItemStack)1 Items (net.minecraft.world.item.Items)1