Jump to content

Recommended Posts

Posted

Hey,

I`ve got a problem: I created a tileentity, all works fine but if somebody die on the server, he can`t respawn.

 

Here, my TileEntity class:

 

Spoiler

package oect.lwaltens.luckyblockoect.quest;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.MobEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.SPacketTitle;
import net.minecraft.network.play.server.SPacketTitle.Type;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import oect.lwaltens.luckyblockoect.registeries.LuckyBlockOect_Items;
import oect.lwaltens.luckyblockoect.registeries.LuckyBlockOect_Potions;

import java.util.UUID;

import javax.annotation.Nullable;

import com.mojang.authlib.GameProfile;
import com.mojang.realmsclient.gui.ChatFormatting;


public class quest_tileentity extends TileEntity implements ITickable {

    static ItemStackHandler inventory = new ItemStackHandler(3);

    @Override
    public void readFromNBT(NBTTagCompound compound) {
        super.readFromNBT(compound);
        inventory.deserializeNBT(compound.getCompoundTag("inventory_quest"));
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound) {
        compound.setTag("inventory_quest", inventory.serializeNBT());
        return super.writeToNBT(compound);
    }

    @Override
    public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
        return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
    }

    @Nullable
    @Override
    public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
        return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T)inventory : super.getCapability(capability, facing);
    }


	@Override
	public void update() {
		if(!world.isRemote) 
		{
			if(inventory.getStackInSlot(0) != null && inventory.getStackInSlot(1) != null && inventory.getStackInSlot(2) != null)
			{
				Item item0 = inventory.getStackInSlot(0).getItem();
				Item item1 = inventory.getStackInSlot(1).getItem();
				Item item2 = inventory.getStackInSlot(2).getItem();
				
				if(item0 == LuckyBlockOect_Items.clue_dna && item1 == LuckyBlockOect_Items.clue_finger && item2 == LuckyBlockOect_Items.clue_fuss) 
				{
					if(world.getMinecraftServer() != null) 
					{
						MinecraftServer server = world.getMinecraftServer();
						GameProfile[] baum = server.getOnlinePlayerProfiles();
						int size = baum.length;
						
					  	for(int i = 0; i < size; i++) 
			        	{
			        		

			        			UUID i1 = baum[i].getId();
			        			

			        			if(server.getPlayerList().getPlayerByUUID(i1) != null)
			        			{
			        				if(server.getPlayerList().getPlayerByUUID(i1).isPotionActive(LuckyBlockOect_Potions.Murder)) 
			        				{		      				
			        					if(!server.getPlayerList().getPlayerByUUID(i1).getEntityWorld().isRemote) 
			        					{
			        						
			        					inventory.setStackInSlot(0, new ItemStack(Blocks.AIR));
			        					inventory.setStackInSlot(1, new ItemStack(Blocks.AIR));
			        					inventory.setStackInSlot(2, new ItemStack(Blocks.AIR));
			        					String murdername = server.getPlayerList().getPlayerByUUID(i1).getName();
			        						
			        					for(int i2 = 0; i2 < size; i2++)			        	
			        					{
			        						UUID i3 = baum[i].getId();
			        						server.getPlayerList().getPlayerByUUID(i3).sendMessage(new TextComponentString(ChatFormatting.WHITE+murdername+ChatFormatting.RED+" wurde als Murder durch das"+ChatFormatting.WHITE+" Labor "+ChatFormatting.RED+"indentifiziert!"));					     
			        					}
			        						
		
			        				}
			        					
			        			}
			        		}
			        	}
					}
				}
			}
		}
	}
}

 

And here my Server Log:

 

Spoiler

[18:21:43] [Server thread/FATAL] [net.minecraft.server.MinecraftServer]: Error executing task
java.util.concurrent.ExecutionException: java.lang.RuntimeException: class oect.lwaltens.luckyblockoect.quest.quest_tileentity is missing a mapping! This is a bug!
    at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:795) [MinecraftServer.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:409) [DedicatedServer.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:740) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:589) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
Caused by: java.lang.RuntimeException: class oect.lwaltens.luckyblockoect.quest.quest_tileentity is missing a mapping! This is a bug!
    at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:89) ~[TileEntity.class:?]
    at net.minecraft.tileentity.TileEntity.getUpdateTag(TileEntity.java:226) ~[TileEntity.class:?]
    at net.minecraft.network.play.server.SPacketChunkData.<init>(SPacketChunkData.java:51) ~[SPacketChunkData.class:?]
    at net.minecraft.server.management.PlayerChunkMapEntry.sendToPlayer(PlayerChunkMapEntry.java:182) ~[PlayerChunkMapEntry.class:?]
    at net.minecraft.server.management.PlayerChunkMapEntry.addPlayer(PlayerChunkMapEntry.java:74) ~[PlayerChunkMapEntry.class:?]
    at net.minecraft.server.management.PlayerChunkMap.addPlayer(PlayerChunkMap.java:299) ~[PlayerChunkMap.class:?]
    at net.minecraft.server.management.PlayerList.recreatePlayerEntity(PlayerList.java:621) ~[PlayerList.class:?]
    at net.minecraft.network.NetHandlerPlayServer.processClientStatus(NetHandlerPlayServer.java:1161) ~[NetHandlerPlayServer.class:?]
    at net.minecraft.network.play.client.CPacketClientStatus.processPacket(CPacketClientStatus.java:42) ~[CPacketClientStatus.class:?]
    at net.minecraft.network.play.client.CPacketClientStatus.processPacket(CPacketClientStatus.java:8) ~[CPacketClientStatus.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_151]
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_151]
    at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?]
    ... 5 more

Thank you very much!

Posted
10 minutes ago, diesieben07 said:
  • That is creating a new tile entity, I asked for where you are registering your tile entity.
  • Problematic code, issue 4.

sorry, I missunderstood you:

here is my registery:

GameRegistry.registerTileEntity(quest_tileentity.class, "luckyblockoect:quest");

It`s after the Block registery in the preInit.

 

Ok, the block class is fixed:

Spoiler

package oect.lwaltens.luckyblockoect.blocks;

import java.util.Random;

import javax.annotation.Nullable;

import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import oect.lwaltens.luckyblockoect.LuckyBlockOect;
import oect.lwaltens.luckyblockoect.quest.quest_tileentity;

public class BlockMurderQuest extends Block {

	public static String NAME = "murderquest"; 
	
    public BlockMurderQuest() {
        super(Material.WOOD);
        setCreativeTab(LuckyBlockOect.questtab);
        setUnlocalizedName(NAME);
        setRegistryName(NAME);
    }

    @Override
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
        if(!world.isRemote)
        {
        	TileEntity te = world.getTileEntity(pos);
        	
            if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH)) 
            {
                player.openGui(LuckyBlockOect.instance, LuckyBlockOect.quest, world, pos.getX(), pos.getY(), pos.getZ());
            }
        }
    	
        return super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ);
    }
    
    @Override
    public boolean hasTileEntity() 
    {
    	return true;
    }
    
    @Override
    public TileEntity createTileEntity(World world, IBlockState state) {
    	
    	return new quest_tileentity();
    }  
    
}

 

 

  • Like 1
Posted
1 hour ago, #ÖCT said:

quest_tileentity

Why is your class not Upper Cased?

https://www.javatpoint.com/java-naming-conventions

@diesieben07 can we add that to the common Code Style list?

  • Thanks 1

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.

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



×
×
  • Create New...

Important Information

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