This commit is contained in:
叁玖领域 2024-09-25 16:06:02 +08:00
parent 685bf74793
commit 5f089de75f
13 changed files with 616 additions and 1 deletions

View File

@ -1,10 +1,16 @@
package com.r3944realms.modernlifepatch;
import net.minecraftforge.fml.common.Mod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.r3944realms.modernlifepatch.ModernLifePatch.MOD_ID;
@Mod(value = MOD_ID)
public class ModernLifePatch {
public static final String MOD_ID = "modernlifepatch";
public static final Logger logger = LoggerFactory.getLogger(ModernLifePatch.class);
ModernLifePatch() {
logger.info("ModernLifePatch loaded");
}
}

View File

@ -0,0 +1,46 @@
package com.r3944realms.modernlifepatch.mixin.block.bathroom;
import com.dairymoose.modernlife.blocks.AbstractWallBlock;
import com.dairymoose.modernlife.blocks.ShowerHeadBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(ShowerHeadBlock.class)
public abstract class MixinShowerHead extends AbstractWallBlock implements EntityBlock {
@Unique
private static final VoxelShape SHAPE_N = Block.box(6, 8.5, 10, 10, 12.5, 16), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
public MixinShowerHead(Properties p_i241196_1_) {
super(p_i241196_1_);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,54 @@
package com.r3944realms.modernlifepatch.mixin.block.bathroom;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.blocks.ToiletBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(ToiletBlock.class)
public abstract class MixinToilet extends StandardHorizontalBlock implements SimpleWaterloggedBlock, EntityBlock {
@Unique
private static final VoxelShape SHAPE_S, SHAPE_W, SHAPE_N, SHAPE_E;
static {
SHAPE_S = Stream.of(
Block.box(3, 4, 0, 13, 16, 5),
Block.box(3, 3.99, 5, 5, 7.99, 15),
Block.box(11, 3.99, 5, 13, 7.99, 15),
Block.box(5, 3.99, 5, 11, 7.99, 7),
Block.box(5, 3.99, 13, 11, 7.99, 15),
Block.box(4, -0.01, 2, 12, 3.99, 13)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
public MixinToilet(Properties p_i48377_1_) {
super(p_i48377_1_);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,51 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.CoffeeMugBlock;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(CoffeeMugBlock.class)
public class MixinCoffeeMug extends StandardHorizontalBlock {
public MixinCoffeeMug(Properties p_i48377_1_) {
super(p_i48377_1_);
}
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(7, 0, 9, 9, 5, 10),
Block.box(7, 0, 6, 9, 5, 7),
Block.box(7, 0, 7, 9, 1, 9),
Block.box(6, 0, 6, 7, 5, 10),
Block.box(9, 0, 6, 10, 5, 10)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,55 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.LightBulbBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(LightBulbBlock.class)
public class MixinLightBulb extends FaceAttachedHorizontalDirectionalBlock {
@Unique
private static final VoxelShape _SHAPE_CEILING = Shapes.join(Block.box(5, 8, 5, 11, 14, 11), Block.box(7, 13, 7, 9, 16, 9), BooleanOp.OR)
, _SHAPE_WALL_NORTH, _SHAPE_WALL_EAST, _SHAPE_WALL_SOUTH, _SHAPE_WALL_WEST, _SHAPE_FLOOR;
static {
_SHAPE_WALL_NORTH = ModernLifeUtil.RotateVoxelShapeXAxis(_SHAPE_CEILING);
_SHAPE_WALL_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_NORTH);
_SHAPE_WALL_SOUTH = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_EAST);
_SHAPE_WALL_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_SOUTH);
_SHAPE_FLOOR = ModernLifeUtil.RotateVoxelShapeXAxis(_SHAPE_WALL_NORTH);
}
public MixinLightBulb(Properties p_53182_) {
super(p_53182_);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACE)) {
case WALL:
switch (bs.getValue(FACING)) {
case NORTH -> cir.setReturnValue(_SHAPE_WALL_NORTH);
case EAST -> cir.setReturnValue(_SHAPE_WALL_EAST);
case WEST -> cir.setReturnValue(_SHAPE_WALL_WEST);
case SOUTH -> cir.setReturnValue(_SHAPE_WALL_SOUTH);
}
break;
case FLOOR:
cir.setReturnValue(_SHAPE_FLOOR);
break;
default:
cir.setReturnValue(_SHAPE_CEILING);
}
}
}

View File

@ -0,0 +1,38 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.TrashCanBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(TrashCanBlock.class)
public abstract class MixinTrashCan extends Block implements EntityBlock {
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(6, 17, 7.5, 10, 18, 8.5),
Block.box(2, 13, 2, 14, 16, 14),
Block.box(3, 0, 3, 13, 13, 13)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
public MixinTrashCan(Properties p_49795_) {
super(p_49795_);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
cir.setReturnValue(SHAPE_N);
}
}

View File

@ -0,0 +1,55 @@
package com.r3944realms.modernlifepatch.mixin.block.kitchen;
import com.dairymoose.modernlife.blocks.KitchenSinkBlock;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(KitchenSinkBlock.class)
public class MixinKitchenSink extends StandardHorizontalBlock {
public MixinKitchenSink(Properties p_i48377_1_) {
super(p_i48377_1_);
}
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(4, 3, 0, 12, 5, 3),
Block.box(5, 5, 1, 6, 6, 2),
Block.box(10, 5, 1, 11, 6, 2),
Block.box(7, 5, 0, 9, 8, 2),
Block.box(7, 8, 0, 9, 10, 7),
Block.box(7, 7, 5, 9, 8, 7),
Block.box(0, 0, 13, 16, 3, 16),
Block.box(0, 0, 0, 16, 3, 3),
Block.box(0, 0, 3, 3, 3, 13),
Block.box(13, 0, 3, 16, 3, 13),
Block.box(3, 0, 3, 13, 1, 13)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_N);
case EAST -> cir.setReturnValue(SHAPE_W);
case WEST -> cir.setReturnValue(SHAPE_E);
default -> cir.setReturnValue(SHAPE_S);
}
}
}

View File

@ -0,0 +1,62 @@
package com.r3944realms.modernlifepatch.mixin.block.kitchen;
import com.dairymoose.modernlife.blocks.MicrowaveBlock;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(MicrowaveBlock.class)
public abstract class MixinMicrowave extends StandardHorizontalBlock implements EntityBlock {
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(1, 8, 2, 15, 10, 14),
Block.box(12, 2, 2, 15, 8, 14),
Block.box(1, 0, 2, 15, 2, 14),
Block.box(1, 2, 2, 3, 8, 14),
Block.box(3, 2, 2, 12, 8, 5),
Block.box(3, 2, 14, 12, 8, 14)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W,
SHAPE_N_O = Stream.of(
Block.box(3, 2, 2, 12, 8, 5),
Block.box(1, 8, 2, 15, 10, 14),
Block.box(12, 2, 2, 15, 8, 14),
Block.box(1, 0, 2, 15, 2, 14),
Block.box(1, 2, 2, 3, 8, 14)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E_O, SHAPE_S_O, SHAPE_W_O;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_E_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N_O);
SHAPE_S_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E_O);
SHAPE_W_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S_O);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
boolean isOpen = bs.getValue(MicrowaveBlock.OPEN_DOOR);
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(isOpen ? SHAPE_S_O :SHAPE_S);
case EAST -> cir.setReturnValue(isOpen ? SHAPE_E_O : SHAPE_E);
case WEST -> cir.setReturnValue(isOpen ? SHAPE_W_O : SHAPE_W);
default -> cir.setReturnValue(isOpen? SHAPE_N_O : SHAPE_N);
}
}
public MixinMicrowave(Properties p_i48377_1_) {
super(p_i48377_1_);
}
}

View File

@ -0,0 +1,87 @@
package com.r3944realms.modernlifepatch.mixin.block.kitchen;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.blocks.StoveBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(StoveBlock.class)
public abstract class MixinStove extends StandardHorizontalBlock implements EntityBlock {
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Stream.of(
Block.box(0, 0, 15, 16, 2, 16),
Block.box(0, 8, 15, 16, 10, 16),
Block.box(13, 2, 15, 16, 8, 16),
Block.box(0, 2, 15, 3, 8, 16),
Block.box(2, 9, 16, 2, 10, 17),
Block.box(14, 9, 16, 14, 10, 17),
Block.box(2, 9, 17, 14, 10, 18),
Block.box(3, 2, 16, 13, 8, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(),
Block.box(0, 0, 0, 16, 2, 15),
Block.box(0, 9, 0, 16, 13, 15),
Block.box(0, 13, 0, 16, 16, 2),
Block.box(0, 10, 15, 16, 13, 16),
Block.box(3, 2, 0, 13, 9, 3),
Block.box(13, 2, 0, 16, 9, 15),
Block.box(0, 2, 0, 3, 9, 15),
Block.box(3, 6, 3, 13, 6, 14),
Block.box(3, 3, 3, 13, 3, 14)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W,
SHAPE_N_O = Stream.of(
Stream.of(
Block.box(0, 0, 15, 16, 1, 17),
Block.box(0, 0, 23, 16, 1, 25),
Block.box(13, 0, 17, 16, 1, 23),
Block.box(0, 0, 17, 3, 1, 23),
Block.box(2, -1, 24, 2, 0, 25),
Block.box(14, -1, 24, 14, 0, 25),
Block.box(2, -2, 24, 14, -1, 25),
Block.box(3, 0.099, 17, 13, 0.099, 23)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(),
Block.box(0, 0, 0, 16, 2, 15),
Block.box(0, 9, 0, 16, 13, 15),
Block.box(0, 13, 0, 16, 16, 2),
Block.box(0, 10, 15, 16, 13, 16),
Block.box(3, 2, 0, 13, 9, 3),
Block.box(13, 2, 0, 16, 9, 15),
Block.box(0, 2, 0, 3, 9, 15)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E_O, SHAPE_S_O, SHAPE_W_O;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_E_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N_O);
SHAPE_S_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E_O);
SHAPE_W_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S_O);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
boolean isOpen = bs.getValue(StoveBlock.OPEN_DOOR);
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(isOpen ? SHAPE_S_O : SHAPE_S);
case EAST -> cir.setReturnValue(isOpen ? SHAPE_E_O : SHAPE_E);
case WEST -> cir.setReturnValue(isOpen ? SHAPE_W_O : SHAPE_W);
default -> cir.setReturnValue(isOpen ? SHAPE_N_O : SHAPE_N);
}
}
public MixinStove(Properties p_i48377_1_) {
super(p_i48377_1_);
}
}

View File

@ -0,0 +1,40 @@
package com.r3944realms.modernlifepatch.mixin.block.redstone;
import com.dairymoose.modernlife.blocks.ExtractorBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(ExtractorBlock.class)
public class MixinExtractor {
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(5, 4, 2, 11, 10, 14),
Block.box(3, 2, 14, 13, 12, 17),
Block.box(3, 2, -1, 13, 12, 2),
Block.box(4, 3, 4, 12, 11, 12)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E;
@Inject(method = "getShape", at = @At("HEAD"), cancellable = true)
public void getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_, CollisionContext p_220053_4_, CallbackInfoReturnable<VoxelShape> cir) {
switch (p_220053_1_.getValue(ExtractorBlock.FACING)) {
case EAST,WEST -> cir.setReturnValue(SHAPE_E);
default -> cir.setReturnValue(SHAPE_N);
}
}
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
}

View File

@ -0,0 +1,30 @@
package com.r3944realms.modernlifepatch.mixin.block.redstone;
import com.dairymoose.modernlife.blocks.PowerReceiverBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PowerReceiverBlock.class)
public class MixinPowerReceiver {
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
VoxelShape combinedShape =
Shapes.join(
Block.box(5, 10, 5, 11, 16, 11),
Block.box(0, 0, 0, 16, 5, 16),
BooleanOp.OR);
cir.setReturnValue(combinedShape);
}
}

View File

@ -0,0 +1,81 @@
package com.r3944realms.modernlifepatch.mixin.block.redstone;
import com.dairymoose.modernlife.blocks.WinchBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(WinchBlock.class)
public abstract class MixinWinch extends FaceAttachedHorizontalDirectionalBlock implements EntityBlock {
@Unique
private static final VoxelShape __SHAPE_FLOOR_SOUTH ,_SHAPE_FLOOR_WEST, _SHAPE_FLOOR_NORTH, _SHAPE_FLOOR_EAST, _SHAPE_WALL_SOUTH, _SHAPE_WALL_WEST, _SHAPE_WALL_NORTH, _SHAPE_WALL_EAST, _SHAPE_CEILING_SOUTH, _SHAPE_CEILING_WEST, _SHAPE_CEILING_NORTH, _SHAPE_CEILING_EAST;
static {
__SHAPE_FLOOR_SOUTH = Stream.of(
Block.box(2, 5, 5, 14, 11, 11),
Block.box(0, 4, 4, 2, 12, 12),
Block.box(0, 0, 6, 2, 4, 10),
Block.box(14, 0, 6, 16, 4, 10),
Block.box(14, 4, 4, 16, 12, 12)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
_SHAPE_FLOOR_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(__SHAPE_FLOOR_SOUTH);
_SHAPE_FLOOR_NORTH = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_FLOOR_WEST);
_SHAPE_FLOOR_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_FLOOR_NORTH);
_SHAPE_WALL_SOUTH = ModernLifeUtil.RotateVoxelShapeXAxis(__SHAPE_FLOOR_SOUTH);
_SHAPE_WALL_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_SOUTH);
_SHAPE_WALL_NORTH = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_WEST);
_SHAPE_WALL_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_NORTH);
_SHAPE_CEILING_SOUTH = ModernLifeUtil.RotateVoxelShapeXAxis(_SHAPE_WALL_SOUTH);
_SHAPE_CEILING_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_CEILING_SOUTH);
_SHAPE_CEILING_NORTH = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_CEILING_WEST);
_SHAPE_CEILING_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_CEILING_NORTH);
}
public MixinWinch(Properties p_53182_) {
super(p_53182_);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch ((bs.getValue(FACE))) {
case CEILING: {
MH$SwitchInner(bs, cir, _SHAPE_CEILING_NORTH, _SHAPE_CEILING_EAST, _SHAPE_CEILING_WEST, _SHAPE_CEILING_SOUTH);
break;
}
case WALL: {
MH$SwitchInner(bs, cir, _SHAPE_WALL_NORTH, _SHAPE_WALL_EAST, _SHAPE_WALL_WEST, _SHAPE_WALL_SOUTH);
break;
}
case FLOOR: {
MH$SwitchInner(bs, cir, _SHAPE_FLOOR_NORTH, _SHAPE_FLOOR_EAST, _SHAPE_FLOOR_WEST, __SHAPE_FLOOR_SOUTH);
break;
}
default:
cir.setReturnValue(_SHAPE_FLOOR_NORTH);
}
}
@Unique
private void MH$SwitchInner(BlockState bs, CallbackInfoReturnable<VoxelShape> cir, VoxelShape shapeFloorNorth, VoxelShape shapeFloorEast, VoxelShape shapeFloorWest, VoxelShape shapeFloorSouth) {
switch (bs.getValue(FACING)) {
case NORTH -> cir.setReturnValue(shapeFloorNorth);
case EAST -> cir.setReturnValue(shapeFloorEast);
case WEST -> cir.setReturnValue(shapeFloorWest);
case SOUTH -> cir.setReturnValue(shapeFloorSouth);
}
}
}

View File

@ -4,7 +4,17 @@
"compatibilityLevel": "JAVA_17",
"refmap": "imodhelper.refmap.json",
"mixins": [
"block.bathroom.MixinShowerHead",
"block.bathroom.MixinToilet",
"block.common.MixinCoffeeMug",
"block.common.MixinLightBulb",
"block.common.MixinTrashCan",
"block.kitchen.MixinKitchenSink",
"block.kitchen.MixinMicrowave",
"block.kitchen.MixinStove",
"block.redstone.MixinExtractor",
"block.redstone.MixinPowerReceiver",
"block.redstone.MixinWinch"
],
"minVersion": "0.8",
"client": [