mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 20:22:28 +00:00
Add '#forge:chorus_additionally_grows_on' tag for similar mechanics to '#minecraft:azalea_grows_on' but for chorus (#10459)
This commit is contained in:
1 parent
c97eabc0c4
commit
b864faf0ef
8 files changed
+160
-4
No files matched your search
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"values": [
|
||||
"#forge:end_stones"
|
||||
]
|
||||
}
|
||||
@@ -55,6 +55,7 @@ public class Tags {
|
||||
|
||||
public static final TagKey<Block> CHESTS_ENDER = forgeTag("chests/ender");
|
||||
public static final TagKey<Block> CHESTS_TRAPPED = forgeTag("chests/trapped");
|
||||
public static final TagKey<Block> CHORUS_ADDITIONALLY_GROWS_ON = forgeTag("chorus_additionally_grows_on");
|
||||
public static final TagKey<Block> COBBLESTONE_NORMAL = forgeTag("cobblestone/normal");
|
||||
public static final TagKey<Block> COBBLESTONE_INFESTED = forgeTag("cobblestone/infested");
|
||||
public static final TagKey<Block> COBBLESTONE_MOSSY = forgeTag("cobblestone/mossy");
|
||||
|
||||
@@ -55,6 +55,8 @@ public final class ForgeBlockTagsProvider extends BlockTagsProvider {
|
||||
tag(CHESTS_WOODEN)
|
||||
.add(Blocks.CHEST, Blocks.TRAPPED_CHEST)
|
||||
.addOptionalTag(forgeTagKey("chests/wooden"));
|
||||
tag(CHORUS_ADDITIONALLY_GROWS_ON)
|
||||
.addTag(END_STONES);
|
||||
tag(CLUSTERS).add(Blocks.AMETHYST_CLUSTER);
|
||||
tag(COBBLESTONES)
|
||||
.addTags(COBBLESTONE_NORMAL, COBBLESTONE_INFESTED, COBBLESTONE_MOSSY, COBBLESTONE_DEEPSLATE)
|
||||
|
||||
@@ -196,22 +196,39 @@ public interface IForgeGameTestHelper {
|
||||
}
|
||||
|
||||
default void setAndAssertBlock(int x, int y, int z, Block block) {
|
||||
this.setAndAssertBlock(x, y, z, block.defaultBlockState());
|
||||
this.setAssertAndGetBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
default void setAndAssertBlock(int x, int y, int z, BlockState state) {
|
||||
this.setAndAssertBlock(new BlockPos(x, y, z), state);
|
||||
this.setAssertAndGetBlock(x, y, z, state);
|
||||
}
|
||||
|
||||
default void setAndAssertBlock(BlockPos pos, Block block) {
|
||||
this.setAndAssertBlock(pos, block.defaultBlockState());
|
||||
this.setAssertAndGetBlock(pos, block);
|
||||
}
|
||||
|
||||
default void setAndAssertBlock(BlockPos pos, BlockState state) {
|
||||
this.setAssertAndGetBlock(pos, state);
|
||||
}
|
||||
|
||||
default BlockState setAssertAndGetBlock(int x, int y, int z, Block block) {
|
||||
return this.setAssertAndGetBlock(x, y, z, block.defaultBlockState());
|
||||
}
|
||||
|
||||
default BlockState setAssertAndGetBlock(int x, int y, int z, BlockState state) {
|
||||
return this.setAssertAndGetBlock(new BlockPos(x, y, z), state);
|
||||
}
|
||||
|
||||
default BlockState setAssertAndGetBlock(BlockPos pos, Block block) {
|
||||
return this.setAssertAndGetBlock(pos, block.defaultBlockState());
|
||||
}
|
||||
|
||||
default BlockState setAssertAndGetBlock(BlockPos pos, BlockState state) {
|
||||
this.assertTrue(
|
||||
this.self().getLevel().setBlock(this.self().absolutePos(pos), state, Block.UPDATE_ALL),
|
||||
() -> "Failed to set block at pos %s : %s".formatted(pos, state.getBlock())
|
||||
);
|
||||
return state;
|
||||
}
|
||||
|
||||
default void removeAllItemEntitiesInRange(BlockPos pos, double range) {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"values": [
|
||||
"chorus_block_placement:placeable_on_chorus"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.debug.gameplay.block;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.gametest.framework.GameTest;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraftforge.common.data.BlockTagsProvider;
|
||||
import net.minecraftforge.data.event.GatherDataEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.gametest.GameTestHolder;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.test.BaseTestMod;
|
||||
|
||||
@GameTestHolder("forge." + ChorusBlockPlacementTest.MOD_ID)
|
||||
@Mod(ChorusBlockPlacementTest.MOD_ID)
|
||||
public class ChorusBlockPlacementTest extends BaseTestMod {
|
||||
static final String MOD_ID = "chorus_block_placement";
|
||||
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID);
|
||||
private static final RegistryObject<Block> BLOCK = BLOCKS.register("placeable_on_chorus", () -> new Block(Block.Properties.of().setId(BLOCKS.key("placeable_on_chorus"))));
|
||||
|
||||
public ChorusBlockPlacementTest(FMLJavaModLoadingContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@GameTest(template = "forge:empty3x3x3")
|
||||
public static void custom_placeable_block(GameTestHelper helper) {
|
||||
var custom = helper.setAssertAndGetBlock(BlockPos.ZERO, BLOCK.get());
|
||||
helper.assertTrue(custom.is(Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON), () -> "Block %s is not placeable on chorus".formatted(custom.getBlock()));
|
||||
|
||||
helper.setAndAssertBlock(BlockPos.ZERO.above(), Blocks.CHORUS_FLOWER);
|
||||
helper.runAfterDelay(1, () -> {
|
||||
helper.assertBlockPresent(Blocks.CHORUS_FLOWER, BlockPos.ZERO.above());
|
||||
helper.succeed();
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void runData(GatherDataEvent event) {
|
||||
event.getGenerator().addProvider(event.includeServer(), new BlockTags(event));
|
||||
}
|
||||
|
||||
private static final class BlockTags extends BlockTagsProvider {
|
||||
public BlockTags(GatherDataEvent event) {
|
||||
super(event.getGenerator().getPackOutput(), event.getLookupProvider(), MOD_ID, event.getExistingFileHelper());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags(HolderLookup.Provider provider) {
|
||||
this.tag(Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON).add(BLOCK.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user