Pyrotech

Pyrotech

897k Downloads

Seperate Campfire into lit and unlit blockstates

Exsolutus opened this issue ยท 17 comments

commented

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.

commented

Thanks a lot

commented

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.

https://github.com/Glitchfiend/ToughAsNails/blob/TAN-1.12.x-3.x.x/src/main/java/toughasnails/temperature/modifier/ObjectProximityModifier.java

The applyEnvironmentModifiers method uses world.getBlockState, and then calls getBlockTemperature to compare the state to the config.

commented

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" }
    }
}
commented

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.

commented

Have you spoken to the TaN devs about it?

commented

Does this snippet work?

 {
    "state": {
    "block": "minecraft:log",
    "properties": {
		"variant": "oak"
	  }
    },
    "temperature": 5.0
  }
commented

TaN has been discontinued, I haven't contacted their team.

And yes, the snippet you provided works as expected.

commented

The following snip works:

  {
    "state": {
      "block": "pyrotech:campfire",
      "properties": {}
    },
    "temperature": 300.0
  }

image

The following snip does not work:

  {
    "state": {
      "block": "pyrotech:campfire",
      "properties": {
        "variant": "lit"
      }
    },
    "temperature": 300.0
  }

image

commented

@Exsolutus

I've found the problem. TaN is assuming that the variant name is the same as the enum name.

https://github.com/Glitchfiend/ToughAsNails/blob/TAN-1.12.x-3.x.x/src/main/java/toughasnails/util/BlockStateUtils.java#L121

image

This one works:

  {
    "state": {
      "block": "pyrotech:campfire",
      "properties": {
        "variant": "LIT"
      }
    },
    "temperature": 300.0
  }

image

commented

Excellent! Thanks a bunch for all your help on this.

commented

The campfire has these blockstates:

    NORMAL(0, "normal"),
    LIT(1, "lit"),
    ASH(2, "ash"),
    ITEM(3, "item");
commented

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

commented

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.

commented

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.

commented

Ah, ok, well I'll look into this in the future. Thanks for the report!

commented

Changed in 1.4.0

commented

@codetaylor

That's ridiculous! Thanks a lot for this fix, you're my hero!