-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
446 additions
and
2 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
common/src/main/java/dev/architectury/registry/level/block/BlockFlammabilityRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* This file is part of architectury. | ||
* Copyright (C) 2020, 2021, 2022 architectury | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package dev.architectury.registry.level.block; | ||
|
||
import dev.architectury.injectables.annotations.ExpectPlatform; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
public final class BlockFlammabilityRegistry { | ||
/** | ||
* Gets the burn odds for the given block. | ||
* | ||
* @param level the level | ||
* @param state the block state | ||
* @param pos the position of the block | ||
* @param direction the direction of where the fire is coming from | ||
* @return the burn odds | ||
*/ | ||
@ExpectPlatform | ||
public static int getBurnOdds(BlockGetter level, BlockState state, BlockPos pos, Direction direction) { | ||
throw new AssertionError(); | ||
} | ||
|
||
/** | ||
* Gets the flame odds for the given block. | ||
* | ||
* @param level the level | ||
* @param state the block state | ||
* @param pos the position of the block | ||
* @param direction the direction of where the fire is spreading from | ||
* @return the flame odds | ||
*/ | ||
@ExpectPlatform | ||
public static int getFlameOdds(BlockGetter level, BlockState state, BlockPos pos, Direction direction) { | ||
throw new AssertionError(); | ||
} | ||
|
||
/** | ||
* Registers the flammability for the given blocks for all fire blocks. | ||
* | ||
* @param burnOdds the burn odds | ||
* @param flameOdds the flame odds | ||
* @param flammableBlocks the flammable blocks | ||
*/ | ||
@ExpectPlatform | ||
public static void registerAll(int burnOdds, int flameOdds, Block... flammableBlocks) { | ||
throw new AssertionError(); | ||
} | ||
|
||
/** | ||
* Registers the flammability for a given block tag for all fire blocks. | ||
* | ||
* @param burnOdds the burn odds | ||
* @param flameOdds the flame odds | ||
* @param flammableBlocks the flammable block tag | ||
*/ | ||
@ExpectPlatform | ||
public static void registerAll(int burnOdds, int flameOdds, TagKey<Block> flammableBlocks) { | ||
throw new AssertionError(); | ||
} | ||
|
||
/** | ||
* Registers the flammability for the given blocks for a given fire block. | ||
* | ||
* @param fireBlock the specific fire block | ||
* @param burnOdds the burn odds | ||
* @param flameOdds the flame odds | ||
* @param flammableBlocks the flammable blocks | ||
*/ | ||
@ExpectPlatform | ||
public static void register(Block fireBlock, int burnOdds, int flameOdds, Block... flammableBlocks) { | ||
throw new AssertionError(); | ||
} | ||
|
||
/** | ||
* Registers the flammability for a given block tag for a given fire block. | ||
* | ||
* @param fireBlock the specific fire block | ||
* @param burnOdds the burn odds | ||
* @param flameOdds the flame odds | ||
* @param flammableBlocks the flammable block tag | ||
*/ | ||
@ExpectPlatform | ||
public static void register(Block fireBlock, int burnOdds, int flameOdds, TagKey<Block> flammableBlocks) { | ||
throw new AssertionError(); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...main/java/dev/architectury/registry/level/block/fabric/BlockFlammabilityRegistryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* This file is part of architectury. | ||
* Copyright (C) 2020, 2021, 2022 architectury | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package dev.architectury.registry.level.block.fabric; | ||
|
||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.FireBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
public class BlockFlammabilityRegistryImpl { | ||
public static int getBurnOdds(BlockGetter level, BlockState state, BlockPos pos, Direction direction) { | ||
BlockState fireState = level.getBlockState(pos.relative(direction)); | ||
|
||
if (fireState.getBlock() instanceof FireBlock fireBlock) { | ||
FlammableBlockRegistry.Entry entry = FlammableBlockRegistry.getInstance(fireBlock).get(state.getBlock()); | ||
return entry.getBurnChance(); | ||
} else { | ||
FlammableBlockRegistry.Entry entry = FlammableBlockRegistry.getDefaultInstance().get(state.getBlock()); | ||
return entry.getBurnChance(); | ||
} | ||
} | ||
|
||
public static int getFlameOdds(BlockGetter level, BlockState state, BlockPos pos, Direction direction) { | ||
BlockState fireState = level.getBlockState(pos.relative(direction)); | ||
|
||
if (fireState.getBlock() instanceof FireBlock fireBlock) { | ||
FlammableBlockRegistry.Entry entry = FlammableBlockRegistry.getInstance(fireBlock).get(state.getBlock()); | ||
return entry.getSpreadChance(); | ||
} else { | ||
FlammableBlockRegistry.Entry entry = FlammableBlockRegistry.getDefaultInstance().get(state.getBlock()); | ||
return entry.getSpreadChance(); | ||
} | ||
} | ||
|
||
public static void registerAll(int burnOdds, int flameOdds, Block... flammableBlocks) { | ||
FlammableBlockRegistry registry = FlammableBlockRegistry.getDefaultInstance(); | ||
for (Block block : flammableBlocks) { | ||
registry.add(block, burnOdds, flameOdds); | ||
} | ||
} | ||
|
||
public static void registerAll(int burnOdds, int flameOdds, TagKey<Block> flammableBlocks) { | ||
FlammableBlockRegistry registry = FlammableBlockRegistry.getDefaultInstance(); | ||
registry.add(flammableBlocks, burnOdds, flameOdds); | ||
} | ||
|
||
public static void register(Block fireBlock, int burnOdds, int flameOdds, Block... flammableBlocks) { | ||
FlammableBlockRegistry registry = FlammableBlockRegistry.getInstance(fireBlock); | ||
for (Block block : flammableBlocks) { | ||
registry.add(block, burnOdds, flameOdds); | ||
} | ||
} | ||
|
||
public static void register(Block fireBlock, int burnOdds, int flameOdds, TagKey<Block> flammableBlocks) { | ||
FlammableBlockRegistry registry = FlammableBlockRegistry.getInstance(fireBlock); | ||
registry.add(flammableBlocks, burnOdds, flameOdds); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
forge/src/main/java/dev/architectury/mixin/forge/MixinIForgeBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* This file is part of architectury. | ||
* Copyright (C) 2020, 2021, 2022 architectury | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package dev.architectury.mixin.forge; | ||
|
||
import net.minecraftforge.common.extensions.IForgeBlock; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(IForgeBlock.class) | ||
public interface MixinIForgeBlock { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.