Jump to content

Recommended Posts

Posted (edited)

Hi,

 

I am trying to get my mod to run on a dedicated server. The mod works perfectly in SinglePlayer, but when i try to run a dedicated server I get this crash:

 

[m[1;31m[15:49:01] [modloading-worker-3/FATAL] [ne.mi.fm.lo.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/renderer/texture/ITickable for invalid dist DEDICATED_SERVER
[m[1;31m[15:49:02] [modloading-worker-3/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Failed to register automatic subscribers. ModID: dimensionalpocketsii, class com.zeher.dimpockets.DimensionalPockets
java.lang.ExceptionInInitializerError: null
	at java.lang.Class.forName0(Native Method) ~[?:1.8.0_251] {}
	at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_251] {}
	at net.minecraftforge.fml.AutomaticEventSubscriber.lambda$inject$3(AutomaticEventSubscriber.java:70) ~[?:?] {re:classloading}
	at java.util.ArrayList.forEach(Unknown Source) ~[?:1.8.0_251] {}
	at net.minecraftforge.fml.AutomaticEventSubscriber.inject(AutomaticEventSubscriber.java:57) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:141) ~[?:28.2] {re:classloading}
	at java.util.function.Consumer.lambda$andThen$0(Unknown Source) ~[?:1.8.0_251] {}
	at java.util.function.Consumer.lambda$andThen$0(Unknown Source) ~[?:1.8.0_251] {}
	at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.ModList.lambda$null$10(ModList.java:134) ~[?:?] {re:classloading}
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source) [?:1.8.0_251] {}
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) [?:1.8.0_251] {}
	at java.util.stream.AbstractPipeline.copyInto(Unknown Source) [?:1.8.0_251] {}
	at java.util.stream.ForEachOps$ForEachTask.compute(Unknown Source) [?:1.8.0_251] {}
	at java.util.concurrent.CountedCompleter.exec(Unknown Source) [?:1.8.0_251] {}
	at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) [?:1.8.0_251] {}
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) [?:1.8.0_251] {}
	at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) [?:1.8.0_251] {}
	at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) [?:1.8.0_251] {}
Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/texture/ITickable for invalid dist DEDICATED_SERVER
	at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClass(RuntimeDistCleaner.java:71) ~[forge-1.14.4-28.2.23_mapped_snapshot_20190719-1.14.3-launcher.jar:28.2] {}
	at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClass(ILaunchPluginService.java:102) ~[modlauncher-4.1.0.jar:4.1.0+62+5bfa59b] {}
	at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:80) ~[modlauncher-4.1.0.jar:?] {}
	at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:115) ~[modlauncher-4.1.0.jar:?] {}
	at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:241) ~[modlauncher-4.1.0.jar:?] {}
	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:128) ~[modlauncher-4.1.0.jar:?] {}
	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) ~[modlauncher-4.1.0.jar:?] {}
	at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_251] {}
	at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_251] {}
	at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_251] {}
	at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_251] {}
	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:129) ~[modlauncher-4.1.0.jar:?] {}
	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) ~[modlauncher-4.1.0.jar:?] {}
	at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_251] {}
	at com.zeher.dimpockets.core.manager.BusSubscriberMod.<clinit>(BusSubscriberMod.java:45) ~[?:?] {re:classloading}
	... 19 more
[m[36m[15:49:02] [modloading-worker-0/DEBUG] [ne.mi.fm.co.ConfigTracker/CONFIG]: Config file forge-client.toml for forge tracking
[m[36m[15:49:02] [modloading-worker-0/DEBUG] [ne.mi.fm.co.ConfigTracker/CONFIG]: Config file forge-server.toml for forge tracking
[m[36m[15:49:02] [modloading-worker-0/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Loaded mod instance forge of type net.minecraftforge.common.ForgeMod
[m[36m[15:49:02] [modloading-worker-0/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Injecting Automatic event subscribers for forge
[m[36m[15:49:02] [modloading-worker-0/DEBUG] [ne.mi.fm.AutomaticEventSubscriber/LOADING]: Attempting to inject @EventBusSubscriber classes into the eventbus for forge
[m[36m[15:49:02] [modloading-worker-0/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Completed Automatic event subscribers for forge
[m[1;31m[15:49:02] [Server thread/FATAL] [ne.mi.fm.ModLoader/LOADING]: Failed to complete lifecycle event CONSTRUCT, 1 errors found
[m[1;31m[15:49:02] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [
	Dimensional Pockets II (dimensionalpocketsii) has failed to load correctly
§7null
]
	at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:201) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:183) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.server.ServerModLoader.begin(ServerModLoader.java:45) ~[?:?] {re:classloading}
	at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:121) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:600) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_251] {}
[m[1;31m[15:49:02] [Server thread/ERROR] [minecraft/CrashReport]: Could not save crash report to .\crash-reports\crash-2020-07-29_15.49.02-server.txt
java.lang.NoSuchMethodError: net.minecraft.crash.CrashReport.func_71505_b()Ljava/lang/Throwable;
	at me.xfl03.morecrashinfo.handler.CrashHandler.addCrashReportHeader(CrashHandler.java:31) ~[?:1.0.4] {re:classloading}
	at net.minecraftforge.fml.CrashReportExtender.addCrashReportHeader(CrashReportExtender.java) ~[?:?] {re:classloading,xf:fml:morecrashinfo:CrashReportExtenderTransformer}
	at net.minecraft.crash.CrashReport.getCompleteReport(CrashReport.java:131) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.crash.CrashReport.saveToFile(CrashReport.java:171) [?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:652) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_251] {}
[m[1;31m[15:49:02] [Server thread/ERROR] [minecraft/MinecraftServer]: We were unable to save this crash report to disk.
[m[32m[15:49:02] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[m[32m[15:49:02] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds
[m[1;31m[15:49:02] [Server thread/ERROR] [minecraft/MinecraftServer]: Exception stopping the server
java.lang.RuntimeException: The server has failed to initialize correctly due to mod loading errors. Examine the crash report for more details.
	at net.minecraftforge.common.DimensionManager.getWorld(DimensionManager.java:182) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.getWorld(MinecraftServer.java:981) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:523) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:555) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.dedicated.DedicatedServer.stopServer(DedicatedServer.java:544) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:663) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_251] {}
[m

 

The crash is pointing to where i have registered the block:

 

public static final Block BLOCK_POCKET = new BlockPocket(Properties.create(Material.IRON).hardnessAndResistance(-1).harvestLevel(4).harvestTool(ToolType.PICKAXE)); 
	
@SubscribeEvent
public static void onBlockRegistry(final RegistryEvent.Register<Block> event) {
	event.getRegistry().registerAll(
    setupString("block_dimensional_ore", BLOCK_DIMENSIONAL_ORE),
    setupString("block_dimensional", BLOCK_DIMENSIONAL),
    setupString("block_dimensional_metal", BLOCK_DIMENSIONAL_METAL),
			
    setupString("block_pocket", BLOCK_POCKET),
    setupString("block_dimensional_core", BLOCK_DIMENSIONAL_CORE),
			
    setupString("block_dimensional_pocket_wall", BLOCK_DIMENSIONAL_POCKET_WALL),
	setupString("block_dimensional_pocket_wall_edge", BLOCK_DIMENSIONAL_POCKET_WALL_EDGE));
		
    LOGGER.info("[onBlockRegistry] Blocks Registered...", BusSubscriberMod.class);
}
      
public static <T extends IForgeRegistryEntry<T>> T setupString(final String name, final T entry) {
	return setupLow(entry, new ResourceLocation(DimensionalPockets.MOD_ID, name));
}

 

Here is my TileEntity class:

package com.zeher.dimpockets.pocket.core.tileentity;

import com.zeher.dimpockets.core.manager.ModDimensionManager;
import com.zeher.dimpockets.core.manager.BusSubscriberMod;
import com.zeher.dimpockets.core.manager.SoundHandler;
import com.zeher.dimpockets.core.manager.TileEntityManager;
import com.zeher.dimpockets.core.util.DimUtils;
import com.zeher.dimpockets.pocket.core.Pocket;
import com.zeher.dimpockets.pocket.core.manager.PocketRegistryManager;
import com.zeher.zeherlib.api.client.util.TextHelper;
import com.zeher.zeherlib.api.compat.client.interfaces.IClientUpdatedTile;
import com.zeher.zeherlib.api.compat.core.interfaces.EnumSideState;
import com.zeher.zeherlib.api.compat.core.interfaces.ISidedTile;
import com.zeher.zeherlib.api.core.interfaces.block.IBlockInteract;
import com.zeher.zeherlib.api.core.interfaces.block.IBlockNotifier;
import com.zeher.zeherlib.mod.util.ModUtil;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.renderer.texture.ITickable;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.ItemStackHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class TilePocket extends TileBase implements IBlockNotifier, IBlockInteract, ITickable, ISidedInventory, IInventory, ISidedTile, /**IEnergyReceiver, IEnergyProvider,*/ IClientUpdatedTile.Storage {
	
	public TilePocket() {
		super(TileEntityManager.POCKET);
	}

	private static final String TAG_CUSTOM_DP_NAME = "customDPName";
	private String customName;
	
	public EnumSideState[] SIDE_STATE_ARRAY = EnumSideState.getStandardArray();

	private NonNullList<ItemStack> INVENTORY_STACKS = NonNullList.<ItemStack>withSize(17, ItemStack.EMPTY);
	
	@OnlyIn(Dist.CLIENT)
	private Pocket pocket;

	@Override
	@OnlyIn(Dist.CLIENT)
	public void tick() { 
		for (int i = 0 ; i < 9; i++) {
			if (this.getStackInSlot(i) != this.getPocket().items.get(i)) {
				ItemStack pocket_stack = this.getPocket().items.get(i);
				ItemStack copy = pocket_stack.copy();
				if (!this.world.isRemote) {
					this.INVENTORY_STACKS.set(i, copy);
				}
			}
		}
	}

	public ItemStack generateItemStackOnRemoval(BlockPos pos) {
		ItemStack itemStack = new ItemStack(BusSubscriberMod.BLOCK_POCKET);

		if (!itemStack.hasTag()) {
			itemStack.setTag(new CompoundNBT());
		}

		BlockPos chunkSet = this.getPocket().getChunkPos();
		
		CompoundNBT compound = new CompoundNBT();
		
		//Saves the chunk data to NBT
		CompoundNBT chunk_tag = new CompoundNBT();
		chunk_tag.putInt("X", chunkSet.getX());
		chunk_tag.putInt("Y", chunkSet.getY());
		chunk_tag.putInt("Z", chunkSet.getZ());

		compound.put("chunk_set", chunk_tag);

		String creatorLore = null;
		Pocket pocket = getPocket();
		
		if (pocket != null && pocket.getCreator() != null) {
			creatorLore = TextHelper.LIGHT_BLUE + TextHelper.BOLD + I18n.format("pocket.desc.creator.name") + TextHelper.PURPLE + TextHelper.BOLD + " [" + pocket.getCreator() + "]";
		}
		
		//Saves the side data to NBT
		if (this instanceof ISidedTile) {
			CompoundNBT side_tag = new CompoundNBT();
			
			for (Direction c : Direction.values()) {
				side_tag.putInt("index_" + c.getIndex(), this.getSideArray()[c.getIndex()].getIndex());
			}
			
			compound.put("sides", side_tag);
		}
		
		/**
		if (this.getEnergyStored(Direction.DOWN) > 0) {
			compound.putInt("energy", this.getEnergyStored(Direction.DOWN));
		}
		*/
		
		itemStack.getTag().put("nbt_data", compound);
		
		BlockPos blockSet = new BlockPos(chunkSet.getX() << 4, chunkSet.getY() << 4, chunkSet.getZ() << 4);

		itemStack = DimUtils.generateItem(itemStack, customName, false, TextHelper.LIGHT_GRAY + TextHelper.BOLD
				+ "Pocket: [" + blockSet.getX() + " | " + blockSet.getY() + " | " + blockSet.getZ() + "]", creatorLore);
		return itemStack;
	}

	public ItemStack generateItemStackWithNBT(BlockPos pos, int x, int y, int z) {
		ItemStack item_stack = new ItemStack(BusSubscriberMod.BLOCK_POCKET);

		if (!item_stack.hasTag()) {
			item_stack.setTag(new CompoundNBT());
		}

		CompoundNBT compound = new CompoundNBT();
		
		CompoundNBT chunk_tag = new CompoundNBT();
		chunk_tag.putInt("X", x);
		chunk_tag.putInt("Y", y);
		chunk_tag.putInt("Z", z);

		compound.put("chunk_set", chunk_tag);
		
		item_stack.getTag().put("nbt_data", compound);

		String creatorLore = null;
		Pocket pocket = getPocket();
		if (pocket != null && pocket.getCreator() != null) {
			creatorLore = "Creator: [" + pocket.getCreator() + "]";
		}

		item_stack = DimUtils.generateItem(item_stack, customName, false,
				"Pocket: [" + (x << 4) + "," + (y << 4) + "," + (z << 4) + "]", creatorLore);

		return item_stack;
	}

	@Override
	public Pocket getPocket() {
		return PocketRegistryManager.getOrCreatePocket(this.world, this.getPos());
	}
	
	@Override
	public CompoundNBT write(CompoundNBT compound) {
		if (this.SIDE_STATE_ARRAY != null) {
			CompoundNBT sides_tag = new CompoundNBT();
			
			for (Direction c : Direction.values()) {
				int i = this.getSide(c).getIndex();
				
				sides_tag.putInt(c.getName(), i);
			}
			compound.put("sides", sides_tag);
		}
		
		if (customName != null) {
			compound.putString(TAG_CUSTOM_DP_NAME, customName);
		}
		
		return compound;
	}

	@Override
	public void read(CompoundNBT compound) {
		super.read(compound);
		
		if (compound.contains("sides")) {
			CompoundNBT sides_tag = compound.getCompound("sides");
			
			for (Direction c : Direction.values()) {
				this.setSide(c, EnumSideState.getStateFromIndex(sides_tag.getInt(c.getName())));
			}
		}
		
		String tempString = compound.getString(TAG_CUSTOM_DP_NAME);
		if (!tempString.isEmpty()) {
			customName = tempString;
		}
	}

	private void shiftIntoPocket(PlayerEntity player, BlockPos pos_) {
		this.getPocket().addPosToBlockMap(this.getPos());
		this.getPocket().shiftTo(player);
	}

	/**
	 * Check whether the pocket is locked.
	 * @return boolean of the lock state
	 */
	public boolean getLockState() {
		return this.getPocket().getLockState();
	}
	
	/**
	 * Set the lock state of the pocket.
	 */
	public void setLockState(boolean change) {
		this.getPocket().setLockState(change);
		this.sendUpdates();
	}

	/**
	 * ISidedTile Begin--
	 */
	
	@Override 
	public EnumSideState getSide(Direction direction) {
		return SIDE_STATE_ARRAY[direction.getIndex()];
	}
	
	@Override
	public void setSide(Direction direction, EnumSideState side_state) {
		SIDE_STATE_ARRAY[direction.getIndex()] = side_state;
		
		this.sendUpdates();
	}
	
	@Override
	public EnumSideState[] getSideArray() {
		return this.SIDE_STATE_ARRAY;
	}

	@Override
	public void setSideArray(EnumSideState[] new_array) {
		SIDE_STATE_ARRAY = new_array;
		
		this.sendUpdates();
	}

	@Override
	public void cycleSide(Direction direction) {
		EnumSideState state = SIDE_STATE_ARRAY[direction.getIndex()];
		
		EnumSideState state2 = state.getNextState();
		
		SIDE_STATE_ARRAY[direction.getIndex()] = state2;
		
		this.sendUpdates();
	}

	@Override
	public boolean canConnect(Direction direction) {
		EnumSideState state = SIDE_STATE_ARRAY[direction.getIndex()];
		
		if (state.equals(EnumSideState.DISABLED)) {
			return false;
		}
		return true;
	}

	@Override
	public void sendUpdates() {
		//this.world.markBlockRangeForRenderUpdate(this.getPos(), this.getPos());
		this.world.notifyBlockUpdate(this.getPos(), world.getBlockState(this.getPos()), world.getBlockState(this.getPos()), 3);
		//this.world.scheduleBlockUpdate(this.getPos(), this.getBlockType(), 0, 0);		
		this.markDirty();
	}
	
	/**
	 * Set the data once it has been received. [NBT > TE]
	 */
	@Override
	public void handleUpdateTag(CompoundNBT tag) {
		System.out.println("READ TAG: index_1/up " + tag.getInt("index_1"));

		this.read(tag);
	}
	
	/**
	 * Retrieve the data to be stored. [TE > NBT]
	 */
	@Override
	public CompoundNBT getUpdateTag() {
		CompoundNBT tag = new CompoundNBT();
		
		System.out.println("WRITE TAG: index_1/up " + this.getSide(Direction.UP).getIndex());
		
		this.write(tag);
		
		return tag;
	}
	
	/**
	 * Actually sends the data to the server. [NBT > SER]
	 */
	@Override
	public SUpdateTileEntityPacket getUpdatePacket() {
		return new SUpdateTileEntityPacket(this.getPos(), 3, this.getUpdateTag());
	}
	
	/**
	 * Method is called once packet has been received by the client. [SER > CLT]
	 */
	@Override
	public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
		super.onDataPacket(net, pkt);
		CompoundNBT tag_ = pkt.getNbtCompound();
		
		this.handleUpdateTag(tag_);
		this.sendUpdates();
	}
	
	@Override
	public int getSizeInventory() {
		/**return this.INVENTORY_STACKS.size() + */ return this.INVENTORY_STACKS.size();
	}

	@Override
	public ItemStack getStackInSlot(int index) {
		return this.INVENTORY_STACKS.get(index);
	}

	@Override
	public ItemStack decrStackSize(int index, int count) {
		this.markDirty();
		return ItemStackHelper.getAndSplit(this.INVENTORY_STACKS, index, count);
	}

	@Override
	public ItemStack removeStackFromSlot(int index) {
		this.markDirty();
		return ItemStackHelper.getAndRemove(this.INVENTORY_STACKS, index);
	}
	
	@Override
	public void setInventorySlotContents(int index, ItemStack stack) {
		this.INVENTORY_STACKS.set(index, stack);
		if (stack.getCount() > this.getInventoryStackLimit()) {
			stack.setCount(this.getInventoryStackLimit());
		}
		
		this.getPocket().items.set(index, stack);
		
		this.markDirty();
	}

	@Override
	public int getInventoryStackLimit() {
		return 64;
	}

	@Override
	public boolean isUsableByPlayer(PlayerEntity player) {
		return true;
	}

	@Override
	public void openInventory(PlayerEntity player) { }

	@Override
	public void closeInventory(PlayerEntity player) { }

	@Override
	public boolean isItemValidForSlot(int index, ItemStack stack) {
		return true;
	}
	
	@Override
	public void clear() { }

	@Override
	public int[] getSlotsForFace(Direction side) {
		return new int[] { 0 };
	}

	@Override
	public boolean canInsertItem(int index, ItemStack itemStackIn, Direction direction) {
		return true;
	}

	@Override
	public boolean canExtractItem(int index, ItemStack stack, Direction direction) {
		return true;
	}

	@Override
	public boolean isEmpty() {
		for (ItemStack itemstack : this.INVENTORY_STACKS) {
			if (!itemstack.isEmpty()) {
				return false;
			}
		}
		return true;
	}
	
	@Override
	public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand handIn, BlockRayTraceResult hit) {
		if (playerIn.isSneaking() && playerIn.getHeldItem(Hand.MAIN_HAND).isEmpty()) {
			if (this.getPocket() != null) {
				Pocket pocket = this.getPocket();
				
				if (pocket.getCreator() == null) {
					pocket.setCreator(playerIn.getDisplayName().getString());
					//NetworkHandler.sendCreatorPacketToServer(playerIn.getName(), pos);
					this.markDirty();
				} else { 
					String creator = pocket.getCreator();
	
					String player_name = playerIn.getDisplayName().getString();
					
					this.markDirty();
					
					if (creator != null) {
						if (this.getLockState()) {
							if (player_name.equals(creator)) {
								playerIn.playSound(SoundHandler.GENERIC.PORTAL_IN, 1.0F, 1.0F);
								this.shiftIntoPocket(playerIn, pos);
							} else if (pocket.checkPlayerMap(player_name)) {
								playerIn.playSound(SoundHandler.GENERIC.PORTAL_IN, 1.0F, 1.0F);
								this.shiftIntoPocket(playerIn, pos);
							} else {
								StringTextComponent comp = new StringTextComponent(TextHelper.RED + TextHelper.BOLD + I18n.format("pocket.status.is_locked.name") + "[" + creator + "]");
								playerIn.sendMessage(comp);
							}
						} else {
							playerIn.playSound(SoundHandler.GENERIC.PORTAL_IN, 1.0F, 1.0F);
							this.shiftIntoPocket(playerIn, pos);
						}
					}
				}
			}
		} else if (!playerIn.isSneaking() && playerIn.getHeldItem(Hand.MAIN_HAND).isEmpty()) {
			String creator = this.getPocket().getCreator();
			String locked_comp;

			if (this.getLockState()) {
				locked_comp = TextHelper.RED + TextHelper.BOLD + I18n.format("pocket.status.locked.name");
			} else {
				locked_comp = TextHelper.GREEN + TextHelper.BOLD + I18n.format("pocket.status.unlocked.name");
			}

			if (!worldIn.isRemote) {
				StringTextComponent comp = new StringTextComponent(TextHelper.LIGHT_GRAY + TextHelper.BOLD + I18n.format("pocket.status.owner.name") + TextHelper.PURPLE + TextHelper.BOLD + " {" + creator + "} " + TextHelper.LIGHT_GRAY + TextHelper.BOLD + I18n.format("pocket.status.and.name") + locked_comp + ".");
				playerIn.sendMessage(comp);
				
				return false;
			}
		} else if ((ModUtil.isHoldingHammer(playerIn)) && (playerIn.isSneaking())) {
			playerIn.swingArm(Hand.MAIN_HAND);
			if (!(worldIn.isRemote)) {

				String creator = this.getPocket().getCreator();

				if (creator != null) {
					if (playerIn.getDisplayName().getString().equals(creator)) {
						if (this.getLockState()) {
							StringTextComponent comp = new StringTextComponent(TextHelper.RED + TextHelper.BOLD + I18n.format("pocket.status.remove_locked.name"));
							playerIn.sendMessage(comp);
						} else {
							//ChunkLoaderManagerRoom.removePocketFromChunkLoader(this.getPocket());
							//ChunkLoaderManagerBlock.removePocketBlockFromChunkLoader(this.getPos());
							DimUtils.spawnItemStack(this.generateItemStackOnRemoval(pos), world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0);
							
							world.setBlockState(pos, Blocks.AIR.getDefaultState());
						}
					} else {
						StringTextComponent comp = new StringTextComponent(TextHelper.RED + TextHelper.BOLD + I18n.format("pocket.status.remove_not.name"));
						playerIn.sendMessage(comp);
					}
				}

				return true;
			}
		} else if ((ModUtil.isHoldingHammer(playerIn)) && !(playerIn.isSneaking())) {
			playerIn.swingArm(Hand.MAIN_HAND);
			
			String creator = this.getPocket().getCreator();

			if (creator != null) {
				if (playerIn.getDisplayName().getString().equals(creator)) {
					this.cycleSide(hit.getFace());
					this.markDirty();
					
					if (!(worldIn.isRemote)) {
						StringTextComponent comp = new StringTextComponent(TextHelper.LIGHT_GRAY + TextHelper.BOLD + I18n.format("pocket.status.cycle_side.name") + this.getSide(hit.getFace()).getTextColour() + TextHelper.BOLD + " [" + this.getSide(hit.getFace()).getDisplayName() + "]");
						playerIn.sendMessage(comp);
					}
					return false;
				} else {
					if (!(worldIn.isRemote)) {
						StringTextComponent comp = new StringTextComponent(TextHelper.RED + TextHelper.BOLD + I18n.format("pocket.status.access_lock.name"));
						playerIn.sendMessage(comp);
					}
				}
			}
		}
		return false;
	}

	@Override
	public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn) {
		if (this.getPocket() != null) {
			if (ModUtil.isHoldingHammer(playerIn) && playerIn.isSneaking()) {
				if(this.getPocket().getCreator() != null) {
					String creator = this.getPocket().getCreator();
					
					if (creator != null) {
						if (playerIn.getDisplayName().getString().equals(creator)) {
							if (!(worldIn.isRemote)) {
								//FMLNetworkHandler.openGui(playerIn, DimensionalPockets.INSTANCE, 0, worldIn, pos.getX(), pos.getY(), pos.getZ());
							}
						} else {
							if (!(worldIn.isRemote)) {
								StringTextComponent comp = new StringTextComponent(TextHelper.RED + TextHelper.BOLD + I18n.format("pocket.status.access_set.name"));
								playerIn.sendMessage(comp);
							}
						}
					}
				} else {
					StringTextComponent comp = new StringTextComponent(TextHelper.RED + TextHelper.BOLD + I18n.format("pocket.status.creator_null.name"));
					playerIn.sendMessage(comp);
				}
			}
		} else {
			StringTextComponent comp = new StringTextComponent(TextHelper.RED + TextHelper.BOLD + I18n.format("pocket.status.null.name"));
			playerIn.sendMessage(comp);
		}
	}

	@Override
	public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { }

	@Override
	public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
		if (!worldIn.isRemote) {
			if (stack.hasTag() && placer.dimension != ModDimensionManager.POCKET_DIMENSION.getDimensionType()) {
				CompoundNBT compound = stack.getTag();
				
				if (compound.contains("nbt_data")) {
					CompoundNBT nbt_tag = compound.getCompound("nbt_data");
					
					int X = nbt_tag.getCompound("chunk_set").getInt("X");
					int Y = nbt_tag.getCompound("chunk_set").getInt("Y");
					int Z = nbt_tag.getCompound("chunk_set").getInt("Z");
	
					BlockPos chunkSet = new BlockPos(X, Y, Z);
					boolean success = PocketRegistryManager.getPocket(chunkSet) != null;
	
					if (!success) {
						throw new RuntimeException("YOU DESERVED THIS!");
					}
	
					PocketRegistryManager.updatePocket(chunkSet, placer.dimension, getPos());
	
					if (nbt_tag.contains("display")) {
						String tempString = nbt_tag.getCompound("display").getString("Name");
						if (!tempString.isEmpty()) {
							customName = tempString;
						}
					}
					
					CompoundNBT side_tag = nbt_tag.getCompound("sides");
					
					for(Direction c : Direction.values()) {
						this.setSide(c, EnumSideState.getStateFromIndex(side_tag.getInt("index_" + c.getIndex())));
					}
				}

				if (placer instanceof PlayerEntity) {
					ServerPlayerEntity player = (ServerPlayerEntity) placer;
					if (player.getHeldItemMainhand() == stack) {
						player.getHeldItemMainhand().setCount(0);
					}
				}

				Pocket pocket = this.getPocket();
				pocket.generatePocket(placer.getDisplayName().getString());
				//NetworkHandler.sendPocketSetCreator(placer.getName(), pos);
				//ChunkLoaderManagerRoom.addPocketToChunkLoader(pocket);
				//ChunkLoaderManagerBlock.addPocketBlockToChunkLoader(this.getPos(), placer.dimension.getId());

			} else if (stack.hasTag() && placer.dimension == ModDimensionManager.POCKET_DIMENSION.getDimensionType()) {
				if (placer.dimension == ModDimensionManager.POCKET_DIMENSION.getDimensionType()) {
					CompoundNBT stack_tag = stack.getTag();

					if (stack_tag.contains("nbt_data")) {
						CompoundNBT nbt_tag = stack_tag.getCompound("nbt_data");
						
						int X = nbt_tag.getCompound("chunk_set").getInt("X");
						int Y = nbt_tag.getCompound("chunk_set").getInt("Y");
						int Z = nbt_tag.getCompound("chunk_set").getInt("Z");
						
						BlockPos chunk_set = new BlockPos(X, Y, Z);
	
						Pocket test_pocket = PocketRegistryManager.getPocket(chunk_set);
	
						if (test_pocket != null) {
							if (test_pocket.equals(PocketRegistryManager.getPocket(new BlockPos(pos.getX() >> 4, pos.getY() >> 4, pos.getZ() >> 4)))) {
								if (!world.isRemote) {
									DimUtils.spawnItemStack(this.generateItemStackWithNBT(pos, X, Y, Z), world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0);
									
									world.setBlockState(pos, Blocks.AIR.getDefaultState());
								}
							} else {
								PocketRegistryManager.updatePocket(chunk_set, placer.dimension, getPos());
	
								if (nbt_tag.contains("display")) {
									CompoundNBT nbt = nbt_tag.getCompound("display");
									
									String tempString = nbt.getString("name");
									if (!tempString.isEmpty()) {
										customName = tempString;
									}
								}
	
								if (placer instanceof PlayerEntity) {
									ServerPlayerEntity player = (ServerPlayerEntity) placer;
									if (player.getHeldItemMainhand() == stack) {
										player.getHeldItemMainhand().setCount(0);
									}
								}
	
								Pocket pocket = this.getPocket();
								pocket.generatePocket(placer.getDisplayName().getString());
								//NetworkHandler.sendPocketSetCreator(placer.getName(), pos);
								//ChunkLoaderManagerRoom.addPocketToChunkLoader(pocket);
								//ChunkLoaderManagerBlock.addPocketBlockToChunkLoader(this.getPos(), placer.dimension.getId());
							}
						}
					}
				}
			}
		}
	}

	@Override
	public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { }

	@Override
	public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { }

	@Override
	public int getEnergyScaled(int scale) {
		return 0;
	}

	@Override
	public boolean hasEnergy() {
		return false;
	}
	
	public TileEntityType<?> getType() {
		return TileEntityManager.POCKET;
	}

}

 

And how i register My TileEntityType:

@SubscribeEvent
	public static void onTileEntityTypeRegistry(final RegistryEvent.Register<TileEntityType<?>> event) {
		setupString("pocket", TileEntityType.Builder.create(TilePocket::new, BLOCK_POCKET).build(null));
				
		LOGGER.info("[onTileEntityTypeRegistry] TileEntityTypes Registered...", BusSubscriberMod.class);
	}

 

I am confused as i cannot seem to determine the root cause of the crash.

 

Any help is much appreciated!

Edited by Zeher_Monkey
Posted (edited)
13 minutes ago, Zeher_Monkey said:

Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/texture/ITickable for invalid dist DEDICATED_SERVER

You have the wrong interface

13 minutes ago, Zeher_Monkey said:

ISidedInventory, IInventory

Do not use IInventory, use Capabilities.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
6 hours ago, Draco18s said:

You have the wrong interface

Do not use IInventory, use Capabilities.

 

1 hour ago, poopoodice said:

ITickableTileEntity not ITickable

 

Thank you both, It now runs on servers. I will take a look into using capabilities but I'm sure there is lots to learn. Is there anything particularly wrong or problematic with using IInventory? That is the way I have always done TileEntities with Containers, GUIs etc.

 

Are there any good tutorials you know of that explain capabilities and how to use them?

Edited by Zeher_Monkey
Posted

I am now getting a different error:

 

net.minecraft.crash.ReportedException: Ticking block entity
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:835) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:766) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:112) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:624) [?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_251] {}
Caused by: java.lang.NullPointerException
	at net.minecraft.world.World.func_217391_K(World.java:620) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:367) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:831) ~[?:?] {re:classloading,pl:accesstransformer:B}
	... 4 more

 

When I place or interact with the Block.

Posted

Tip:

21 minutes ago, Zeher_Monkey said:

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:835)

This is a class and row, exception occurred at, so you may analyze what exactly happened.

Please, share your project with GitHub, for precise help.

 

Read sign.

Everything said above may be absolutely wrong. No rights reserved.

Posted
6 minutes ago, Dzuchun said:

Tip:

This is a class and row, exception occurred at, so you may analyze what exactly happened.

Please, share your project with GitHub, for precise help.

 

Read sign.

 

Yes of course I know this allows me to analyse what happened. The row it points to is a blank line. In fact most of the exceptions occured on blank lines, at least that is what the console is telling me. 

 

I have uploaded the code to my GitHub here:

https://github.com/TheRealZeher/DimensionalPocketsII/tree/1.14.4-0.1.32
 

22 minutes ago, Dzuchun said:

Thank you, I will have a look through and move over to Capabilities.

Posted (edited)

I have scanned through and made some changes accordingly:

1. Copied similar Abstract Structure as FurnaceTileEntity

2. No longer using IInventory (Will use capabilities once I have wrapped my head around them, and the new Menu/Container/Gui system)

3. No longer using ISidedInventory

4. Removed

onDataPacket()

and

getUpdatePacket()

5. Stopped using BlockContainer using these methods instead:

@Override
public TileEntity createTileEntity(BlockState state, IBlockReader worldIn) {
	return new PocketTileEntity();
}

@Override
public boolean hasTileEntity(BlockState state) {
	return true;
}

 

But the game is still crashing. These are the methods and lines that the crash report shows:

net.minecraft.crash.ReportedException: Ticking block entity
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:835) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:766) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:112) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:624) [?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_251] {}
Caused by: java.lang.NullPointerException
	at net.minecraft.world.World.func_217391_K(World.java:620) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:367) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:831) ~[?:?] {re:classloading,pl:accesstransformer:B}
	... 4 more

 

First class (MinecraftServer#updateTimeLightAndEntities()  [line 835])

[Removed]

MinecraftServer#tick() [line 766]

[Removed]

As you can see, this isn't even the same method as the one being indicated by the crash report!

 

IntegratedServer#tick() [line 112]

         this.getPlayerList().saveAllPlayerData();

Is pointing to this line ^^

 

Anyway...

 

It eventually boils down to a NullPointerException in World#addTileEntity()

[Removed]

 

I am completely lost. When I remove the Implement of ITickableTileEntity it works perfectly, but I need the TileEntity to be tickable.

 

Updated code:

 

https://github.com/TheRealZeher/DimensionalPocketsII/tree/1.14.4-0.1.40

Edited by DaemonUmbra
Removed Mojang code

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.