Skip to content

Commit

Permalink
When CAN_GOO_DIE is set to false, placed goo is alive by default. Res…
Browse files Browse the repository at this point in the history
…olves #208
  • Loading branch information
Direwolf20-MC committed Oct 19, 2024
1 parent 58bd519 commit 7974e4a
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.direwolf20.justdirethings.common.blocks.gooblocks;

import com.direwolf20.justdirethings.setup.Config;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;

import java.util.List;

Expand All @@ -27,4 +30,12 @@ public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<C
tooltip.add(Component.translatable("justdirethings.requiresfeeding")
.withStyle(ChatFormatting.DARK_RED));
}

@Override
protected BlockState getPlacementState(BlockPlaceContext context) {
BlockState blockstate = Config.GOO_CAN_DIE.get() ? this.getBlock().getStateForPlacement(context) : this.getBlock().getStateForPlacement(context).setValue(GooBlock_Base.ALIVE, true);
if (blockstate == null)
return null;
return this.canPlace(context, blockstate) ? blockstate : null;
}
}

0 comments on commit 7974e4a

Please sign in to comment.