Can place skulls inside when creativeNoClip. Fixes #775

This commit is contained in:
gnembon committed 2021-04-04 18:28:25 -03:00
1 parent 8f5330e241
commit 00f932bafc
2 files changed
+39

No files matched your search

@@ -0,0 +1,38 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.WallStandingBlockItem;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.WorldView;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(WallStandingBlockItem.class)
public class WallStandingBlockItem_creativeNoClipMixin
{
@Redirect(method = "getPlacementState", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/WorldView;canPlace(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Z"
))
private boolean canCreativePlayerPlace(
WorldView worldView, BlockState state, BlockPos pos, ShapeContext context,
ItemPlacementContext itemcontext
)
{
PlayerEntity player = itemcontext.getPlayer();
if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.abilities.flying)
{
// copy from canPlace
VoxelShape voxelShape = state.getCollisionShape(worldView, pos, context);
return voxelShape.isEmpty() || worldView.intersectsEntities(player, voxelShape.offset(pos.getX(), pos.getY(), pos.getZ()));
}
return worldView.canPlace(state, pos, context);
}
}
+1
View File
@@ -194,6 +194,7 @@
"PlayerEntity_creativeNoClipMixin",
"PistonBlockEntity_playerHandlingMixin",
"BlockItem_creativeNoClipMixin",
"WallStandingBlockItem_creativeNoClipMixin",
"LivingEntity_creativeFlyMixin"
],