Jump to content

[1.10.2] TileEntitys Data synchronisation and updating Containers


Roxane

Recommended Posts

I'm trying to update my mod from 1.9 to 1.10.2 (forge version 12.16.1.1887 to 12.18.2.2098).

 

Most of my mods work just fine, but with my AccessControl I'm having a little bit of a problem. The access panels can have different colors and some other properties, but on loading a world they all have the default properties on the client side. It seems that on the server side they have correct properties because they are behaving as they should, although looking differently. As soon as they are activated once the clientside gets the correct data and now they are looking as they should.

 

This is my code of the BlockAccessPanel.java

 

package net.roxa.accessControl;

import java.util.List;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.scoreboard.Team;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockAccessPanel extends BlockContainer
{
//TileEntityAccessPanel tileEntity;

    public static final PropertyBool POWERED = PropertyBool.create("powered");
    public static final PropertyDirection FACING = PropertyDirection.create("facing");
    public static final PropertyEnum COLOR = PropertyEnum.create("color", EnumColor.class);

public BlockAccessPanel() {
	super(Material.CIRCUITS);
	this.setDefaultState(this.blockState.getBaseState().withProperty(POWERED, Boolean.valueOf(false)).withProperty(COLOR, EnumColor.WHITE).withProperty(FACING, EnumFacing.UP));
	this.setUnlocalizedName("accessPanel");
	this.setRegistryName("accessPanel");
	this.setCreativeTab(CreativeTabs.REDSTONE);
	this.setSoundType(SoundType.METAL);
	this.setHardness(0.5F);
	this.setResistance(1F);
	//this.useNeighborBrightness = true;

	//tileEntity = new TileEntityAccessPanel();
}

@SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer()
{
	return BlockRenderLayer.CUTOUT_MIPPED;
}

@Override
public boolean isOpaqueCube(IBlockState state)
{
	return false;
}

@Override
public boolean isFullCube(IBlockState state)
{
	return false;
}

@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
	return EnumBlockRenderType.MODEL;
}

/*
@Override
public void setBlockBoundsForItemRender()
    {
        float f = 0.1875F;
        float f1 = 0.125F;
        float f2 = 0.125F;
        this.setBlockBounds(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2);
    }
    */

@Override
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side)
    {
        return worldIn.isSideSolid(pos.offset(side.getOpposite()), side, true);
    }

@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
    {
        EnumFacing[] aenumfacing = EnumFacing.values();
        int i = aenumfacing.length;

        for (int j = 0; j < i; ++j)
        {
            EnumFacing enumfacing = aenumfacing[j];

            if (worldIn.isSideSolid(pos.offset(enumfacing), enumfacing.getOpposite(), true))
            {
                return true;
            }
        }

        return false;
    }

@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return worldIn.isSideSolid(pos.offset(facing.getOpposite()), facing, true) ? this.getDefaultState().withProperty(FACING, facing).withProperty(POWERED, Boolean.valueOf(false)) : this.getDefaultState().withProperty(FACING, EnumFacing.DOWN).withProperty(POWERED, Boolean.valueOf(false));
    }

@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block neighborBlock)
    {
        if (this.checkForDrop(worldIn, pos, state))
        {
            EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

            if (!worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true))
            {
                this.dropBlockAsItem(worldIn, pos, state, 0);
                worldIn.setBlockToAir(pos);
            }
        }
    }

    private boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
    {
        if (!this.canPlaceBlockAt(worldIn, pos))
        {
            this.dropBlockAsItem(worldIn, pos, state, 0);
            worldIn.setBlockToAir(pos);
            return false;
        }
        else
        {
            return true;
        }
    }
    
    @Override
    //public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
    {
        return this.updateBlockBounds(source.getBlockState(pos));
    }

    private AxisAlignedBB updateBlockBounds(IBlockState state)
    {
    	if (state.getBlock() instanceof BlockAccessPanel)
    	{
    	AxisAlignedBB axis;
        EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
        float f = 0.25F;
        float f1 = 0.375F;
        float f2 = 1 / 16.0F;
        float f3 = 0.1875F;
        float f4 = 1 - 0.1875F;

        switch (BlockAccessPanel.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()])
        {
            case 1:
            	axis = new AxisAlignedBB(0.0F, f3, f3, f2, f4, f4);
                break;
            case 2:
            	axis = new AxisAlignedBB(1.0F - f2, f3, f3, 1.0F, f4, f4);
                break;
            case 3:
            	axis = new AxisAlignedBB(f3, f3, 0.0F, f4, f4, f2);
                break;
            case 4:
            	axis = new AxisAlignedBB(f3, f3, 1.0F - f2, f4, f4, 1.0F);
                break;
            case 5:
            	axis = new AxisAlignedBB(f3, 0.0F, f3, f4, 0.0F + f2, f4);
                break;
            default:
            	axis = new AxisAlignedBB(f3, 1.0F - f2, f3, f4, 1.0F, f4);
        }
        return axis;
    	}
    	else return null;
    }
    
    /*
    @Override
    public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
    {
        return null;
    }
    */

@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
    {
        if (((Boolean)state.getValue(POWERED)).booleanValue())
        {
            this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        }

        super.breakBlock(worldIn, pos, state);
    }

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
    {
	boolean activated = false;
	boolean canAccess = false;
    	//ItemStack itemStackHold = playerIn.getHeldItem();
    	Item item;
    	if (heldItem != null) item = heldItem.getItem();
    	else item = null;
    	if (item == RoxaAccessControlMod.accessCard && !playerIn.isSneaking())
    	{
    		TileEntity tileEntity = worldIn.getTileEntity(pos);
    		TileEntityAccessPanel entityAccessPanel = null;
    		if (tileEntity instanceof TileEntityAccessPanel) entityAccessPanel = (TileEntityAccessPanel)tileEntity;
    		ItemAccessCard card = (ItemAccessCard) item;
    		
    		//Testing for the right color
            if (card.canAccess(heldItem, (entityAccessPanel.getColor())))
            {
            	//activated = activateBlock(worldIn, state, pos);
            	canAccess = true;
            	//System.out.println("Access because of color saved on Card");
            }
            //Testing for Panels on Card or Player on Panel
            else if (entityAccessPanel != null)
    		{
    			String[] playerNames = null;
    			playerNames = entityAccessPanel.getPlayerNames();
    			String playerName = playerIn.getDisplayNameString();
    			if (playerNames != null)
    			{
    				for (int i = 0; i < playerNames.length; i++)
                    {
        				if (playerNames[i].equals(playerName))
                    	{
                    		//activated = activateBlock(worldIn, state, pos);
        					canAccess = true;
                    		//System.out.println("Access because of player saved in Panel");
                    	}
        				if (playerNames[i].equals(""))
                    	{
                    		canAccess = true;
                    		//System.out.println("Access because everybody has Access");
                    	}
                    }
    			}
    			
    			if (!canAccess && card.getPanels(heldItem) != null)
    			{
    				String[] panels = card.getPanels(heldItem);
    				String panelName = entityAccessPanel.getPanelName();
    				for (int i = 0; i < panels.length; i++)
                    {
    					if (panels[i].equals(panelName))
    					{
    						canAccess = true;
    						//activated = activateBlock(worldIn, state, pos);
    						//System.out.println("Access because of panel name is on Card");
    					}
                    }
    			}
    			
    			if (!canAccess)
    			{
    				worldIn.playSound(null, pos, RoxaAccessControlMod.soundDenied, SoundCategory.BLOCKS, 0.6F, 1.0F);
    			}
    		}
    		
    		if (((Boolean)state.getValue(POWERED)).booleanValue())
            {
    			if(!entityAccessPanel.isToggle()) activated = true;
    			else if (canAccess)
    			{
    				deactivateBlock(worldIn, state, pos);
    				entityAccessPanel.incCounter();
        			activateOtherPanels(worldIn, pos, entityAccessPanel, false);
    				worldIn.playSound(null, pos, RoxaAccessControlMod.soundGranted, SoundCategory.BLOCKS, 0.4F, 1.0F);
    			}
            }
    		else if (canAccess)
    		{
			activateBlock(worldIn, state, pos, entityAccessPanel.isToggle());
    			entityAccessPanel.incCounter();
    			activateOtherPanels(worldIn, pos, entityAccessPanel, true);
    			worldIn.playSound(null, pos, RoxaAccessControlMod.soundGranted, SoundCategory.BLOCKS, 0.6F, 1.0F);
    		}
    	}
    	else
    	{
    		//Do nothing
    	}
    	return activated;
    }

private boolean activateBlock(World worldIn, IBlockState state, BlockPos pos, boolean toggle)
{
	worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSound(null, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.6F);
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        if(!toggle) worldIn.scheduleUpdate(pos, this, 40);
        return true;
}

public void deactivateBlock(World worldIn, IBlockState state, BlockPos pos)
{
	if (!worldIn.isRemote)
        {
            if (((Boolean)state.getValue(POWERED)).booleanValue())
            {
                worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
                this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
                worldIn.playSound(null, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_OFF, SoundCategory.BLOCKS, 0.3F, 0.5F);
                worldIn.markBlockRangeForRenderUpdate(pos, pos);
            }
        }
}

public void activateOtherPanels(World worldIn, BlockPos pos, TileEntityAccessPanel entityAccessPanel, boolean activate)
{
	String panelName = entityAccessPanel.getPanelName();
	if (!panelName.isEmpty())
	{
		for(int i = -5; i <= 5; i++)
		{
			for(int j = -5; j <= 5; j++)
			{
				BlockPos posOther = pos.add(i, 0, j);
				Block blockOther = worldIn.getBlockState(posOther).getBlock();
				if(blockOther == RoxaAccessControlMod.accessPanel && (i != 0 | j != 0))
				{
					TileEntity tileEntityOther = worldIn.getTileEntity(posOther);
		    		TileEntityAccessPanel entityAccessPanelOther = null;
		    		if (tileEntityOther instanceof TileEntityAccessPanel) entityAccessPanelOther = (TileEntityAccessPanel)tileEntityOther;
		    		String panelNameOther = entityAccessPanelOther.getPanelName();
		    		if(panelName.equals(panelNameOther))
		    		{
		    			BlockAccessPanel blockPanel = (BlockAccessPanel) blockOther;
		    			if(activate)
		    			{
		    				blockPanel.activateBlock(worldIn, worldIn.getBlockState(posOther), posOther, entityAccessPanelOther.isToggle());
		    				//System.out.println("Activating Access Panel at " + i + " " + j + " with same name");
		    				//System.out.println("Counter is: " + entityAccessPanel.getCounter());
	    				}
		    			else 
		    			{
		    				blockPanel.deactivateBlock(worldIn, worldIn.getBlockState(posOther), posOther);
		    				//System.out.println("Deaktivating Access Panel at " + i + " " + j + " with same name");
		    				//System.out.println("Counter is: " + entityAccessPanel.getCounter());
		    			}
		    			if (entityAccessPanel.getCounter() != entityAccessPanelOther.getCounter())
		    			{
		    				entityAccessPanelOther.setCounter(entityAccessPanel.getCounter());
		    				activateOtherPanels(worldIn, posOther, entityAccessPanelOther, activate);
		    			}
		    		}
				}
			}
		}
		for(int x = -3; x <= 3; x++)
		{
			for(int y = -3; y <= 3; y++)
			{
				if (y!=0)
				{
					for(int z = -3; z <= 3; z++)
					{
						BlockPos posOther = pos.add(x, y, z);
						Block blockOther = worldIn.getBlockState(posOther).getBlock();
						if(blockOther == RoxaAccessControlMod.accessPanel)
						{
							TileEntity tileEntityOther = worldIn.getTileEntity(posOther);
				    		TileEntityAccessPanel entityAccessPanelOther = null;
				    		if (tileEntityOther instanceof TileEntityAccessPanel) entityAccessPanelOther = (TileEntityAccessPanel)tileEntityOther;
				    		String panelNameOther = entityAccessPanelOther.getPanelName();
				    		if(panelName.equals(panelNameOther))
				    		{
				    			BlockAccessPanel blockPanel = (BlockAccessPanel) blockOther;
				    			if(activate)
				    			{
				    				blockPanel.activateBlock(worldIn, worldIn.getBlockState(posOther), posOther, entityAccessPanelOther.isToggle());
				    				//System.out.println("Activating Access Panel at " + i + " " + j + " with same name");
				    				//System.out.println("Counter is: " + entityAccessPanel.getCounter());
			    				}
				    			else 
				    			{
				    				blockPanel.deactivateBlock(worldIn, worldIn.getBlockState(posOther), posOther);
				    				//System.out.println("Deaktivating Access Panel at " + i + " " + j + " with same name");
				    				//System.out.println("Counter is: " + entityAccessPanel.getCounter());
				    			}
				    			if (entityAccessPanel.getCounter() != entityAccessPanelOther.getCounter())
				    			{
				    				entityAccessPanelOther.setCounter(entityAccessPanel.getCounter());
				    				activateOtherPanels(worldIn, posOther, entityAccessPanelOther, activate);
				    			}
				    		}
						}
					}
				}
			}
		}
	}
}

@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
    {
        this.deactivateBlock(worldIn, state, pos);
        TileEntityAccessPanel entityAccessPanel = (TileEntityAccessPanel) worldIn.getTileEntity(pos);
        entityAccessPanel.incCounter();
        activateOtherPanels(worldIn, pos, entityAccessPanel, false);
    }

public int isProvidingWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
    {
        return ((Boolean)state.getValue(POWERED)).booleanValue() ? 15 : 0;
    }

@Override
    public int getStrongPower(IBlockState state, IBlockAccess worldIn, BlockPos pos, EnumFacing side)
    {
	return !((Boolean)state.getValue(POWERED)).booleanValue() ? 0 : (state.getValue(FACING) == side ? 15 : 0);
    }

@Override
    public boolean canProvidePower(IBlockState state)
    {
	return true;
    }
    
    private void notifyNeighbors(World worldIn, BlockPos pos, EnumFacing facing)
    {
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.offset(facing.getOpposite()), this);
    }
    
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing;

        switch (meta & 7)
        {
            case 0:
                enumfacing = EnumFacing.DOWN;
                break;
            case 1:
                enumfacing = EnumFacing.EAST;
                break;
            case 2:
                enumfacing = EnumFacing.WEST;
                break;
            case 3:
                enumfacing = EnumFacing.SOUTH;
                break;
            case 4:
                enumfacing = EnumFacing.NORTH;
                break;
            case 5:
            default:
                enumfacing = EnumFacing.UP;
        }
        return this.getDefaultState().withProperty(FACING, enumfacing).withProperty(POWERED, Boolean.valueOf((meta &  > 0));
    }

    public int getMetaFromState(IBlockState state)
    {
        int i;

        switch (BlockAccessPanel.SwitchEnumFacing.FACING_LOOKUP[((EnumFacing)state.getValue(FACING)).ordinal()])
        {
            case 1:
                i = 1;
                break;
            case 2:
                i = 2;
                break;
            case 3:
                i = 3;
                break;
            case 4:
                i = 4;
                break;
            case 5:
            default:
                i = 5;
                break;
            case 6:
                i = 0;
        }

        if (((Boolean)state.getValue(POWERED)).booleanValue())
        {
            i |= 8;
        }

        return i;
    }
    
    @Override
    public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    {
    	TileEntityAccessPanel teap = (TileEntityAccessPanel) worldIn.getTileEntity(pos);
    	return worldIn.getBlockState(pos).withProperty(COLOR, this.getPanelColor(teap.getColor()));
    }
    
    @Override
    protected BlockStateContainer createBlockState()
    {
    	return new BlockStateContainer(this, new IProperty[] {POWERED, FACING, COLOR});
    }

@Override
public TileEntity createNewTileEntity(World worldIn, int meta)
{
	return new TileEntityAccessPanel();
}

public EnumColor getPanelColor(int colorIn)
{
	EnumColor color = null;
	switch (colorIn) 
	{
	case 0:
		color = EnumColor.WHITE;
		break;
	case 1:
		color = EnumColor.YELLOW;
		break;
	case 2:
		color = EnumColor.ORANGE;
		break;
	case 3:
		color = EnumColor.RED;
		break;
	case 4:
		color = EnumColor.PURPLE;
		break;
	case 5:
		color = EnumColor.BLUE;
		break;
	case 6:
		color = EnumColor.GREEN;
		break;
	case 7:
		color = EnumColor.BLACK;
		break;
	case 8:
		color = EnumColor.GREY;
		break;
	case 9:
		color = EnumColor.LIGHT_GREY;
		break;
	case 10:
		color = EnumColor.PINK;
		break;
	case 11:
		color = EnumColor.MAGENTA;
		break;
	case 12:
		color = EnumColor.LIGHT_BLUE;
		break;
	case 13:
		color = EnumColor.CYAN;
		break;
	case 14:
		color = EnumColor.LIME;
		break;
	case 15:
		color = EnumColor.BROWN;
		break;
	}
	return color;
}

public void setPanelColor(World worldIn, BlockPos posIn, int colorIn)
{
	TileEntityAccessPanel teap = (TileEntityAccessPanel) worldIn.getTileEntity(posIn);
	teap.setColor(colorIn);
	IBlockState state = worldIn.getBlockState(posIn);
	switch (colorIn) 
	{
	case 0:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.WHITE));
		break;
	case 1:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.YELLOW));
		break;
	case 2:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.ORANGE));
		break;
	case 3:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.RED));
		break;
	case 4:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.PURPLE));
		break;
	case 5:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.BLUE));
		break;
	case 6:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.GREEN));
		break;
	case 7:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.BLACK));
		break;
	case 8:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.GREY));
		break;
	case 9:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.LIGHT_GREY));
		break;
	case 10:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.PINK));
		break;
	case 11:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.MAGENTA));
		break;
	case 12:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.LIGHT_BLUE));
		break;
	case 13:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.CYAN));
		break;
	case 14:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.LIME));
		break;
	case 15:
		worldIn.setBlockState(posIn, state.withProperty(COLOR, EnumColor.BROWN));
		break;
	}
	//System.out.println(worldIn.getBlockState(posIn));
	//TODO Mit Mehrspieler testen: Tut das hier das, was es soll?
	//worldIn.markBlockForUpdate(posIn);
	worldIn.markBlockRangeForRenderUpdate(posIn, posIn);
}

static final class SwitchEnumFacing
    {
        static final int[] FACING_LOOKUP = new int[EnumFacing.values().length];
        private static final String __OBFID = "CL_00002131";

        static
        {
            try
            {
                FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 1;
            }
            catch (NoSuchFieldError var6)
            {
                ;
            }

            try
            {
                FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 2;
            }
            catch (NoSuchFieldError var5)
            {
                ;
            }

            try
            {
                FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 3;
            }
            catch (NoSuchFieldError var4)
            {
                ;
            }

            try
            {
                FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 4;
            }
            catch (NoSuchFieldError var3)
            {
                ;
            }

            try
            {
                FACING_LOOKUP[EnumFacing.UP.ordinal()] = 5;
            }
            catch (NoSuchFieldError var2)
            {
                ;
            }

            try
            {
                FACING_LOOKUP[EnumFacing.DOWN.ordinal()] = 6;
            }
            catch (NoSuchFieldError var1)
            {
                ;
            }
        }
    }
}

and this is the TileEntityAccessPanel.java

 

package net.roxa.accessControl;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class TileEntityAccessPanel extends TileEntity
{
String name = "";
boolean toggleMode;
String players[];
int color = 0;
private int counter = 0;

public TileEntityAccessPanel()
{

}

@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
	super.readFromNBT(tagCompound);

	name = tagCompound.getString("Name");
	if (name == null) name = "";

	toggleMode = tagCompound.getBoolean("Toggle");

	color = tagCompound.getInteger("Color");

	NBTTagCompound tag = tagCompound.getCompoundTag("Player");
  		
  		if (tag != null)
  		{
  			int playerAmount = 0;
  	  		for (int i = 0; tag.hasKey("Player" + i); i++)
  			{
  	  		playerAmount++;
  			}
  	  		
  	  		players = new String[playerAmount];
  	  		
  	  		for (int i = 0; i < players.length; i++)
  			{
  	  		players[i] = tag.getString("Player" + i);
  			}

  	  		if (playerAmount == 0) players = null;
  		}
  		else
  		{
  			players = null;
  		}
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
	super.writeToNBT(tagCompound);

	tagCompound.setString("Name", name);

	tagCompound.setBoolean("Toggle", toggleMode);

	tagCompound.setInteger("Color", color);

	NBTTagCompound tag = new NBTTagCompound();
    	
    	if (players != null)
    	{
    		NBTTagString string = new NBTTagString();
    		for (int i = 0; i < players.length; i++)
    		{
    			string = new NBTTagString(players[i]);
    			tag.setTag("Player" + i, string);
    		}
    		tagCompound.setTag("Player", tag);
    	}
    	else tagCompound.setTag("Player", tag);
	return tagCompound;

}

@Override
public SPacketUpdateTileEntity getUpdatePacket()
{
	NBTTagCompound syncData = new NBTTagCompound();
	this.writeToNBT(syncData);
	return new SPacketUpdateTileEntity(pos, 0, syncData);
}

@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
{
	this.readFromNBT(pkt.getNbtCompound());
	RoxaAccessControlMod.network.sendToServer(new MessageInt(MessageInt.requestTileEntityForPanel, pos));
}

public void addPlayer(String nameIn)
  	{
  		int newLength;
  		if (players == null)
  		{
  			//System.out.println("Read no Players from NBT. Creating new String[]");
  			newLength = 1;
  			players = new String[newLength];
  			players[0] = nameIn;
  		}
  		else 
  		{
  			//System.out.println("Read some Players from NBT");
  			newLength = players.length + 1;
  			String[] old = players;
  			players = new String[newLength];
  			for (int i = 0; i < old.length; i++)
  			{
  				players[i] = old[i];
  				//System.out.println("Player[" + i + "] is now: " + players[i]);
  			}
  			players[newLength - 1] = nameIn;
  		}
  	}

public boolean doesPlayerExist(String nameIn)
{
	boolean exists = false;
	for (int i = 0; players != null && i < players.length; i++)
	{
		if (nameIn.equals(players[i])) exists = true;
	}
	return exists;
}

public void deletePlayer(int index)
{
	String[] old = players;

	RoxaAccessControlMod.network.sendToServer(new MessageInt(MessageInt.deletePlayerFromPanel, index));

	if (players != null && players.length > 1)
  		{
		players = new String[old.length - 1];
  			for (int i = 0; i < index; i++)
  			{
  				players[i] = old[i];
  			}
  			for (int i = players.length - 1; i >= index; i--)
  			{
  				players[i] = old[i+1];
  			}
  		}
  		else
  		{
  			players = null;
  		}
}

public boolean isToggle()
{
	return toggleMode;
}

public void setToggle(boolean toggleMode)
{
	this.toggleMode = toggleMode;

}

public void setToggleOtherPanels(World worldIn, BlockPos pos, boolean toggle)
{
	if (!name.isEmpty())
	{
		for(int i = -5; i <= 5; i++)
		{
			for(int j = -5; j <= 5; j++)
			{
				BlockPos posOther = pos.add(i, 0, j);
				Block blockOther = worldIn.getBlockState(posOther).getBlock();
				if(blockOther == RoxaAccessControlMod.accessPanel && (i != 0 | j != 0))
				{
					TileEntity tileEntityOther = worldIn.getTileEntity(posOther);
		    		TileEntityAccessPanel entityAccessPanelOther = null;
		    		if (tileEntityOther instanceof TileEntityAccessPanel) entityAccessPanelOther = (TileEntityAccessPanel)tileEntityOther;
		    		String panelNameOther = entityAccessPanelOther.getPanelName();
		    		if(name.equals(panelNameOther))
		    		{
		    			//System.out.println("Setting Toggle Mode to " + toggle + " at " + i + " " + j);
		    			entityAccessPanelOther.setToggle(toggle);
		    			
		    			TileEntity tileEntity = worldIn.getTileEntity(pos);
			    		TileEntityAccessPanel entityAccessPanel = null;
			    		if (tileEntity instanceof TileEntityAccessPanel) entityAccessPanel = (TileEntityAccessPanel)tileEntity;
			    		//System.out.println("Counter is: " + entityAccessPanel.getCounter());
		    			if (entityAccessPanel.getCounter() != entityAccessPanelOther.getCounter())
		    			{
		    				entityAccessPanelOther.setCounter(entityAccessPanel.getCounter());
		    				setToggleOtherPanels(worldIn, posOther, toggle);
		    			}
		    		}
				}
			}
		}
		for(int x = -3; x <= 3; x++)
		{
			for(int y = -3; y <= 3; y++)
			{
				if (y!=0)
				{
					for(int z = -3; z <= 3; z++)
					{
						BlockPos posOther = pos.add(x, y, z);
						Block blockOther = worldIn.getBlockState(posOther).getBlock();
						if(blockOther == RoxaAccessControlMod.accessPanel)
						{
							TileEntity tileEntityOther = worldIn.getTileEntity(posOther);
				    		TileEntityAccessPanel entityAccessPanelOther = null;
				    		if (tileEntityOther instanceof TileEntityAccessPanel) entityAccessPanelOther = (TileEntityAccessPanel)tileEntityOther;
				    		String panelNameOther = entityAccessPanelOther.getPanelName();
				    		if(name.equals(panelNameOther))
				    		{
				    			System.out.println("Setting Toggle Mode to " + toggle + " at " + x + " " + y + " " + z);
				    			entityAccessPanelOther.setToggle(toggle);
				    			
				    			TileEntity tileEntity = worldIn.getTileEntity(pos);
					    		TileEntityAccessPanel entityAccessPanel = null;
					    		if (tileEntity instanceof TileEntityAccessPanel) entityAccessPanel = (TileEntityAccessPanel)tileEntity;
					    		System.out.println("Counter is: " + entityAccessPanel.getCounter());
				    			if (entityAccessPanel.getCounter() != entityAccessPanelOther.getCounter())
				    			{
				    				entityAccessPanelOther.setCounter(entityAccessPanel.getCounter());
				    				setToggleOtherPanels(worldIn, posOther, toggle);
				    			}
				    		}
						}
					}
				}
			}
		}
	}
}

public int getColor()
{
	return this.color;
}

public void setColor(int colorIn)
{
	color = colorIn;
}

public String[] getPlayerNames()
{
	return this.players;
}

public void setPlayers(String[] playerIn)
{
	players = playerIn;
}

public void setPanelName(String nameIn)
{
	name = nameIn;
}

public String getPanelName()
{
	return name;
}

public String getName()
{
	return "tileEntity.accessPanel";
}

public int getCounter()
{
	return counter;
}

public void setCounter(int counterIn)
{
	counter = counterIn;
}

public void incCounter()
{
	counter++;
}


@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate)
    {
        return (oldState.getBlock() != newSate.getBlock());
    }
}

 

 

and I can't seem to find a correct way to update this line

((ICrafting)this.crafters.get(j)).sendSlotContents(this, i, itemstack1);

in public void detectAndSendChanges() in the container...

ContainerAccessAdministrator.java:

 

package net.roxa.accessControl;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerWorkbench;
import net.minecraft.inventory.IContainerListener;
//import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class ContainerAccessAdministrator extends Container
{
public IInventory cardSlot;// = new InventoryCrafting(this, 1, 1); 
protected TileEntityAccessAdministrator tileEntity;

    private World worldObj;
    private BlockPos pos;
    private EntityPlayer player;

    public ContainerAccessAdministrator(EntityPlayer playerIn, InventoryPlayer playerInventory, World worldIn, BlockPos posIn, TileEntityAccessAdministrator te)
    {
        this.worldObj = worldIn;
        this.pos = posIn;
        this.player = playerIn;
        this.tileEntity = te;
        cardSlot = te;
        int i;
        int j;
        
        this.addSlotToContainer(new Slot(this.cardSlot, 0, 14, );//22, 25)); //Slot 0 of custom "Inventory"
        
        for (i = 0; i < 3; ++i)
        {
            for (j = 0; j < 9; ++j)
            {
                this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 48 + j * 18, 121 + i * 18)); //Slot (9 to 35) or (10 to 36)
            }
        }
        
        for (i = 0; i < 9; ++i)
        {
            this.addSlotToContainer(new Slot(playerInventory, i, 48 + i * 18, 179)); //Slot (0 to  or (1 to 9)
        }
        EntityPlayer player = playerInventory.player;
        if (!worldIn.isRemote)
        {
        	//System.out.println("Casting");
        	if (RoxaAccessControlMod.network != null) 
        	{
        		ItemStack stack = cardSlot.getStackInSlot(0);
        		if (stack != null && stack.getItem() == RoxaAccessControlMod.accessCard) 
        		{
        			ItemAccessCard card = (ItemAccessCard) stack.getItem();
        			String[] panels = card.getPanels(stack);
        			int length = 0;
        			if (panels != null) length = panels.length;
        			RoxaAccessControlMod.network.sendTo(new MessageInt(MessageInt.colorsToAdministratorGui, card.getColor(stack)), (EntityPlayerMP) player);//worldIn.getPlayerEntityByUUID(playerInventory.player.getUniqueID()));
        			RoxaAccessControlMod.network.sendTo(new MessageStringArray(MessageStringArray.panelsToAdministratorGui, panels, length), (EntityPlayerMP) player);
        		}
            	else 
            	{
            		RoxaAccessControlMod.network.sendTo(new MessageInt(MessageInt.colorsToAdministratorGui, 0), (EntityPlayerMP) player);//worldIn.getPlayerEntityByUUID(playerInventory.player.getUniqueID()));
            		RoxaAccessControlMod.network.sendTo(new MessageStringArray(MessageStringArray.panelsToAdministratorGui, null, 0), (EntityPlayerMP) player);
            	}
        	}
        }
    }
    
    @Override
    public boolean canInteractWith(EntityPlayer playerIn)
    {
        return playerIn.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
    }
    
    @Override
    public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
    {
    	ItemStack itemstack = null;
    	Slot slot = (Slot)this.inventorySlots.get(index);
    	if (slot != null && slot.getHasStack())
    	{
    		ItemStack itemstack1 = slot.getStack();
    		itemstack = itemstack1.copy();
    		// If itemstack is in Output stack
    		if (index == 0)
    		{
    			// try to place in player inventory / action bar; add 36+1 because mergeItemStack uses < index,
    			// so the last slot in the inventory won't get checked if you don't add 1
    			if (!this.mergeItemStack(itemstack1, 0+1, 0+36+1, true))
    			{
    				return null;
    			}
    			slot.onSlotChange(itemstack1, itemstack);
    		}
    		// itemstack is in player inventory, try to place in appropriate furnace slot
    		else if (index != 0)
    		{
    			//if it is an access Card, place it in the access card slot
    			if (itemstack1.getItem() == RoxaAccessControlMod.accessCard)
    			{
    				if (!this.mergeItemStack(itemstack1, 0, 0+1, false))
    				{
    					return null;
    				}
    			}
    			//item in player's inventory, but not in action bar
    			else if (index >= 0+1 && index < 0+28)
    			{
    				//place in action bar
    				if (!this.mergeItemStack(itemstack1, 0+28, 0+37, false))
    				{
    					return null;
    				}
    			}
    			//item in action bar - place in player inventory
    			else if (index >= 0+28 && index < 0+37 && !this.mergeItemStack(itemstack1, 0+1, 0+28, false))
    			{
    				return null;
    			}
    		}
    		//In one of the infuser slots; try to place in player inventory / action bar
    		else if (!this.mergeItemStack(itemstack1, 0+1, 0+37, false))
    		{
    			return null;
    		}
    		
    		if (itemstack1.stackSize == 0)
    		{
    			slot.putStack((ItemStack)null);
    		}
    		else
    		{
    			slot.onSlotChanged();
    		}
    		
    		if (itemstack1.stackSize == itemstack.stackSize)
    		{
    			return null;
    		}
    		
    		slot.onPickupFromSlot(playerIn, itemstack1);
    	}
    	return itemstack;
   	}
    
    @Override
    public void detectAndSendChanges()
    {
    	for (int i = 0; i < this.inventorySlots.size(); ++i)
        {
            ItemStack stack = ((Slot)this.inventorySlots.get(i)).getStack();
            ItemStack itemstack1 = (ItemStack)this.inventoryItemStacks.get(i);

            if (!ItemStack.areItemStacksEqual(itemstack1, stack))
            {
                itemstack1 = stack == null ? null : stack.copy();
                this.inventoryItemStacks.set(i, itemstack1);

                for (int j = 0; j < this.inventorySlots.size(); ++j)
                {
                	((ICrafting)this.crafters.get(j)).sendSlotContents(this, i, itemstack1);
                }
                if (!worldObj.isRemote && stack == cardSlot.getStackInSlot(0))
                {
                	//System.out.println("Casting");
                	if (stack != null && stack.getItem() == RoxaAccessControlMod.accessCard) 
                	{
                		ItemAccessCard card = (ItemAccessCard) stack.getItem();
            			String[] panels = card.getPanels(stack);
            			int length = 0;
            			if (panels != null) length = panels.length;
            			RoxaAccessControlMod.network.sendTo(new MessageInt(MessageInt.colorsToAdministratorGui, card.getColor(stack)), (EntityPlayerMP) player);//worldIn.getPlayerEntityByUUID(playerInventory.player.getUniqueID()));
            			RoxaAccessControlMod.network.sendTo(new MessageStringArray(MessageStringArray.panelsToAdministratorGui, panels, length), (EntityPlayerMP) player);
                	}
                	else 
                	{
                		RoxaAccessControlMod.network.sendTo(new MessageInt(MessageInt.colorsToAdministratorGui, 0), (EntityPlayerMP) player);//worldIn.getPlayerEntityByUUID(playerInventory.player.getUniqueID()));
                		RoxaAccessControlMod.network.sendTo(new MessageStringArray(MessageStringArray.panelsToAdministratorGui, null, 0), (EntityPlayerMP) player);
                	}
                }
            }
        }
    	if (cardSlot.getStackInSlot(0) == null || cardSlot.getStackInSlot(0).getItem() != RoxaAccessControlMod.accessCard) 
    	{
    		RoxaAccessControlMod.network.sendTo(new MessageInt(MessageInt.colorsToAdministratorGui, 0), (EntityPlayerMP) player);//worldIn.getPlayerEntityByUUID(playerInventory.player.getUniqueID()));
    		RoxaAccessControlMod.network.sendTo(new MessageStringArray(MessageStringArray.panelsToAdministratorGui, null, 0), (EntityPlayerMP) player);
    	}
    }
}

 

 

Edit: The solution was to update the line to:

this.listeners.get(0).sendSlotContents(this, i, itemstack1);

The whole code can be found here:

GitHub Repo

Link to comment
Share on other sites

1.9.4 changed

TileEntity

syncing a bit, the initial chunk data sent to the client now includes the update tag (

TileEntity#getUpdateTag

) of every

TileEntity

in the chunk; the update packet (

TileEntity#getUpdatePacket

) is only sent afterwards. This document by williewillus explains the changes in more detail.

 

ICrafting

was renamed to

IContainerListener

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

1.9.4 changed

TileEntity

syncing a bit, the initial chunk data sent to the client now includes the update tag (

TileEntity#getUpdateTag

) of every

TileEntity

in the chunk; the update packet (

TileEntity#getUpdatePacket

) is only sent afterwards. This document by williewillus explains the changes in more detail.

Thanks a lot! This solved it. Good explanation too :)

 

ICrafting

was renamed to

IContainerListener

.

When I chage

((ICrafting)this.crafters.get(j)).sendSlotContents(this, i, itemstack1);

to

((IContainerListener)this.inventorySlots.get(j)).sendSlotContents(this, i, itemstack1);

(as this.craftes does not seem to exist any more) it does compile but crashes as soon as I open the Gui with a "Cannot be cast" Exception. Is there anythin else but crafters and inventorySlots that I can use there? I didn't find it...

Link to comment
Share on other sites

Container#listeners

contains the

Container

's

IContainerListener

s.

 

Since generics were added to the vanilla codebase in 1.8.9 (or more accurately no longer stripped by Mojang's obfuscation process), you don't need to cast values when retrieving them from collections; the returned values are already the appropriate type. Only cast values when it's required and you already know that the value is of the type you're casting to.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I know about Generics, I just can't see what that got to do with my problem?

 

Maybe I should be asking differently:

How do I get the client side of the Gui to immediatly display a change made to an item in one of the containers slots on the server side?

Right now the item updates client side (shows the correct tool tip) as soon as I take it out of the slot. How can I update the item so I see the correct tool tip even if I only hover it?

Link to comment
Share on other sites

On that one I can't follow you...

 

Right at the moment I'm delaying the problem by simply commenting out the line, but I haven't found a proper solution yet.

 

The basic gist of what I was saying is don't cast unless you have a reason to and you know that the value you're casting is actually an instance of the type you're casting to.

 

Container#inventorySlots

is a

List<Slot>

.

Slot

is completely unrelated to

IContainerListener

, so don't try to cast a

Slot

to

IContainerListener

.

 

Container#listeners

is a

List<IContainerListener>

. You don't need to cast values from this to

IContainerListener

because they're already that type.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

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

    • Join one of the largest civilization experiments in Minecraft under our banner!   Our goal is to create the largest and most prominent civilization across the entirety of Minecraft, and we’d like you to join! We offer lots of unique roles and jobs that tailor to your specific skillset in Minecraft! You can build a city, participate in the government, or fight for Gold, God, and Glory on the battlefield!   Join our nation today! https://discord.gg/hb3cuaDezA
    • I have an issue where after I exit the world the capability data does not save when I reload the world. It will save the initial data such as village name but if I modify any data during gameplay theres a 5% chance the data saves when I exit then reload the world. I read the docs and was told that chunks need to be marked dirty but the docs does not say how to mark the chunk dirty... Heres the provider: public class ChunkCapProvider implements ICapabilityProvider, ICapabilitySerializable<CompoundTag> { private final Capability<IChunk> capability = ChunkCapability.CHUNK_CAPABILITY; private final ChunkCapability instance = new ChunkCapability(); private final LazyOptional lazy = LazyOptional.of(()->instance).cast(); public void invalidate(){ lazy.invalidate(); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) { if(cap == capability ) return lazy; return LazyOptional.empty(); } @Override public CompoundTag serializeNBT() { return instance.serializeNBT(); } @Override public void deserializeNBT(CompoundTag tag) { instance.deserializeNBT(tag); } }   Heres the capability class: public class ChunkCapability implements IChunk { public static final ResourceLocation ID = new ResourceLocation(Main.MODID, "owner"); public static final String VILLAGE_NAME = "village_name"; public static final String SAVED_ROLES = "saved_roles"; public static final String SAVED_POINTS = "saved_points"; public static final String BAD_CHUNK = "BAD_VILLAGE_CHUNK"; public static Capability<IChunk> CHUNK_CAPABILITY = null; private String villageName = "BAD_VILLAGE_CHUNK"; private String savedRoles = ""; private String savedPoints = ""; public ChunkCapability(){ this.getClass(); } @Override public CompoundTag serializeNBT() { CompoundTag nbt = new CompoundTag(); nbt.putString(SAVED_ROLES, this.savedRoles); nbt.putString(SAVED_POINTS, this.savedPoints); nbt.putString(VILLAGE_NAME, this.villageName); return nbt; } public void deserializeNBT(CompoundTag tag) { this.setVillageName(tag.getString(VILLAGE_NAME)); this.setSavedRoles(tag.getString(SAVED_ROLES)); this.setSavedPoints(tag.getString(SAVED_POINTS)); } public String getVillageName() { return this.villageName; } public void setVillageName(String str) { this.villageName = str; } public void setSavedRoles(String str) { this.savedRoles = str; } public void setRole(String name, String role){ if(!this.hasRole(name)) { this.savedRoles += (name + ":" + role + ","); this.savedPoints += (name + ":" + 10 + ","); return; } String roleName = this.getRole(name); String firstStr = this.savedRoles.substring(0, this.savedRoles.indexOf(name + ":") + name.length() + 1); String lastStr = this.savedRoles.substring(this.savedRoles.indexOf(name + ":") + ((name.length() + 1) + roleName.length())); this.savedRoles = firstStr + role + lastStr; } public String getRole(String name){ if(this.savedRoles.isEmpty() || !this.savedRoles.contains(name)) { this.setRole(name, Roles.Role.FOREIGNER.getName()); } String fStr = this.savedRoles.substring(this.savedRoles.indexOf(name + ":"), this.savedRoles.indexOf(',')); return fStr.substring(fStr.indexOf(':') + 1); } public boolean hasRole(String name) { if(this.savedRoles.isEmpty()) return false; return this.savedRoles.contains(name); } public String getSavedRoles() { return this.savedRoles; } public String getSavedPoints() { return this.savedPoints; } public void setSavedPoints(String name) { this.savedPoints = name; } public int getPoints(String name) { if(this.savedPoints.isEmpty() || !this.savedRoles.contains(name)) this.setPoints(name, 10); String fStr = this.savedPoints.substring(this.savedPoints.indexOf(name + ':')); return Integer.parseInt(fStr.substring(fStr.indexOf(':') + 1, fStr.indexOf(','))); } public void setPoints(String name, int rV) { if(!this.hasPoints(name)){ this.savedPoints += (name + ":" + rV + ","); return; } String oldPoints = String.valueOf(this.getPoints(name)); String points = String.valueOf(rV); String firstStr = this.savedPoints.substring(0, this.savedPoints.indexOf(name + ":") + name.length() + 1); String lastStr = this.savedPoints.substring(this.savedPoints.indexOf(name + ":") + ((name.length() + 1) + oldPoints.length())); Minecraft.getInstance().player.displayClientMessage(Component.nullToEmpty("Saved String: " + (firstStr + points + lastStr)), false); this.savedPoints = (firstStr + points + lastStr); } public boolean hasPoints(String name) { if(this.savedPoints.isEmpty()) return false; return this.savedPoints.contains(name); } }   Heres where I attach/register: @Mod.EventBusSubscriber(modid = Main.MODID) public class CapabilityEvents { @SubscribeEvent public static void attachCapability(AttachCapabilitiesEvent<LevelChunk> event){ ChunkCapProvider provider = new ChunkCapProvider(); event.addCapability(ChunkCapability.ID, provider); event.addListener(provider::invalidate); } }  
    • Id use this ServerLevel#findNearestMapFeature  
    • Trying to play with the mods: Tinkers Construct, Buildcraft and the Blood Magic addon Blood Arsenal; the game crashes. I noticed that when trying to use only two of the three in any combination the game opens without problems, but when trying to put all three together the error occurs. Is there any configuration I can modify or any other way to solve the problem?   ---- Minecraft Crash Report ---- // Hi. I'm Minecraft, and I'm a crashaholic. Time: 5/22/24 8:48 PM Description: There was a severe problem during mod loading that has caused the game to fail cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: tconstruct/library/weaponry/AmmoWeapon     at cpw.mods.fml.common.LoadController.transition(LoadController.java:163)     at cpw.mods.fml.common.Loader.loadMods(Loader.java:544)     at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208)     at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:480)     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:878)     at net.minecraft.client.main.Main.main(SourceFile:148)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) Caused by: java.lang.NoClassDefFoundError: tconstruct/library/weaponry/AmmoWeapon     at java.lang.Class.forName0(Native Method)     at java.lang.Class.forName(Unknown Source)     at cpw.mods.fml.common.ProxyInjector.inject(ProxyInjector.java:42)     at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:512)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)     at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)     at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)     at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)     at com.google.common.eventbus.EventBus.post(EventBus.java:275)     at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)     at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)     at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)     at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)     at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)     at com.google.common.eventbus.EventBus.post(EventBus.java:275)     at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)     at cpw.mods.fml.common.Loader.loadMods(Loader.java:513)     ... 10 more Caused by: java.lang.ClassNotFoundException: tconstruct.library.weaponry.AmmoWeapon     at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)     at java.lang.ClassLoader.loadClass(Unknown Source)     at java.lang.ClassLoader.loadClass(Unknown Source)     ... 36 more Caused by: java.lang.NoClassDefFoundError: tconstruct/library/weaponry/AmmoItem     at java.lang.ClassLoader.defineClass1(Native Method)     at java.lang.ClassLoader.defineClass(Unknown Source)     at java.security.SecureClassLoader.defineClass(Unknown Source)     at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182)     ... 38 more Caused by: java.lang.ClassNotFoundException: tconstruct.library.weaponry.AmmoItem     at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:101)     at java.lang.ClassLoader.loadClass(Unknown Source)     at java.lang.ClassLoader.loadClass(Unknown Source)     ... 42 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:     Minecraft Version: 1.7.10     Operating System: Windows 10 (x86) version 10.0     Java Version: 1.8.0_411, Oracle Corporation     Java VM Version: Java HotSpot(TM) Client VM (mixed mode, sharing), Oracle Corporation     Memory: 271923192 bytes (259 MB) / 402653184 bytes (384 MB) up to 536870912 bytes (512 MB)     JVM Flags: 9 total; -Xmx512M -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -XX:+IgnoreUnrecognizedVMOptions -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump     AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used     IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0     FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 14 mods loaded, 14 mods active     States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored     UC    mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)      UC    FML{7.10.99.99} [Forge Mod Loader] (forge-1.7.10-10.13.4.1614-1.7.10.jar)      UC    Forge{10.13.4.1614} [Minecraft Forge] (forge-1.7.10-10.13.4.1614-1.7.10.jar)      UC    AWWayofTime{v1.3.3} [Blood Magic: Alchemical Wizardry] (BloodMagic-1.7.10-1.3.3-17.jar)      UC    Mantle{1.7.10-0.3.2.jenkins191} [Mantle] (Mantle-1.7.10-0.3.2b.jar)      UE    TConstruct{1.7.10-1.8.8.build991} [Tinkers' Construct] (TConstruct-1.7.10-1.8.8.build991.jar)      UC    BloodArsenal{1.2-5} [Blood Arsenal] (BloodArsenal-1.7.10-1.2-5.jar)      UC    BuildCraft|Core{7.1.25} [BuildCraft] (buildcraft-7.1.25.jar)      UC    BuildCraft|Builders{7.1.25} [BC Builders] (buildcraft-7.1.25.jar)      UC    BuildCraft|Robotics{7.1.25} [BC Robotics] (buildcraft-7.1.25.jar)      UC    BuildCraft|Silicon{7.1.25} [BC Silicon] (buildcraft-7.1.25.jar)      UC    BuildCraft|Energy{7.1.25} [BC Energy] (buildcraft-7.1.25.jar)      UC    BuildCraft|Transport{7.1.25} [BC Transport] (buildcraft-7.1.25.jar)      UC    BuildCraft|Factory{7.1.25} [BC Factory] (buildcraft-7.1.25.jar)      GL info: ' Vendor: 'Intel' Version: '4.4.0 - Build 21.20.16.4541' Renderer: 'Intel(R) HD Graphics 610'     Mantle Environment: Environment healthy.     TConstruct Environment: Environment healthy.
    • fixed this problem but now i have a new one  java.lang.RuntimeException: java.lang.NoSuchFieldException: processor  Help 
  • Topics

×
×
  • Create New...

Important Information

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