mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 11:53:29 +01:00
resolved all todos (untested though oof)
This commit is contained in:
parent
1d9c22cb0a
commit
ae5128971c
9 changed files with 130 additions and 94 deletions
|
@ -78,6 +78,6 @@ public class ItemTerminalWidget extends AbstractWidget {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateNarration(NarrationElementOutput output) {
|
public void updateNarration(NarrationElementOutput output) {
|
||||||
// TODO narration
|
this.defaultButtonNarrationText(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.block.*;
|
import net.minecraft.world.level.block.*;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.StateDefinition;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
|
@ -297,6 +299,12 @@ public class PipeBlock extends BaseEntityBlock {
|
||||||
return RenderShape.MODEL;
|
return RenderShape.MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
@Override
|
||||||
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||||
|
return createTickerHelper(type, Registry.pipeBlockEntity, PipeBlockEntity::tick);
|
||||||
|
}
|
||||||
|
|
||||||
public static void dropItems(Level worldIn, BlockPos pos, Player player) {
|
public static void dropItems(Level worldIn, BlockPos pos, Player player) {
|
||||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, worldIn, pos);
|
var tile = Utility.getBlockEntity(PipeBlockEntity.class, worldIn, pos);
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -143,52 +144,6 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
this.load(pkt.getTag());
|
this.load(pkt.getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO tick
|
|
||||||
/* @Override
|
|
||||||
public void tick() {
|
|
||||||
// invalidate our pressurizer reference if it was removed
|
|
||||||
if (this.pressurizer != null && this.pressurizer.isRemoved())
|
|
||||||
this.pressurizer = null;
|
|
||||||
|
|
||||||
if (!this.world.isAreaLoaded(this.pos, 1))
|
|
||||||
return;
|
|
||||||
IProfiler profiler = this.world.getProfiler();
|
|
||||||
|
|
||||||
if (!this.world.isRemote) {
|
|
||||||
// drop modules here to give a bit of time for blocks to update (iron -> gold chest etc.)
|
|
||||||
if (this.moduleDropCheck > 0) {
|
|
||||||
this.moduleDropCheck--;
|
|
||||||
if (this.moduleDropCheck <= 0 && !this.canHaveModules())
|
|
||||||
Utility.dropInventory(this, this.modules);
|
|
||||||
}
|
|
||||||
|
|
||||||
profiler.startSection("ticking_modules");
|
|
||||||
var prio = 0;
|
|
||||||
var modules = this.streamModules().iterator();
|
|
||||||
while (modules.hasNext()) {
|
|
||||||
var module = modules.next();
|
|
||||||
module.getRight().tick(module.getLeft(), this);
|
|
||||||
prio += module.getRight().getPriority(module.getLeft(), this);
|
|
||||||
}
|
|
||||||
if (prio != this.priority) {
|
|
||||||
this.priority = prio;
|
|
||||||
// clear the cache so that it's reevaluated based on priority
|
|
||||||
PipeNetwork.get(this.world).clearDestinationCache(this.pos);
|
|
||||||
}
|
|
||||||
profiler.endSection();
|
|
||||||
}
|
|
||||||
|
|
||||||
profiler.startSection("ticking_items");
|
|
||||||
var items = this.getItems();
|
|
||||||
for (var i = items.size() - 1; i >= 0; i--)
|
|
||||||
items.get(i).updateInPipe(this);
|
|
||||||
if (items.size() != this.lastItemAmount) {
|
|
||||||
this.lastItemAmount = items.size();
|
|
||||||
this.world.updateComparatorOutputLevel(this.pos, this.getBlockState().getBlock());
|
|
||||||
}
|
|
||||||
profiler.endSection();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public List<IPipeItem> getItems() {
|
public List<IPipeItem> getItems() {
|
||||||
if (this.items == null)
|
if (this.items == null)
|
||||||
this.items = PipeNetwork.get(this.level).getItemsInPipe(this.worldPosition);
|
this.items = PipeNetwork.get(this.level).getItemsInPipe(this.worldPosition);
|
||||||
|
@ -453,4 +408,49 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
return ConnectionType.BLOCKED;
|
return ConnectionType.BLOCKED;
|
||||||
return ConnectionType.CONNECTED;
|
return ConnectionType.CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void tick(Level level, BlockPos pos, BlockState state, PipeBlockEntity pipe) {
|
||||||
|
// invalidate our pressurizer reference if it was removed
|
||||||
|
if (pipe.pressurizer != null && pipe.pressurizer.isRemoved())
|
||||||
|
pipe.pressurizer = null;
|
||||||
|
|
||||||
|
if (!pipe.level.isAreaLoaded(pipe.worldPosition, 1))
|
||||||
|
return;
|
||||||
|
var profiler = pipe.level.getProfiler();
|
||||||
|
|
||||||
|
if (!pipe.level.isClientSide) {
|
||||||
|
// drop modules here to give a bit of time for blocks to update (iron -> gold chest etc.)
|
||||||
|
if (pipe.moduleDropCheck > 0) {
|
||||||
|
pipe.moduleDropCheck--;
|
||||||
|
if (pipe.moduleDropCheck <= 0 && !pipe.canHaveModules())
|
||||||
|
Utility.dropInventory(pipe, pipe.modules);
|
||||||
|
}
|
||||||
|
|
||||||
|
profiler.push("ticking_modules");
|
||||||
|
var prio = 0;
|
||||||
|
var modules = pipe.streamModules().iterator();
|
||||||
|
while (modules.hasNext()) {
|
||||||
|
var module = modules.next();
|
||||||
|
module.getRight().tick(module.getLeft(), pipe);
|
||||||
|
prio += module.getRight().getPriority(module.getLeft(), pipe);
|
||||||
|
}
|
||||||
|
if (prio != pipe.priority) {
|
||||||
|
pipe.priority = prio;
|
||||||
|
// clear the cache so that it's reevaluated based on priority
|
||||||
|
PipeNetwork.get(pipe.level).clearDestinationCache(pipe.worldPosition);
|
||||||
|
}
|
||||||
|
profiler.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
profiler.push("ticking_items");
|
||||||
|
var items = pipe.getItems();
|
||||||
|
for (var i = items.size() - 1; i >= 0; i--)
|
||||||
|
items.get(i).updateInPipe(pipe);
|
||||||
|
if (items.size() != pipe.lastItemAmount) {
|
||||||
|
pipe.lastItemAmount = items.size();
|
||||||
|
pipe.level.updateNeighbourForOutputSignal(pipe.worldPosition, pipe.getBlockState().getBlock());
|
||||||
|
}
|
||||||
|
profiler.pop();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package de.ellpeck.prettypipes.pipe;
|
package de.ellpeck.prettypipes.pipe;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraftforge.client.ForgeHooksClient;
|
import net.minecraftforge.client.ForgeHooksClient;
|
||||||
import net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer;
|
import net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer;
|
||||||
|
|
||||||
|
@ -33,13 +35,13 @@ public class PipeRenderer implements BlockEntityRenderer<PipeBlockEntity> {
|
||||||
if (tile.cover != null) {
|
if (tile.cover != null) {
|
||||||
matrixStack.pushPose();
|
matrixStack.pushPose();
|
||||||
ForgeBlockModelRenderer.enableCaching();
|
ForgeBlockModelRenderer.enableCaching();
|
||||||
// TODO figure out how to render covers, maybe finally use baked models bleh
|
var renderer = Minecraft.getInstance().getBlockRenderer();
|
||||||
/*for (RenderType layer : RenderType.chunkBufferLayers()) {
|
for (var layer : RenderType.chunkBufferLayers()) {
|
||||||
if (!RenderTypeLookup.canRenderInLayer(tile.cover, layer))
|
if (!ItemBlockRenderTypes.canRenderInLayer(tile.cover, layer))
|
||||||
continue;
|
continue;
|
||||||
ForgeHooksClient.setRenderType(layer);
|
ForgeHooksClient.setRenderType(layer);
|
||||||
Minecraft.getInstance().getBlockRenderer().renderBatched(tile.cover,tile.getBlockPos(),null, matrixStack,null, light, overlay, EmptyModelData.INSTANCE);
|
renderer.getModelRenderer().tesselateBlock(tile.getLevel(), renderer.getBlockModel(tile.cover), tile.cover, tile.getBlockPos(), matrixStack, source.getBuffer(layer), true, new Random(), tile.cover.getSeed(tile.getBlockPos()), overlay);
|
||||||
}*/
|
}
|
||||||
ForgeHooksClient.setRenderType(null);
|
ForgeHooksClient.setRenderType(null);
|
||||||
ForgeBlockModelRenderer.clearCache();
|
ForgeBlockModelRenderer.clearCache();
|
||||||
matrixStack.popPose();
|
matrixStack.popPose();
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package de.ellpeck.prettypipes.pressurizer;
|
package de.ellpeck.prettypipes.pressurizer;
|
||||||
|
|
||||||
|
import de.ellpeck.prettypipes.Registry;
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
|
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
@ -15,6 +17,8 @@ import net.minecraft.world.level.block.BaseEntityBlock;
|
||||||
import net.minecraft.world.level.block.RenderShape;
|
import net.minecraft.world.level.block.RenderShape;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.material.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
|
@ -55,4 +59,10 @@ public class PressurizerBlock extends BaseEntityBlock {
|
||||||
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||||
Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
|
Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
@Override
|
||||||
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||||
|
return level.isClientSide ? null : createTickerHelper(type, Registry.pressurizerBlockEntity, PressurizerBlockEntity::tick);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package de.ellpeck.prettypipes.pressurizer;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.Registry;
|
import de.ellpeck.prettypipes.Registry;
|
||||||
|
import de.ellpeck.prettypipes.Utility;
|
||||||
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
||||||
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -16,6 +18,7 @@ import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
@ -110,36 +113,32 @@ public class PressurizerBlockEntity extends BlockEntity implements MenuProvider,
|
||||||
this.lazyThis.invalidate();
|
this.lazyThis.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO tick
|
@Override
|
||||||
/*@Override
|
public ConnectionType getConnectionType(BlockPos pipePos, Direction direction) {
|
||||||
public void tick() {
|
return ConnectionType.CONNECTED;
|
||||||
if (this.world.isRemote)
|
}
|
||||||
return;
|
|
||||||
|
public static void tick(Level level, BlockPos pos, BlockState state, PressurizerBlockEntity pressurizer) {
|
||||||
// notify pipes in network about us
|
// notify pipes in network about us
|
||||||
if (this.world.getGameTime() % 10 == 0) {
|
if (pressurizer.level.getGameTime() % 10 == 0) {
|
||||||
PipeNetwork network = PipeNetwork.get(this.world);
|
var network = PipeNetwork.get(pressurizer.level);
|
||||||
for (Direction dir : Direction.values()) {
|
for (var dir : Direction.values()) {
|
||||||
BlockPos offset = this.pos.offset(dir);
|
var offset = pressurizer.worldPosition.relative(dir);
|
||||||
for (BlockPos node : network.getOrderedNetworkNodes(offset)) {
|
for (var node : network.getOrderedNetworkNodes(offset)) {
|
||||||
if (!this.world.isBlockLoaded(node))
|
if (!pressurizer.level.isLoaded(node))
|
||||||
continue;
|
continue;
|
||||||
PipeBlockEntity pipe = network.getPipe(node);
|
var pipe = network.getPipe(node);
|
||||||
if (pipe != null)
|
if (pipe != null)
|
||||||
pipe.pressurizer = this;
|
pipe.pressurizer = pressurizer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send energy update
|
// send energy update
|
||||||
if (this.lastEnergy != this.storage.getEnergyStored() && this.world.getGameTime() % 10 == 0) {
|
if (pressurizer.lastEnergy != pressurizer.storage.getEnergyStored() && pressurizer.level.getGameTime() % 10 == 0) {
|
||||||
this.lastEnergy = this.storage.getEnergyStored();
|
pressurizer.lastEnergy = pressurizer.storage.getEnergyStored();
|
||||||
Utility.sendBlockEntityToClients(this);
|
Utility.sendBlockEntityToClients(pressurizer);
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConnectionType getConnectionType(BlockPos pipePos, Direction direction) {
|
|
||||||
return ConnectionType.CONNECTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ModifiableEnergyStorage extends EnergyStorage {
|
private static class ModifiableEnergyStorage extends EnergyStorage {
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package de.ellpeck.prettypipes.terminal;
|
package de.ellpeck.prettypipes.terminal;
|
||||||
|
|
||||||
|
import de.ellpeck.prettypipes.Registry;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
public class CraftingTerminalBlock extends ItemTerminalBlock {
|
public class CraftingTerminalBlock extends ItemTerminalBlock {
|
||||||
|
@ -11,4 +15,9 @@ public class CraftingTerminalBlock extends ItemTerminalBlock {
|
||||||
return new CraftingTerminalBlockEntity(pos, state);
|
return new CraftingTerminalBlockEntity(pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
@Override
|
||||||
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||||
|
return createTickerHelper(type, Registry.craftingTerminalBlockEntity, ItemTerminalBlockEntity::tick);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package de.ellpeck.prettypipes.terminal;
|
package de.ellpeck.prettypipes.terminal;
|
||||||
|
|
||||||
|
import de.ellpeck.prettypipes.Registry;
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -17,6 +18,8 @@ import net.minecraft.world.level.block.BaseEntityBlock;
|
||||||
import net.minecraft.world.level.block.RenderShape;
|
import net.minecraft.world.level.block.RenderShape;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.material.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
@ -75,4 +78,11 @@ public class ItemTerminalBlock extends BaseEntityBlock {
|
||||||
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||||
Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
|
Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
@Override
|
||||||
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||||
|
return createTickerHelper(type, Registry.itemTerminalBlockEntity, ItemTerminalBlockEntity::tick);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,44 +64,42 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
|
||||||
this(Registry.itemTerminalBlockEntity, pos, state);
|
this(Registry.itemTerminalBlockEntity, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO tick
|
public static void tick(Level level, BlockPos pos, BlockState state, ItemTerminalBlockEntity terminal) {
|
||||||
/* @Override
|
if (terminal.level.isClientSide)
|
||||||
public void tick() {
|
|
||||||
if (this.level.isRemote)
|
|
||||||
return;
|
return;
|
||||||
PipeNetwork network = PipeNetwork.get(this.level);
|
var network = PipeNetwork.get(terminal.level);
|
||||||
PipeBlockEntity pipe = this.getConnectedPipe();
|
var pipe = terminal.getConnectedPipe();
|
||||||
if (pipe == null)
|
if (pipe == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean update = false;
|
var update = false;
|
||||||
int interval = pipe.pressurizer != null ? 2 : 10;
|
var interval = pipe.pressurizer != null ? 2 : 10;
|
||||||
if (this.level.getGameTime() % interval == 0) {
|
if (terminal.level.getGameTime() % interval == 0) {
|
||||||
for (int i = 6; i < 12; i++) {
|
for (var i = 6; i < 12; i++) {
|
||||||
ItemStack extracted = this.items.extractItem(i, Integer.MAX_VALUE, true);
|
var extracted = terminal.items.extractItem(i, Integer.MAX_VALUE, true);
|
||||||
if (extracted.isEmpty())
|
if (extracted.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
ItemStack remain = network.routeItem(pipe.getPos(), this.pos, extracted, true);
|
var remain = network.routeItem(pipe.getBlockPos(), terminal.getBlockPos(), extracted, true);
|
||||||
if (remain.getCount() == extracted.getCount())
|
if (remain.getCount() == extracted.getCount())
|
||||||
continue;
|
continue;
|
||||||
this.items.extractItem(i, extracted.getCount() - remain.getCount(), false);
|
terminal.items.extractItem(i, extracted.getCount() - remain.getCount(), false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.existingRequests.isEmpty()) {
|
if (!terminal.existingRequests.isEmpty()) {
|
||||||
NetworkLock request = this.existingRequests.remove();
|
var request = terminal.existingRequests.remove();
|
||||||
network.resolveNetworkLock(request);
|
network.resolveNetworkLock(request);
|
||||||
network.requestExistingItem(request.location, pipe.getPos(), this.pos, request, request.stack, ItemEquality.NBT);
|
network.requestExistingItem(request.location, pipe.getBlockPos(), terminal.getBlockPos(), request, request.stack, ItemEquality.NBT);
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.level.getGameTime() % 100 == 0 || update) {
|
if (terminal.level.getGameTime() % 100 == 0 || update) {
|
||||||
PlayerEntity[] lookingPlayers = this.getLookingPlayers();
|
var lookingPlayers = terminal.getLookingPlayers();
|
||||||
if (lookingPlayers.length > 0)
|
if (lookingPlayers.length > 0)
|
||||||
this.updateItems(lookingPlayers);
|
terminal.updateItems(lookingPlayers);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemoved() {
|
public void setRemoved() {
|
||||||
|
|
Loading…
Reference in a new issue