Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.10.2] [SOLVED] Problems with Player's Display name


Tschipp
 Share

Recommended Posts

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Well, try that first then before I go through the trouble of debugging it on my machine...

Well, apparently that really was all it took O.o

It works fine now! Thank you so much!

I added the working version to github, in case I still find a bug...

Link to comment
Share on other sites

Welp, here I am again.

I found out the mod crashes servers instantly...  ::)

I'm pretty sure it's because of this here in my main mod class:

@SidedProxy(clientSide = CLIENT_PROXY, serverSide = COMMON_PROXY)
public static ClientProxy clientProxy;

 

In any case,here is the log: http://pastebin.com/xvTbWXQN

I have since removed it, but now there's an error in my PacketHandler class:

				EntityPlayer toSync = (EntityPlayer)FakeName.[color=red]clientProxy[/color].getClientWorld().getEntityByID(message.entityId);

 

So I changed it to this:

				EntityPlayer toSync = (EntityPlayer)FakeName.proxy.getClientWorld().getEntityByID(message.entityId);

 

but now it's erroring at getClientWorld(), because that is a method in my ClientProxy class.

Here it is:

package tschipp.fakename;

import net.minecraft.client.Minecraft;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

public class ClientProxy extends CommonProxy {

public void preInit(FMLPreInitializationEvent event) {

	super.preInit(event);



	}

	public void init(FMLInitializationEvent event) {

		super.init(event);

	}

	public void postInit(FMLPostInitializationEvent event) {

		super.postInit(event);

	}


	public World getClientWorld() 
	{
		return Minecraft.getMinecraft().theWorld;
	}

}


 

The problem now is, how do I get access to the getClientWorld method from my PacketHandler class?

Link to comment
Share on other sites

I'm pretty sure it's because of this here in my main mod class:

@SidedProxy(clientSide = CLIENT_PROXY, serverSide = COMMON_PROXY)
public static ClientProxy clientProxy;

 

Attempted to load a proxy type tschipp.fakename.CommonProxy into tschipp.fakename.FakeName.clientProxy, but the types don't match

 

You have to type your proxy as being a CommonProxy.

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/OresBase.java#L88

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.

Link to comment
Share on other sites

You still can't do this:

@SidedProxy(clientSide = CLIENT_PROXY, serverSide = COMMON_PROXY)
public static ClientProxy clientProxy;

Because it will still try to load the common proxy into the variable which can only hold a client proxy.

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.

Link to comment
Share on other sites

Of course it does, I bet it's now crashing with a NullPointerException.

 

My question is, why do you have two proxy variables?

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.

Link to comment
Share on other sites

Of course it does, I bet it's now crashing with a NullPointerException.

 

My question is, why do you have two proxy variables?

Because I didn't know how else to access the getClientWorld() method from my client proxy.

How do I get the client proxy from my proxy variable?

Link to comment
Share on other sites

MainMod.proxy.getClientWorld();

 

This method will be in BOTH proxy classes.  That's the whole point of a proxy.  Look at all these deliciously empty methods that actually do something.

 

Your common proxy will return null.  Your client proxy will then do what it needs to.

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.

Link to comment
Share on other sites

MainMod.proxy.getClientWorld();

 

This method will be in BOTH proxy classes.  That's the whole point of a proxy.  Look at all these deliciously empty methods that actually do something.

 

Your common proxy will return null.  Your client proxy will then do what it needs to.

 

Ah I see, so I'll just add a empty method to my common proxy. Thanks!

Link to comment
Share on other sites

For  Tschipp's use-case, definitely.

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.

Link to comment
Share on other sites

Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/renderer/color/IItemColor

Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/color/IItemColor for invalid side SERVER

 

Your own blocks and items are trying to use IItemColor on the server:

tschipp/creativePlus/items/Wand

tschipp/buildingblocks/blocks/BlockGravelGrass

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.

Link to comment
Share on other sites

but why? There is nothing in my Common Proxy that would cause that...

package tschipp.creativePlus.Proxies;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import tschipp.creativePlus.items.CustomItems;

public class CommonProxy {

public void preInit(FMLPreInitializationEvent event) {
	CustomItems.createItems();
}

public void init(FMLInitializationEvent event) {

}

public void postInit(FMLPostInitializationEvent event) {

}

}

 

 

Client Proxy:

package tschipp.creativePlus.Proxies;

import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import tschipp.creativePlus.CreativePlus;
import tschipp.creativePlus.items.CircleWand;
import tschipp.creativePlus.items.CustomItems;
import tschipp.creativePlus.items.FloodFill;
import tschipp.creativePlus.items.ItemRenderRegister;
import tschipp.creativePlus.items.NoiseFill;
import tschipp.creativePlus.items.Wand;

public class ClientProxy extends CommonProxy{

public void preInit(FMLPreInitializationEvent event) {

super.preInit(event);



}

public void init(FMLInitializationEvent event) {

	super.init(event);

	ItemRenderRegister.registerItems();
	if(CreativePlus.enableNoiseWand) {
	FMLClientHandler.instance().getClient().getItemColors().registerItemColorHandler(new NoiseFill(), CustomItems.noiseFill);
	}

	if(CreativePlus.enableFillWand) {
	FMLClientHandler.instance().getClient().getItemColors().registerItemColorHandler(new FloodFill(), CustomItems.floodFill);
	}

	if(CreativePlus.enablePointWand) {
	FMLClientHandler.instance().getClient().getItemColors().registerItemColorHandler(new Wand(), CustomItems.wand);
	}

	if(CreativePlus.enableCircleWand) {
	FMLClientHandler.instance().getClient().getItemColors().registerItemColorHandler(new CircleWand(), CustomItems.circleWand);
	}

}

public void postInit(FMLPostInitializationEvent event) {

	super.postInit(event);

}



}

Link to comment
Share on other sites

but why? There is nothing in my Common Proxy that would cause that...

 

At what point did I ever say the word "proxy"?

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.

Link to comment
Share on other sites

Show these two classes:

tschipp/creativePlus/items/Wand

tschipp/buildingblocks/blocks/BlockGravelGrass

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.

Link to comment
Share on other sites

Wand:

package tschipp.creativePlus.items;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class Wand extends Item implements IItemColor{


public Vec3d pos1;
public Vec3d pos2;
public Vec3d difference;
public Vec3d posToPlaceBlock;



public IBlockState mat;

public Wand() {
	this.setMaxStackSize(1);

}

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> subItems)
{


	NBTTagCompound subTag = new NBTTagCompound();
	subTag.setString("material", "minecraft:stone");
	subTag.setInteger("damage", 0);
	subTag.setDouble("pos1x", 0);
	subTag.setDouble("pos1y", 0);
	subTag.setDouble("pos1z", 0);
	subTag.setDouble("pos2x", 0);
	subTag.setDouble("pos2y", 0);
	subTag.setDouble("pos2z", 0);
	subTag.setBoolean("hasSetPos1", false);
	subTag.setBoolean("hasSetPos2", false);
	ItemStack stack = new ItemStack(item, 1, 0);
	stack.setTagCompound(subTag);


	subItems.add(stack);
}

@Override
@SideOnly(Side.CLIENT)
public String getItemStackDisplayName(ItemStack stack)
{


	if(stack.getTagCompound() != null) {
		Block block = Block.getBlockFromName(stack.getTagCompound().getString("material"));
		IBlockState state = block.getStateFromMeta(stack.getTagCompound().getInteger("damage"));

		ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));

		return "Line Wand (" + blockStack.getDisplayName() +")";
		} else {
		return "" + I18n.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name");
	}

} 


@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
	{
		Block block = Block.getBlockFromName(stack.getTagCompound().getString("material"));
		IBlockState state = block.getStateFromMeta(stack.getTagCompound().getInteger("damage"));


		if(block.getMapColor(state).colorValue == 000) {
			System.out.println(block.getMapColor(state));
			return 201196;
		} else {

			return block.getMapColor(state).colorValue;
		}
	} 

}

@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{


	World world = player.worldObj;
	if(pos.getX() < 0) {
		pos2 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ());
	}
	if(pos.getX() > 0) {
		pos2 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ());
	}
	if(pos.getZ() < 0) {
		pos2 = new Vec3d(pos.getX(), pos.getY(), pos.getZ()-0.5);
	}
	if(pos.getX() > 0) {
		pos2 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5);
	}
	if(pos.getX() < 0 && pos.getZ() < 0) {
		pos2 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()-0.5);
	}
	if(pos.getX() > 0 && pos.getZ() > 0) {
		pos2 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()+0.5);
	}
	if(pos.getX() < 0 && pos.getZ() > 0) {
		pos2 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5);
	}
	if(pos.getX() > 0 && pos.getZ() < 0) {
		pos2 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()-0.5);
	}

	NBTTagCompound subTag = stack.getTagCompound();
	subTag.setDouble("pos2x", pos2.xCoord);
	subTag.setDouble("pos2y", pos2.yCoord);
	subTag.setDouble("pos2z", pos2.zCoord);
	subTag.setBoolean("hasSetPos2", true);
	stack.setTagCompound(subTag);

	if(!world.isRemote) {
		player.addChatMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE + "Set Pos2 at X: " + (int)pos2.xCoord + ", Y: " + (int)pos2.yCoord + ", Z: " + (int)pos2.zCoord));
	}
	world.scheduleBlockUpdate(pos, world.getBlockState(pos).getBlock(), 0, 1);
	return EnumActionResult.PASS;
}


@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer playerIn, EnumHand hand)
{


	if(stack.getTagCompound().getBoolean("hasSetPos1") && stack.getTagCompound().getBoolean("hasSetPos2") && playerIn.isSneaking()) {

		NBTTagCompound nbt = stack.getTagCompound();

		Vec3d setPos1 = new Vec3d(nbt.getDouble("pos1x"), nbt.getDouble("pos1y"), nbt.getDouble("pos1z"));
		Vec3d setPos2 = new Vec3d(nbt.getDouble("pos2x"), nbt.getDouble("pos2y"), nbt.getDouble("pos2z"));
		difference = setPos1.subtractReverse(setPos2).normalize();
		posToPlaceBlock = setPos1;

		if(setPos1.xCoord > 0 && setPos2.xCoord < 0 || setPos1.xCoord < 0 && setPos2.xCoord > 0 || setPos1.zCoord > 0 && setPos2.zCoord < 0 || setPos1.zCoord < 0 && setPos2.zCoord > 0 || setPos1.yCoord > 256 || setPos2.yCoord > 256 || setPos1.yCoord < 0 || setPos2.yCoord < 0) {
			if(!world.isRemote) {
				playerIn.addChatComponentMessage(new TextComponentString(TextFormatting.RED +"Don't try to create lines from positive X to negative X, Z, or Y"));
			}
		} else {

			if(compare(setPos1, setPos2)) {
				pos1 = null;
				if(!world.isRemote) {
					world.setBlockState(new BlockPos((int)setPos1.xCoord, (int)setPos1.yCoord, (int)setPos1.zCoord), Block.getBlockFromName(stack.getTagCompound().getString("material")).getStateFromMeta(stack.getTagCompound().getInteger("damage")), 2);
					BlockPos pos2 = new BlockPos((int)setPos1.xCoord, (int)setPos1.yCoord, (int)setPos1.zCoord);
					world.scheduleBlockUpdate(pos2, world.getBlockState(pos2).getBlock(), 0, 1);
				}
				pos2 = null;
			} else {
				while (!compare(setPos1, setPos2))
				{

					posToPlaceBlock = posToPlaceBlock.add(difference);
					if(!world.isRemote) {
						world.setBlockState(new BlockPos((int)posToPlaceBlock.xCoord, (int)posToPlaceBlock.yCoord, (int)posToPlaceBlock.zCoord),  Block.getBlockFromName(stack.getTagCompound().getString("material")).getStateFromMeta(stack.getTagCompound().getInteger("damage")), 2);
					}

				} 
			}

		}


	}
	return new ActionResult(EnumActionResult.SUCCESS, stack);
}

public boolean compare(Vec3d setPos1, Vec3d setPos2) {

	if(Math.abs(setPos1.xCoord) <= Math.abs(setPos2.xCoord) && Math.abs(setPos1.zCoord) <= Math.abs(setPos2.zCoord)) {
		return Math.abs(posToPlaceBlock.xCoord) >= Math.abs(setPos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) >= Math.abs(setPos2.zCoord);
	} 
	else if(Math.abs(setPos1.xCoord) >= Math.abs(setPos2.xCoord) && Math.abs(setPos1.zCoord) >= Math.abs(setPos2.zCoord)) {
		return Math.abs(posToPlaceBlock.xCoord) <= Math.abs(setPos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) <= Math.abs(setPos2.zCoord);
	} 
	else if(Math.abs(setPos1.xCoord) <= Math.abs(setPos2.xCoord) && Math.abs(setPos1.zCoord) >= Math.abs(setPos2.zCoord)) {
		return Math.abs(posToPlaceBlock.xCoord) >= Math.abs(setPos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) <= Math.abs(setPos2.zCoord);
	} 
	else if(Math.abs(setPos1.xCoord) >= Math.abs(setPos2.xCoord) && Math.abs(setPos1.zCoord) <= Math.abs(setPos2.zCoord)) {
		return Math.abs(posToPlaceBlock.xCoord) <= Math.abs(setPos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) >= Math.abs(setPos2.zCoord);
	}
	else {
		return true;
	}
}



/*	public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player)
{

	World world = player.worldObj;

	if(player.isSneaking()) {

		mat = world.getBlockState(pos);
		NBTTagCompound subTag = itemstack.getTagCompound();

		subTag.setString("material", mat.getBlock().getRegistryName().getResourceDomain() + ":" + mat.getBlock().getRegistryName().getResourcePath());
		subTag.setInteger("damage", mat.getBlock().getMetaFromState(mat));

		Block block = (Block)Block.REGISTRY.getObject(new ResourceLocation(itemstack.getTagCompound().getString("material")));

		itemstack.setTagCompound(subTag);
		if(!world.isRemote) {
			player.addChatComponentMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE +"Material set to: " + net.minecraft.util.text.translation.I18n.translateToLocal(net.minecraft.util.text.translation.I18n.translateToLocal(block.getLocalizedName()))));
		}
		world.scheduleBlockUpdate(pos, world.getBlockState(pos).getBlock(), 0, 1);
	}
	else {
		if(pos.getX() < 0) {
			pos1 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ());
		}
		if(pos.getX() > 0) {
			pos1 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ());
		}
		if(pos.getZ() < 0) {
			pos1 = new Vec3d(pos.getX(), pos.getY(), pos.getZ()-0.5);
		}
		if(pos.getX() > 0) {
			pos1 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5);
		}
		if(pos.getX() < 0 && pos.getZ() < 0) {
			pos1 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()-0.5);
		}
		if(pos.getX() > 0 && pos.getZ() > 0) {
			pos1 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()+0.5);
		}
		if(pos.getX() < 0 && pos.getZ() > 0) {
			pos1 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5);
		}
		if(pos.getX() > 0 && pos.getZ() < 0) {
			pos1 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()-0.5);
		}

		NBTTagCompound subTag = itemstack.getTagCompound();
		subTag.setDouble("pos1x", pos1.xCoord);
		subTag.setDouble("pos1y", pos1.yCoord);
		subTag.setDouble("pos1z", pos1.zCoord);
		subTag.setBoolean("hasSetPos1", true);
		itemstack.setTagCompound(subTag);

		if(!world.isRemote) {
			player.addChatComponentMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE +"Set Pos1 at X: " + (int)pos1.xCoord + ", Y: " + (int)pos1.yCoord + ", Z: " + (int)pos1.zCoord));
		}
		world.scheduleBlockUpdate(pos, world.getBlockState(pos).getBlock(), 0, 1);

	}

	return true;
}

 */

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
	Block block = Block.getBlockFromName(stack.getTagCompound().getString("material"));
	IBlockState state = block.getStateFromMeta(stack.getTagCompound().getInteger("damage"));
	ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));


	tooltip.add("Draws a straight line from two points");
	tooltip.add("Material: " + blockStack.getDisplayName());
	tooltip.add("Pos1 = X: " + stack.getTagCompound().getDouble("pos1x") + ", Y: " + stack.getTagCompound().getDouble("pos1y") + ", Z: " + stack.getTagCompound().getDouble("pos1z"));
	tooltip.add("Pos2 = X: " + stack.getTagCompound().getDouble("pos2x") + ", Y: " + stack.getTagCompound().getDouble("pos2y") + ", Z: " + stack.getTagCompound().getDouble("pos2z"));

}


}

 

 

BlockGravelGrass:

package tschipp.buildingblocks.blocks;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Nullable;

import tschipp.buildingblocks.BBMod;
import tschipp.buildingblocks.items.BBItems;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
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 BlockGravelGrass extends Block implements IBlockColor {

public BlockGravelGrass(Material materialIn)
{
	super(materialIn, MapColor.STONE);
	this.blockHardness = 0.8F;
	this.blockResistance = 3.5F;
	this.setSoundType(SoundType.PLANT);
	this.setUnlocalizedName("gravelGrass");
	this.setCreativeTab(BBMod.buildingBlocks);
	this.setHarvestLevel("shovel", 0);
}

@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{			
	return 0;
}



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

@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable)
{
	return true;
}


@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
	List<ItemStack> drops = new ArrayList<ItemStack>();
	drops.add(new ItemStack(Blocks.DIRT, 1));
	drops.add(new ItemStack(BBItems.pebbles, 1));
	return drops;

}

}

Link to comment
Share on other sites

The JVM loads the interface

IItemColor

, since you implement it. ← Kaboom,

IItemColor

does not exist on a server.

So should I just not implement IItemColor? Are there other ways of adding a color to an item (and block)?

I would've guessed making getColorFromItemStack() SideOnly(Side.CLIENT) would be enough to fix this... I can't implement the interface client side only, right?

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
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.

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.