mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +00:00
Add '#forge:chorus_additionally_grows_on' tag for similar mechanics to '#minecraft:azalea_grows_on' but for chorus (#10455)
This commit is contained in:
1 parent
fe616ffe20
commit
212da42d6e
8 files changed
+163
-1
No files matched your search
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"values": [
|
||||
"#forge:end_stones"
|
||||
]
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class Tags
|
||||
public static final TagKey<Block> CHESTS_ENDER = tag("chests/ender");
|
||||
public static final TagKey<Block> CHESTS_TRAPPED = tag("chests/trapped");
|
||||
public static final TagKey<Block> CHESTS_WOODEN = tag("chests/wooden");
|
||||
public static final TagKey<Block> CHORUS_ADDITIONALLY_GROWS_ON = tag("chorus_additionally_grows_on");
|
||||
public static final TagKey<Block> COBBLESTONE = tag("cobblestone");
|
||||
public static final TagKey<Block> COBBLESTONE_NORMAL = tag("cobblestone/normal");
|
||||
public static final TagKey<Block> COBBLESTONE_INFESTED = tag("cobblestone/infested");
|
||||
|
||||
@@ -42,6 +42,7 @@ public final class ForgeBlockTagsProvider extends BlockTagsProvider
|
||||
tag(CHESTS_ENDER).add(Blocks.ENDER_CHEST);
|
||||
tag(CHESTS_TRAPPED).add(Blocks.TRAPPED_CHEST);
|
||||
tag(CHESTS_WOODEN).add(Blocks.CHEST, Blocks.TRAPPED_CHEST);
|
||||
tag(CHORUS_ADDITIONALLY_GROWS_ON).addTags(END_STONES);
|
||||
tag(COBBLESTONE).addTags(COBBLESTONE_NORMAL, COBBLESTONE_INFESTED, COBBLESTONE_MOSSY, COBBLESTONE_DEEPSLATE);
|
||||
tag(COBBLESTONE_NORMAL).add(Blocks.COBBLESTONE);
|
||||
tag(COBBLESTONE_INFESTED).add(Blocks.INFESTED_COBBLESTONE);
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -159,6 +160,26 @@ public interface IForgeGameTestHelper {
|
||||
}
|
||||
}
|
||||
|
||||
default BlockState setAndAssertBlock(int x, int y, int z, Block block) {
|
||||
return this.setAndAssertBlock(x, y, z, block.defaultBlockState());
|
||||
}
|
||||
|
||||
default BlockState setAndAssertBlock(int x, int y, int z, BlockState state) {
|
||||
return this.setAndAssertBlock(new BlockPos(x, y, z), state);
|
||||
}
|
||||
|
||||
default BlockState setAndAssertBlock(BlockPos pos, Block block) {
|
||||
return this.setAndAssertBlock(pos, block.defaultBlockState());
|
||||
}
|
||||
|
||||
default BlockState setAndAssertBlock(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 <T> Flag<T> flag(String name) {
|
||||
return new Flag<>(name);
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"values": [
|
||||
"chorus_block_placement:placeable_on_chorus"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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()));
|
||||
|
||||
@GameTest(template = "forge:empty3x3x3")
|
||||
public static void custom_placeable_block(GameTestHelper helper) {
|
||||
var custom = helper.setAndAssertBlock(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