From 8c35005023fbed71b8b4fce71652d26a373b1359 Mon Sep 17 00:00:00 2001 From: DavigJ Date: Tue, 6 Aug 2024 08:20:57 +0400 Subject: [PATCH 1/3] removed sound from getToolModifiedState in WaxedPineconeBlock, as AxeItem already plays the stripping noise. fixes #420 --- .../environmental/common/block/WaxedPineconeBlock.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/teamabnormals/environmental/common/block/WaxedPineconeBlock.java b/src/main/java/com/teamabnormals/environmental/common/block/WaxedPineconeBlock.java index fca5b9159..3fa6ef829 100644 --- a/src/main/java/com/teamabnormals/environmental/common/block/WaxedPineconeBlock.java +++ b/src/main/java/com/teamabnormals/environmental/common/block/WaxedPineconeBlock.java @@ -24,7 +24,6 @@ public BlockState getToolModifiedState(BlockState state, UseOnContext context, T Level level = context.getLevel(); Player player = context.getPlayer(); BlockPos pos = context.getClickedPos(); - level.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); level.levelEvent(player, 3004, pos, 0); return EnvironmentalBlocks.PINECONE.get().defaultBlockState(); } From 0c79b10cc9b2e26fe4414c3a32380759813e9980 Mon Sep 17 00:00:00 2001 From: DavigJ Date: Tue, 6 Aug 2024 09:59:31 +0400 Subject: [PATCH 2/3] cartwheels can be placed in cardinal directions. fixes #318 --- .../common/block/PottedCartwheelBlock.java | 35 ++++++++++++++++--- .../blockstates/potted_cartwheel.json | 5 ++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/teamabnormals/environmental/common/block/PottedCartwheelBlock.java b/src/main/java/com/teamabnormals/environmental/common/block/PottedCartwheelBlock.java index 0e07ed7a6..6570e9ec3 100644 --- a/src/main/java/com/teamabnormals/environmental/common/block/PottedCartwheelBlock.java +++ b/src/main/java/com/teamabnormals/environmental/common/block/PottedCartwheelBlock.java @@ -1,19 +1,28 @@ package com.teamabnormals.environmental.common.block; +import com.teamabnormals.environmental.core.Environmental; +import com.teamabnormals.environmental.core.registry.EnvironmentalBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.stats.Stats; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.FlowerPotBlock; -import net.minecraft.world.level.block.HorizontalDirectionalBlock; -import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +@Mod.EventBusSubscriber(modid = Environmental.MOD_ID) public class PottedCartwheelBlock extends FlowerPotBlock { public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; @@ -41,4 +50,22 @@ public BlockState mirror(BlockState state, Mirror mirrorIn) { protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(FACING); } + + @SubscribeEvent + public static void interact(PlayerInteractEvent.RightClickBlock event) { + Level level = event.getLevel(); + ItemStack stack = event.getItemStack(); + BlockPos pos = event.getPos(); + if (level.getBlockState(pos).getBlock() == Blocks.FLOWER_POT && stack.getItem() == EnvironmentalBlocks.CARTWHEEL.get().asItem()) { + System.out.println(event.getEntity().getDirection().getOpposite()); + level.setBlock(pos, EnvironmentalBlocks.POTTED_CARTWHEEL.get().defaultBlockState().setValue(FACING, event.getEntity().getDirection().getOpposite()), 0); + event.getEntity().awardStat(Stats.POT_FLOWER); + if (!event.getEntity().getAbilities().instabuild) { + stack.shrink(1); + } + event.setUseBlock(Event.Result.DENY); + event.setCancellationResult(InteractionResult.SUCCESS); + event.setCanceled(true); + } + } } diff --git a/src/main/resources/assets/environmental/blockstates/potted_cartwheel.json b/src/main/resources/assets/environmental/blockstates/potted_cartwheel.json index 5e9962a45..7912bb479 100644 --- a/src/main/resources/assets/environmental/blockstates/potted_cartwheel.json +++ b/src/main/resources/assets/environmental/blockstates/potted_cartwheel.json @@ -1,5 +1,8 @@ { "variants": { - "": { "model": "environmental:block/potted_cartwheel" } + "facing=north": { "model": "environmental:block/potted_cartwheel" }, + "facing=east": { "model": "environmental:block/potted_cartwheel", "y": 90 }, + "facing=south": { "model": "environmental:block/potted_cartwheel", "y": 180 }, + "facing=west": { "model": "environmental:block/potted_cartwheel", "y": 270 } } } From c80b3b9ba6c0cf5c4433d63a936662a0bf657c63 Mon Sep 17 00:00:00 2001 From: DavigJ Date: Tue, 6 Aug 2024 10:52:00 +0400 Subject: [PATCH 3/3] add stripped logs block tag, fixes #355 --- .../resources/data/forge/tags/blocks/stripped_logs.json | 8 ++++++++ .../data/server/tags/EnvironmentalBlockTagsProvider.java | 2 ++ .../core/other/tags/EnvironmentalBlockTags.java | 2 ++ 3 files changed, 12 insertions(+) create mode 100644 src/generated/resources/data/forge/tags/blocks/stripped_logs.json diff --git a/src/generated/resources/data/forge/tags/blocks/stripped_logs.json b/src/generated/resources/data/forge/tags/blocks/stripped_logs.json new file mode 100644 index 000000000..689b77c8a --- /dev/null +++ b/src/generated/resources/data/forge/tags/blocks/stripped_logs.json @@ -0,0 +1,8 @@ +{ + "values": [ + "environmental:stripped_willow_log", + "environmental:stripped_pine_log", + "environmental:stripped_wisteria_log", + "environmental:stripped_plum_log" + ] +} \ No newline at end of file diff --git a/src/main/java/com/teamabnormals/environmental/core/data/server/tags/EnvironmentalBlockTagsProvider.java b/src/main/java/com/teamabnormals/environmental/core/data/server/tags/EnvironmentalBlockTagsProvider.java index 772d7e467..6cbf55e81 100644 --- a/src/main/java/com/teamabnormals/environmental/core/data/server/tags/EnvironmentalBlockTagsProvider.java +++ b/src/main/java/com/teamabnormals/environmental/core/data/server/tags/EnvironmentalBlockTagsProvider.java @@ -118,5 +118,7 @@ public void addTags(Provider provider) { this.tag(BlueprintBlockTags.LEAF_PILES).add(WILLOW_LEAF_PILE.get(), PINE_LEAF_PILE.get(), WISTERIA_LEAF_PILE.get(), PINK_WISTERIA_LEAF_PILE.get(), BLUE_WISTERIA_LEAF_PILE.get(), PURPLE_WISTERIA_LEAF_PILE.get(), WHITE_WISTERIA_LEAF_PILE.get(), PLUM_LEAF_PILE.get(), CHEERFUL_PLUM_LEAF_PILE.get(), MOODY_PLUM_LEAF_PILE.get(), HIBISCUS_LEAF_PILE.get()); this.tag(Tags.Blocks.FENCE_GATES_WOODEN).add(WILLOW_FENCE_GATE.get(), PINE_FENCE_GATE.get(), WISTERIA_FENCE_GATE.get(), PLUM_FENCE_GATE.get()); + + this.tag(STRIPPED_LOGS).add(STRIPPED_WILLOW_LOG.get(), STRIPPED_PINE_LOG.get(), STRIPPED_WISTERIA_LOG.get(), STRIPPED_PLUM_LOG.get()); } } \ No newline at end of file diff --git a/src/main/java/com/teamabnormals/environmental/core/other/tags/EnvironmentalBlockTags.java b/src/main/java/com/teamabnormals/environmental/core/other/tags/EnvironmentalBlockTags.java index a22050abc..c9f6e6e66 100644 --- a/src/main/java/com/teamabnormals/environmental/core/other/tags/EnvironmentalBlockTags.java +++ b/src/main/java/com/teamabnormals/environmental/core/other/tags/EnvironmentalBlockTags.java @@ -23,6 +23,8 @@ public class EnvironmentalBlockTags { public static final TagKey WISTERIA_LOGS = blockTag("wisteria_logs"); public static final TagKey PLUM_LOGS = blockTag("plum_logs"); + public static final TagKey STRIPPED_LOGS = TagUtil.blockTag("forge", "stripped_logs"); + private static TagKey blockTag(String tagName) { return TagUtil.blockTag(Environmental.MOD_ID, tagName); }