I'm making a Technology Mod and I want to be able to dye the Monitor. I use Mr Crayfish's Furniture Mod's source code as a reference. I'm following his Bar Stool code, and the onBlockActivated doesn't use a return statement. Here's my code:
public static final PropertyInteger COLOR = PropertyInteger.create("color", 0, 15);
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public BlockMonitor(Material materialIn) {
super(materialIn);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(COLOR, Integer.valueOf(0)));
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube()
{
return false;
}
Return false from onBlockActivated if there was no effect from the right click.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I noticed you haven't overridden Block#getStateFromMeta, which may cause issues.
You're also ignoring the colour when converting from state to metadata. You can't store both the facing and the colour in the metadata since you're limited to 4 bits (16 possible values).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I noticed you haven't overridden Block#getStateFromMeta, which may cause issues.
You're also ignoring the colour when converting from state to metadata. You can't store both the facing and the colour in the metadata since you're limited to 4 bits (16 possible values).
Here is my new code: http://pastebin.com/aFm6qEET Where do I put the COLOR variable then if it can't go with FACING?
I overode getStateFromMeta, and I figured out whats wrong. The ((EnumFacing) state.getValue(FACING)).getHorizontalIndex(); won't go with return ((Integer) state.getValue(COLOR)).intValue();. If I remove the ((EnumFacing) state.getValue(FACING)).getHorizontalIndex(); The dying works, but it won't be rotatable.
I overode getStateFromMeta, and I figured out whats wrong. The ((EnumFacing) state.getValue(FACING)).getHorizontalIndex(); won't go with return ((Integer) state.getValue(COLOR)).intValue();. If I remove the ((EnumFacing) state.getValue(FACING)).getHorizontalIndex(); The dying works, but it won't be rotatable.
Don't bump threads. It often takes a while to compose a reply.
You either need to reduce the possible number of states to 16 (remove the facing or reduce the number of colours) or store some of the data in a TileEntity (this will be difficult to implement properly if you're new).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I'm making a Technology Mod and I want to be able to dye the Monitor. I use Mr Crayfish's Furniture Mod's source code as a reference. I'm following his Bar Stool code, and the onBlockActivated doesn't use a return statement. Here's my code:
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockMonitor extends Block{
public static final PropertyInteger COLOR = PropertyInteger.create("color", 0, 15);
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public BlockMonitor(Material materialIn) {
super(materialIn);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(COLOR, Integer.valueOf(0)));
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube()
{
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){
ItemStack currentItem = player.getCurrentEquippedItem();
if (currentItem != null){
if (currentItem.getItem() instanceof ItemDye){
world.setBlockState(pos, state.withProperty(COLOR, 15 - currentItem.getItemDamage()));
if (!player.capabilities.isCreativeMode)
currentItem.stackSize--;
return true;
}
}
}
@Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
IBlockState state = super.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, meta, placer);
state = state.withProperty(FACING, placer.getHorizontalFacing());
return state.withProperty(COLOR, Integer.valueOf(0));
}
@Override
public int getMetaFromState(IBlockState state)
{
return ((EnumFacing) state.getValue(FACING)).getHorizontalIndex();
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { FACING, COLOR });
}
}
Can anyone help? If so, it would be greatly appreciated!
Return false from onBlockActivated if there was no effect from the right click.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
This didn't work.
It takes my dye when I take out if (!player.capabilities.isCreativeMode) but that's it. Here's my block state:
{
"variants": {
"color=0,facing=north": { "model": "btech:monitor_white" },
"color=0,facing=east": { "model": "btech:monitor_white", "y": 90 },
"color=0,facing=south": { "model": "btech:monitor_white", "y": 180 },
"color=0,facing=west": { "model": "btech:monitor_white", "y": 270 },
"color=1,facing=north": { "model": "btech:monitor_orange" },
"color=1,facing=east": { "model": "btech:monitor_orange", "y": 90 },
"color=1,facing=south": { "model": "btech:monitor_orange", "y": 180 },
"color=1,facing=west": { "model": "btech:monitor_orange", "y": 270 },
"color=2,facing=north": { "model": "btech:monitor_magenta" },
"color=2,facing=east": { "model": "btech:monitor_magenta", "y": 90 },
"color=2,facing=south": { "model": "btech:monitor_magenta", "y": 180 },
"color=2,facing=west": { "model": "btech:monitor_magenta", "y": 270 },
"color=3,facing=north": { "model": "btech:monitor_light_blue" },
"color=3,facing=east": { "model": "btech:monitor_light_blue", "y": 90 },
"color=3,facing=south": { "model": "btech:monitor_light_blue", "y": 180 },
"color=3,facing=west": { "model": "btech:monitor_light_blue", "y": 270 },
"color=4,facing=north": { "model": "btech:monitor_yellow" },
"color=4,facing=east": { "model": "btech:monitor_yellow", "y": 90 },
"color=4,facing=south": { "model": "btech:monitor_yellow", "y": 180 },
"color=4,facing=west": { "model": "btech:monitor_yellow", "y": 270 },
"color=5,facing=north": { "model": "btech:monitor_lime" },
"color=5,facing=east": { "model": "btech:monitor_lime", "y": 90 },
"color=5,facing=south": { "model": "btech:monitor_lime", "y": 180 },
"color=5,facing=west": { "model": "btech:monitor_lime", "y": 270 },
"color=6,facing=north": { "model": "btech:monitor_pink" },
"color=6,facing=east": { "model": "btech:monitor_pink", "y": 90 },
"color=6,facing=south": { "model": "btech:monitor_pink", "y": 180 },
"color=6,facing=west": { "model": "btech:monitor_pink", "y": 270 },
"color=7,facing=north": { "model": "btech:monitor_gray" },
"color=7,facing=east": { "model": "btech:monitor_gray", "y": 90 },
"color=7,facing=south": { "model": "btech:monitor_gray", "y": 180 },
"color=7,facing=west": { "model": "btech:monitor_gray", "y": 270 },
"color=8,facing=north": { "model": "btech:monitor_silver" },
"color=8,facing=east": { "model": "btech:monitor_silver", "y": 90 },
"color=8,facing=south": { "model": "btech:monitor_silver", "y": 180 },
"color=8,facing=west": { "model": "btech:monitor_silver", "y": 270 },
"color=9,facing=north": { "model": "btech:monitor_cyan" },
"color=9,facing=east": { "model": "btech:monitor_cyan", "y": 90 },
"color=9,facing=south": { "model": "btech:monitor_cyan", "y": 180 },
"color=9,facing=west": { "model": "btech:monitor_cyan", "y": 270 },
"color=10,facing=north": { "model": "btech:monitor_purple" },
"color=10,facing=east": { "model": "btech:monitor_purple", "y": 90 },
"color=10,facing=south": { "model": "btech:monitor_purple", "y": 180 },
"color=10,facing=west": { "model": "btech:monitor_purple", "y": 270 },
"color=11,facing=north": { "model": "btech:monitor_blue" },
"color=11,facing=east": { "model": "btech:monitor_blue", "y": 90 },
"color=11,facing=south": { "model": "btech:monitor_blue", "y": 180 },
"color=11,facing=west": { "model": "btech:monitor_blue", "y": 270 },
"color=12,facing=north": { "model": "btech:monitor_brown" },
"color=12,facing=east": { "model": "btech:monitor_brown", "y": 90 },
"color=12,facing=south": { "model": "btech:monitor_brown", "y": 180 },
"color=12,facing=west": { "model": "btech:monitor_brown", "y": 270 },
"color=13,facing=north": { "model": "btech:monitor_green" },
"color=13,facing=east": { "model": "btech:monitor_green", "y": 90 },
"color=13,facing=south": { "model": "btech:monitor_green", "y": 180 },
"color=13,facing=west": { "model": "btech:monitor_green", "y": 270 },
"color=14,facing=north": { "model": "btech:monitor_red" },
"color=14,facing=east": { "model": "btech:monitor_red", "y": 90 },
"color=14,facing=south": { "model": "btech:monitor_red", "y": 180 },
"color=14,facing=west": { "model": "btech:monitor_red", "y": 270 },
"color=15,facing=north": { "model": "btech:monitor_black" },
"color=15,facing=east": { "model": "btech:monitor_black", "y": 90 },
"color=15,facing=south": { "model": "btech:monitor_black", "y": 180 },
"color=15,facing=west": { "model": "btech:monitor_black", "y": 270 }
}
}
.
Post your new code on Gist or Pastebin.
I noticed you haven't overridden Block#getStateFromMeta, which may cause issues.
You're also ignoring the colour when converting from state to metadata. You can't store both the facing and the colour in the metadata since you're limited to 4 bits (16 possible values).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
You're not putting it as the default return statement then.I suggest for you to learn more Java since you don't know this.Here is my new code: http://pastebin.com/aFm6qEET Where do I put the COLOR variable then if it can't go with FACING?
I overode getStateFromMeta, and I figured out whats wrong. The ((EnumFacing) state.getValue(FACING)).getHorizontalIndex(); won't go with return ((Integer) state.getValue(COLOR)).intValue();. If I remove the ((EnumFacing) state.getValue(FACING)).getHorizontalIndex(); The dying works, but it won't be rotatable.
Can you help?
Don't bump threads. It often takes a while to compose a reply.
You either need to reduce the possible number of states to 16 (remove the facing or reduce the number of colours) or store some of the data in a TileEntity (this will be difficult to implement properly if you're new).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.