TheOnly8Z Posted April 8, 2020 Share Posted April 8, 2020 (edited) Hello all, I'm trying to make a block that implements ITickableTileEntity and does something every minute, but tick() doesn't seem to be running at all. I'm following McJty's tutorial series (for 1.14). The forge documentation mentions using net.minecraft.util.ITickable, but the IDE highlighting seems to suggest this doesn't exist. // snip imports public class BaitStationTile extends TileEntity implements ITickableTileEntity, INamedContainerProvider { private LazyOptional<IItemHandler> handler = LazyOptional.of(this::createHandler); private int counter; public BaitStationTile() { super(BAIT_STATION_BLOCK_TILE.get()); } @Override public void tick() { // this line is not running LogManager.getLogger().debug("ticking Bait Station, remote: " + world.isRemote + "handler: " + handler.toString()); if (world.isRemote) { return; } handler.ifPresent(h -> { ItemStack stack = h.getStackInSlot(0); // snip functionality }); } private IItemHandler createHandler() { return new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { markDirty(); } @Override public boolean isItemValid(int slot, @Nonnull ItemStack stack) { return BaitStation.baitEntities.exists(stack.getItem()); } @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { // TODO fancy logic or something if (!BaitStation.baitEntities.exists(stack.getItem())) { return stack; } return super.insertItem(slot, stack, simulate); } }; } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return handler.cast(); } return super.getCapability(cap, side); } @Override public ITextComponent getDisplayName() { return new StringTextComponent(getType().getRegistryName().getPath()); } @Nullable @Override public Container createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new BaitStationContainer(i, world, pos, playerInventory, playerEntity); } } Edited April 8, 2020 by TheOnly8Z resolved Quote Link to comment Share on other sites More sharing options...
Alpvax Posted April 8, 2020 Share Posted April 8, 2020 Have you checked that your TileEntity is actually being registered and created? Quote Link to comment Share on other sites More sharing options...
TheOnly8Z Posted April 8, 2020 Author Share Posted April 8, 2020 (edited) 25 minutes ago, Alpvax said: Have you checked that your TileEntity is actually being registered and created? I have these lines regarding the TileEntity in other classes: // In a registry class private static final DeferredRegister<TileEntityType<?>> TILES = new DeferredRegister<>(ForgeRegistries.TILE_ENTITIES, MOD_ID); public static final RegistryObject<TileEntityType<BaitStationTile>> BAIT_STATION_BLOCK_TILE = TILES.register("bait_station", () -> TileEntityType.Builder.create(BaitStationTile::new, BAIT_STATION_BLOCK.get()).build(null)); // In the block class @Override public boolean hasTileEntity(BlockState state) { return true; } @Nullable @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new BaitStationTile(); } EDIT: I noticed that the item I place in the container isn't saved - when I quit and rejoin the item disappears. Edited April 8, 2020 by TheOnly8Z Quote Link to comment Share on other sites More sharing options...
TheOnly8Z Posted April 8, 2020 Author Share Posted April 8, 2020 Okay, I've been fooled thoroughly. LogManager.getLogger().debug() didn't actually print anything to the game output (for some reason). Changing it to info() worked. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.