Seperate Campfire into lit and unlit blockstates
Exsolutus opened this issue ยท 17 comments
Currently, the campfire only has a single blockstate. For integration with mods such as Tough As Nails, which accept blocks for heat sources in their configs, this is suboptimal. In this particular example, even an unlit campfire would be considered a heat source.
By separating the campfire into lit and unlit blockstates (similar to the furnace), the desired behavior can be achieved by adding only the lit blockstate to the heat source configs of other mods.
Having updated, I am still unable to achieve the desired behavior. Below is the TAN config I currently have, based on our discussion so far. Perhaps I've done this incorrectly?
{
"state": {
"block": "pyrotech:campfire",
"properties": {
"variant": "lit"
}
},
"temperature": 5.0
}
I've done a little digging in the source for TAN. Below, I've linked the file containing the code which checks for a matching blockstate.
The applyEnvironmentModifiers
method uses world.getBlockState
, and then calls getBlockTemperature
to compare the state to the config.
I took a cursory look at the TaN code and nothing jumped out at me. I'm not sure why it isn't working.
Have you spoken to the TaN devs about it?
Does the TaN feature work correctly if you use another block? For example a log with a particular direction:
{
"variants": {
"axis=y": { "model": "jungle_log" },
"axis=z": { "model": "jungle_log", "x": 90 },
"axis=x": { "model": "jungle_log", "x": 90, "y": 90 },
"axis=none": { "model": "jungle_bark" }
}
}
The following TaN config snippet works as expected.
{
"state": {
"block": "minecraft:log",
"properties": {
"variant": "oak",
"axis": "y"
}
},
"temperature": 5.0
}
I should also note that for the campfire, I have tried detecting both normal and lit states. Neither works. To be specific, if "properties" contains a line for "variant", the campfire isn't matched at all. My intuition would be that the blockstate doesn't contain the "variant" property correctly, but F3 shows the expected values when looking at the campfire.
Does this snippet work?
{
"state": {
"block": "minecraft:log",
"properties": {
"variant": "oak"
}
},
"temperature": 5.0
}
TaN has been discontinued, I haven't contacted their team.
And yes, the snippet you provided works as expected.
I've found the problem. TaN is assuming that the variant name is the same as the enum name.
This one works:
{
"state": {
"block": "pyrotech:campfire",
"properties": {
"variant": "LIT"
}
},
"temperature": 300.0
}
The campfire has these blockstates:
NORMAL(0, "normal"),
LIT(1, "lit"),
ASH(2, "ash"),
ITEM(3, "item");
... and it only counts as a fire source if lit:
@Override
public boolean isFireSource(World world, BlockPos pos, EnumFacing side) {
return (this.getActualState(world.getBlockState(pos), world, pos).getValue(VARIANT) == BlockCampfire.EnumType.LIT);
}
I think I see what the problem is, the campfire doesn't really ever switch blockstates when lit, only when getActualState
is called is the lit state applied.
TaN probably doesn't use getActualState
or the fire source method.
I was using the CraftTweaker command when looking at the campfire, which always showed pyrotech:campfire regardless of the campfire's apparent state. Now that I'm looking at it with F3, I see the states you listed above as "variant"
An example of the TaN configuration:
{
"state": {
"block": "toughasnails:campfire",
"properties": {
"burning": "true"
}
},
"temperature": 5.0
}
I will try to set up a config for the Pyrotech campfire with the variant as a property. It's possible no changes on your end are needed in this case.
Unfortunately, no such luck. The TaN campfire uses blockstate properties similar to the Pyrotech campfire. However, it appears the blockstate is updated when the campfire is lit. As you mentioned, the Pyrotech campfire does not. TaN probably needs that blockstate update.
That's ridiculous! Thanks a lot for this fix, you're my hero!