SeptemberBlue
Members-
Posts
49 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
SeptemberBlue's Achievements
Tree Puncher (2/8)
0
Reputation
-
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
Before I attempt block states, is there another approach I could do? As in, refresh the block so it does the event again? EDIT: one other issue I just realized. I'll need to set the item colour, but I'm not sure how I'd go from ItemStack to TileEntity. -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
So wait, do I add that to my BlockState json? How would that not do anything? I was thinking I'd add an if statement to the readNBT part that checks if the colour changed, and if it did, call the event to change accordingly. Or are you saying that if I did try to call the event, nothing would happen? -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
Ok, I've fixed up the code so that the colour does change now, but the block does not actually change colour. Is there some way I can call the event every time the color gets updated? -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
Alright, it seems to be picking the color of the block, which is good. What's weird though is that I can't change the color. I've used blockdata to try change the color value to something else, but when I check the block again, the color value reset. the class: public class TileEntityCanvas extends TileEntity { private int color; public TileEntityCanvas() { } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("color", color); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); } public int getColor() { return color; } public void setColor (int c) { color=c; } } EDIT: Pretty sure this has to do with the writeToNBT, will add an if statement to check if the "color" value changed. Looking for a method that gets an NBT value. EDIT 2: @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); if (!compound.hasKey("color") || compound.getInteger("color") != color) compound.setInteger("color", color); return compound; } For some reason, the color variable still won't change. -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
Done. My basic understanding of them so far is that you give them the parameters of a function, and then on the other side give it a return value. Will read up on them more though. @Nullable TileEntity getTileEntity(BlockPos pos); Not when it looks like this (from IBlockAccess). EDIT: DAMMIT, never thought to use the arguments from the method. I might be able to solve my own problem here. -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
Before I attempt any of the above, my TileEntity's color variable is private. Should I make a get method, or should I use some preexisting method? As for what you've said, I'm not entirely sure how to go about it. I see that IBlockAccess has a getTileEntity() method, and that takes a BlockPos. I don't really know how I'm supposed to put those together though. Can I use a lambda expression for IBlockAccess, even if it has other methods? -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
Sweet, set up the lambda expression, gave it a colour, and now everything works fine! Only issue now is that I want the colour to be set based on the NBT tag of the block, since I made it a tile entity with a color tag. How would I access the tag? -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
I was trying to follow what he said, which would mean that it's not a correct lambda expression. Good to know. -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
I'm still not clear which part exactly is wrong. Am I supposed to create a class that implements the interface? Should I give its method the correct arguments? Or is creating an instance not the same as initializing? -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
new IBlockColor.colorMultiplier(0,0,0,0) How is this not a new instance? -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
@SubscribeEvent public static void registerBlockColors(final ColorHandlerEvent.Block event) { event.getBlockColors().registerBlockColorHandler(new IBlockColor.colorMultiplier(0,0,0,0), ModBlocks.CANVAS); } So how do I register this interface? -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
@SideOnly(Side.CLIENT) public interface IBlockColor { int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex); } The method takes an IBlockState, an IBlockAccess, a BlockPos, and an int. I'm going to set the tintIndex to 0, since that corresponds with the json files. As for the other three, I'm probably going to want the IBlockState, IBlockAccess, and BlockPos for all blocks that need to be coloured (canvas blocks in this case) -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
Alright, so for the interface, it needs an IBlockState, IBlockAccess, and a BlockPos (also needs an int but that's easy). Are there any methods that I can call for these? -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
(First off thanks for the documentation!) As for the other two points, I have this so far: @SubscribeEvent public static void registerBlockColors(final ColorHandlerEvent.Block event) { event.getBlockColors().registerBlockColorHandler(blockColor, ModBlocks.CANVAS); } I'm going to replace blockColor. Since IBlockColor is an interface, do I need to make a class that implements it? -
[1.12.2] Unsure of how to create colour overlay for block.
SeptemberBlue replied to SeptemberBlue's topic in Modder Support
I'm not entirely sure how I'd do this. I see that I have code like this: @SubscribeEvent public static void onBlockRegister(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0])); } So I'm guessing I'd do something similar. Is this on the right track, or do I have this all wrong? Also, anything I should look at to get a better understanding of what you mean? EDIT: I've found this topic here. I know it's for a later version, but I'm assuming it'll also work for 1.12.2. Looking at their solution there, I have two questions. First off, what does the register method take? I was guessing the variable for the block plus an int for the colour, but that didn't seem to work. Also where can I find the main event bus? Is it that init thing? EDIT 2: IBlockColor doesn't seem to exist. Do I have to create it?