Skip to content

Commit

Permalink
Remove glazed terracotta as farmland for DESERT plant type (#416)
Browse files Browse the repository at this point in the history
Fixes #306 by removing glazed terracotta as acceptable farmland for the `DESERT` plant type.

Also includes a related fix to expand `DESERT` plant types to be plantable on both uncolored/raw terracotta and stained terracotta, to match with the plantability of dead bushes on both. (This only really matters for modded plants, because dead bushes extend `BushBlock` and therefore have their `mayPlaceOn` method called to allow placing on stained terracotta anyway.)
  • Loading branch information
sciwhiz12 authored Dec 23, 2023
1 parent aa32f54 commit 36783f0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion patches/net/minecraft/world/level/block/Block.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
+ return true;
+
+ if (net.neoforged.neoforge.common.PlantType.DESERT.equals(type)) {
+ return state.is(BlockTags.SAND) || this == Blocks.TERRACOTTA || this instanceof GlazedTerracottaBlock;
+ return state.is(BlockTags.SAND) || state.is(BlockTags.TERRACOTTA);
+ } else if (net.neoforged.neoforge.common.PlantType.NETHER.equals(type)) {
+ return this == Blocks.SOUL_SAND;
+ } else if (net.neoforged.neoforge.common.PlantType.CROP.equals(type)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.Optional;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.gametest.framework.GameTest;
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -17,6 +18,8 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
Expand All @@ -32,6 +35,7 @@
import net.neoforged.testframework.annotation.ForEachTest;
import net.neoforged.testframework.annotation.TestHolder;
import net.neoforged.testframework.gametest.EmptyTemplate;
import net.neoforged.testframework.gametest.ExtendedGameTestHelper;
import net.neoforged.testframework.registration.RegistrationHelper;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -96,4 +100,30 @@ public Optional<Vec3> getRespawnPosition(BlockState state, EntityType<?> type, L
1, 3, 2))
.thenSucceed());
}

@GameTest
@EmptyTemplate(floor = true)
@TestHolder(description = {
"Dead bushes should be placeable on regular terracotta (colored or not), but not on glazed terracotta",
"(neoforged/NeoForge#306)"
})
static void deadBushTerracottaTest(final ExtendedGameTestHelper helper) {
final BlockPos farmlandBlock = new BlockPos(1, 1, 1);
helper.startSequence(() -> helper.makeTickingMockServerPlayerInCorner(GameType.SURVIVAL))
.thenExecute(() -> helper.setBlock(farmlandBlock, Blocks.TERRACOTTA))
.thenExecute(player -> helper.useBlock(farmlandBlock, player, new ItemStack(Items.DEAD_BUSH), Direction.UP))
.thenExecute(() -> helper.assertBlockPresent(Blocks.DEAD_BUSH, farmlandBlock.above()))

.thenExecute(() -> helper.setBlock(farmlandBlock.above(), Blocks.AIR))
.thenExecute(() -> helper.setBlock(farmlandBlock, Blocks.WHITE_TERRACOTTA))
.thenExecute(player -> helper.useBlock(farmlandBlock, player, new ItemStack(Items.DEAD_BUSH), Direction.UP))
.thenExecute(() -> helper.assertBlockPresent(Blocks.DEAD_BUSH, farmlandBlock.above()))

.thenExecute(() -> helper.setBlock(farmlandBlock.above(), Blocks.AIR))
.thenExecute(() -> helper.setBlock(farmlandBlock, Blocks.WHITE_GLAZED_TERRACOTTA))
.thenExecute(player -> helper.useBlock(farmlandBlock, player, new ItemStack(Items.DEAD_BUSH), Direction.UP))
.thenExecute(() -> helper.assertBlockNotPresent(Blocks.DEAD_BUSH, farmlandBlock.above()))

.thenSucceed();
}
}

0 comments on commit 36783f0

Please sign in to comment.