diff --git a/.gitignore b/.gitignore index 7fe172ee..ef1a98f2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ build .gradle run .DS_Store +src/main/resources/assets/create diff --git a/gradle.properties b/gradle.properties index 21c03d4c..b633205d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,10 +22,10 @@ minecraft_version = 1.20.1 parchment_version = 2023.06.26 # Quilt Mappings - https://lambdaurora.dev/tools/import_quilt.html quilt_mappings = 23 -# NeoForge: https://files.minecraftforge.net/net/minecraftforge/forge/index_1.19.2.html +# NeoForge: https://neoforged.net/ neo_version = 47.1.65 -# Mod Dependencies +## Mod Dependencies # Create, Registrate, and Flywheel: https://github.com/Creators-of-Create/Create/wiki/Depending-on-Create#types-of-dependencies registrate_version = MC1.20-1.3.3 create_version = 0.5.1.e-22 diff --git a/src/main/java/com/sudolev/interiors/content/block/seat/BigChairBlock.java b/src/main/java/com/sudolev/interiors/content/block/seat/BigChairBlock.java index 19244aaa..0b4d73b6 100644 --- a/src/main/java/com/sudolev/interiors/content/block/seat/BigChairBlock.java +++ b/src/main/java/com/sudolev/interiors/content/block/seat/BigChairBlock.java @@ -2,6 +2,11 @@ import java.util.List; +import org.jetbrains.annotations.NotNull; + +import com.simibubi.create.AllItems; +import com.simibubi.create.foundation.utility.BlockHelper; + import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -18,13 +23,9 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; -import com.simibubi.create.AllItems; -import com.simibubi.create.foundation.utility.BlockHelper; import com.sudolev.interiors.content.entity.BigSeatEntity; import com.sudolev.interiors.content.registry.CIBlocks; -import org.jetbrains.annotations.NotNull; - @SuppressWarnings("NullableProblems") public class BigChairBlock extends ChairBlock { private static final VoxelShape SHAPE = Shapes.or(Block.box(0, 5, 0, 16, 13, 16), Block.box(0, 0, 4, 16, 5, 12)); @@ -38,8 +39,7 @@ public VoxelShape shape() { return SHAPE; } - @Override - public void doSitDown(@NotNull Level world, @NotNull BlockPos pos, @NotNull Entity entity) { + public static void sitDown(@NotNull Level world, @NotNull BlockPos pos, @NotNull Entity entity) { if(world.isClientSide) return; BigSeatEntity seat = new BigSeatEntity(world, pos); seat.setPos(pos.getX() + .5f, pos.getY() + .34f, pos.getZ() + .5f); @@ -80,7 +80,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player } if(!world.isClientSide) { - doSitDown(world, pos, getLeashed(world, player).or(player)); + sitDown(world, pos, getLeashed(world, player).or(player)); } return InteractionResult.SUCCESS; } diff --git a/src/main/java/com/sudolev/interiors/content/block/seat/ChairBlock.java b/src/main/java/com/sudolev/interiors/content/block/seat/ChairBlock.java index 0f5eeff1..3df14158 100644 --- a/src/main/java/com/sudolev/interiors/content/block/seat/ChairBlock.java +++ b/src/main/java/com/sudolev/interiors/content/block/seat/ChairBlock.java @@ -1,16 +1,5 @@ package com.sudolev.interiors.content.block.seat; -import static com.sudolev.interiors.content.block.seat.ChairBlock.ArmrestConfiguration.BOTH; -import static com.sudolev.interiors.content.block.seat.ChairBlock.ArmrestConfiguration.DEFAULT; -import static com.sudolev.interiors.content.block.seat.ChairBlock.ArmrestConfiguration.LEFT; -import static com.sudolev.interiors.content.block.seat.ChairBlock.ArmrestConfiguration.NONE; -import static com.sudolev.interiors.content.block.seat.ChairBlock.ArmrestConfiguration.RIGHT; - -import javax.annotation.ParametersAreNonnullByDefault; - -import com.simibubi.create.foundation.block.ProperWaterloggedBlock; -import com.simibubi.create.foundation.utility.Lang; - import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -36,6 +25,13 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; +import com.simibubi.create.foundation.utility.Lang; + +import javax.annotation.ParametersAreNonnullByDefault; + +import static com.sudolev.interiors.content.block.seat.ChairBlock.ArmrestConfiguration.*; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public abstract class ChairBlock extends DirectionalSeatBlock implements ProperWaterloggedBlock { @@ -55,7 +51,8 @@ public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape sh int times = (to.ordinal() - from.get2DDataValue() + 4) % 4; for(int i = 0; i < times; i++) { - buffer[0].forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = Shapes.or(buffer[1], Shapes.create(1 - maxZ, minY, minX, 1 - minZ, maxY, maxX))); + buffer[0].forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> + buffer[1] = Shapes.or(buffer[1], Shapes.create(1 - maxZ, minY, minX, 1 - minZ, maxY, maxX))); buffer[0] = buffer[1]; buffer[1] = Shapes.empty(); } @@ -75,10 +72,6 @@ public BlockState getStateForPlacement(BlockPlaceContext context) { public abstract VoxelShape shape(); - public void doSitDown(Level world, BlockPos pos, Entity entity) { - sitDown(world, pos, entity); - } - @Override public void updateEntityAfterFallOn(BlockGetter reader, Entity entity) { BlockPos pos = entity.blockPosition(); @@ -97,30 +90,21 @@ public void updateEntityAfterFallOn(BlockGetter reader, Entity entity) { return; } if(reader.getBlockState(pos).getBlock() != this) return; - doSitDown(entity.level(), pos, entity); + sitDown(entity.level(), pos, entity); } @Override public InteractionResult onWrenched(BlockState state, UseOnContext context) { Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); - Direction face = context.getClickedFace(); Vec3 clickPos = pos.getCenter().subtract(context.getClickLocation()); state = switch(state.getValue(FACING)) { - case NORTH -> - face == Direction.SOUTH ? toggleBackCrop(state) : - (clickPos.x > 0 ? toggleLeft(state) : toggleRight(state)); - case SOUTH -> - face == Direction.NORTH ? toggleBackCrop(state) : - clickPos.x < 0 ? toggleLeft(state) : toggleRight(state); - case WEST -> - face == Direction.EAST ? toggleBackCrop(state) : - clickPos.z < 0 ? toggleLeft(state) : toggleRight(state); - case EAST -> - face == Direction.WEST ? toggleBackCrop(state) : - clickPos.z > 0 ? toggleLeft(state) : toggleRight(state); + case NORTH -> clickPos.x > 0 ? toggleLeft(state) : toggleRight(state); + case SOUTH -> clickPos.x < 0 ? toggleLeft(state) : toggleRight(state); + case WEST -> clickPos.z < 0 ? toggleLeft(state) : toggleRight(state); + case EAST -> clickPos.z > 0 ? toggleLeft(state) : toggleRight(state); default -> state; }; @@ -160,10 +144,7 @@ public InteractionResult onSneakWrenched(BlockState state, UseOnContext context) BlockPos pos = context.getClickedPos(); if(!world.isClientSide) { - world.setBlock(pos, state.setValue(ARMRESTS, switch(state.getValue(ARMRESTS)) { - case BOTH, LEFT, RIGHT -> NONE; - case NONE -> BOTH; - }), 3); + world.setBlock(pos, toggleBackCrop(state), 3); } return InteractionResult.SUCCESS; diff --git a/src/main/java/com/sudolev/interiors/content/entity/BigSeatEntity.java b/src/main/java/com/sudolev/interiors/content/entity/BigSeatEntity.java index cf42fb8c..a9aa2c27 100644 --- a/src/main/java/com/sudolev/interiors/content/entity/BigSeatEntity.java +++ b/src/main/java/com/sudolev/interiors/content/entity/BigSeatEntity.java @@ -10,9 +10,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.entity.IEntityAdditionalSpawnData; - -public class BigSeatEntity extends SeatEntity implements IEntityAdditionalSpawnData { +public class BigSeatEntity extends SeatEntity { public BigSeatEntity(EntityType type, Level world) { super(type, world); @@ -23,13 +21,18 @@ public BigSeatEntity(Level world, BlockPos pos) { } @SuppressWarnings("unchecked") - public static EntityType.Builder build(Builder builder) { - return ((EntityType.Builder) builder).sized(0.25f, 0.85f); + public static Builder build(Builder builder) { + return ((Builder) builder).sized(0.25f, 0.85f); + } + + @Override + public Vec3 getDismountLocationForPassenger(LivingEntity entity) { + return super.getDismountLocationForPassenger(entity).add(0, 0.34f, 0); } @Override - public Vec3 getDismountLocationForPassenger(LivingEntity pLivingEntity) { - return super.getDismountLocationForPassenger(pLivingEntity).add(0, 0.34f, 0); + public double getPassengersRidingOffset() { + return super.getPassengersRidingOffset() + 0.34; } public static class Render extends SeatEntity.Render { diff --git a/src/main/java/com/sudolev/interiors/foundation/mixin/AbstractContraptionEntityMixin.java b/src/main/java/com/sudolev/interiors/foundation/mixin/AbstractContraptionEntityMixin.java new file mode 100644 index 00000000..b1219129 --- /dev/null +++ b/src/main/java/com/sudolev/interiors/foundation/mixin/AbstractContraptionEntityMixin.java @@ -0,0 +1,37 @@ +package com.sudolev.interiors.foundation.mixin; + +import java.util.UUID; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.Contraption; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; + +import com.sudolev.interiors.content.block.seat.BigChairBlock; + +@Mixin(value = AbstractContraptionEntity.class, remap = false) +public abstract class AbstractContraptionEntityMixin { + + @Shadow + protected Contraption contraption; + + @Inject(method = "getPassengerPosition", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) + private void raise(Entity passenger, float partialTicks, CallbackInfoReturnable cir, UUID id, AABB bb, double ySize, BlockPos seat, Vec3 transformedVector) { + Vec3 vec3 = cir.getReturnValue(); + if(contraption.getBlocks().get(seat).state().getBlock() instanceof BigChairBlock) { + cir.setReturnValue(vec3.add(0, 0.34, 0)); + } + } +} diff --git a/src/main/java/com/sudolev/interiors/foundation/mixin/SeatBlockMixin.java b/src/main/java/com/sudolev/interiors/foundation/mixin/SeatBlockMixin.java new file mode 100644 index 00000000..db8490c3 --- /dev/null +++ b/src/main/java/com/sudolev/interiors/foundation/mixin/SeatBlockMixin.java @@ -0,0 +1,45 @@ +package com.sudolev.interiors.foundation.mixin; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; + +import com.simibubi.create.content.contraptions.actors.seat.SeatBlock; + +import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; + +import com.sudolev.interiors.content.block.seat.BigChairBlock; +import com.sudolev.interiors.content.entity.BigSeatEntity; + +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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(value = SeatBlock.class, remap = false) +public abstract class SeatBlockMixin { + + @Inject(method = "isSeatOccupied", at = @At("HEAD"), cancellable = true) + private static void sitDown(Level world, BlockPos pos, CallbackInfoReturnable cir) { + if(!world.getEntitiesOfClass(BigSeatEntity.class, new AABB(pos)).isEmpty()) + cir.setReturnValue(true); + } + + @Redirect(method = "sitDown", at = @At(value = "NEW", target = "(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Lcom/simibubi/create/content/contraptions/actors/seat/SeatEntity;")) + private static SeatEntity createSeatEntity(Level world, BlockPos pos) { + return world.getBlockState(pos).getBlock() instanceof BigChairBlock + ? new BigSeatEntity(world, pos) + : new SeatEntity(world, pos); + } + + @Inject(method = "sitDown", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z"), locals = LocalCapture.CAPTURE_FAILHARD) + private static void getY(Level world, BlockPos pos, Entity entity, CallbackInfo ci, SeatEntity seat) { + if(seat instanceof BigSeatEntity) { + seat.setPos(seat.getX(), seat.getY() + .34f, seat.getZ()); + } + } +} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index ac30df80..255383fd 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,6 +1,6 @@ modLoader = "javafml" loaderVersion = "[${neo_version},)" -license = "MIT" +license = "GPL-3.0" issueTrackerURL = "https://github.com/sudolev/CreateInteriorsMod/issues" [[mods]] @@ -38,26 +38,8 @@ mandatory = true versionRange = "[${create_version},)" ordering = "NONE" side = "BOTH" -[[dependencies.interiors]] -modId="jei" -mandatory=false -versionRange="[0.0.0,)" -ordering="NONE" -side="CLIENT" -[[dependencies.interiors]] -modId="configured" -mandatory=false -versionRange="[0.0.0,)" -ordering="NONE" -side="CLIENT" -[[dependencies.interiors]] -modId="catalogue" -mandatory=false -versionRange="[0.0.0,)" -ordering="NONE" -side="CLIENT" [modproperties.interiors] catalogueImageIcon="icon.png" -catalogueBackground="background.png" +catalogueBackground="mod_banner.png" configuredBackground="create:textures/block/seat/top_red.png" diff --git a/src/main/resources/assets/interiors/models/block/floor_chair/both_cropped.json b/src/main/resources/assets/interiors/models/block/floor_chair/both_cropped.json index 8d1f114b..25df73bb 100644 --- a/src/main/resources/assets/interiors/models/block/floor_chair/both_cropped.json +++ b/src/main/resources/assets/interiors/models/block/floor_chair/both_cropped.json @@ -63,7 +63,7 @@ "east": {"uv": [0, 5, 16, 0], "rotation": 270, "texture": "#side_top"}, "south": {"uv": [0, 16, 16, 0], "texture": "#side_top"}, "west": {"uv": [0, 5, 16, 0], "rotation": 90, "texture": "#side_top"}, - "up": {"uv": [0, 8, 16, 13], "texture": "#top"}, + "up": {"uv": [0, 8, 16, 13], "texture": "#side_top"}, "down": {"uv": [0, 0, 16, 8], "texture": "#missing"} } }, diff --git a/src/main/resources/assets/interiors/models/block/floor_chair/left_cropped.json b/src/main/resources/assets/interiors/models/block/floor_chair/left_cropped.json index 7d32f123..f4b50d8b 100644 --- a/src/main/resources/assets/interiors/models/block/floor_chair/left_cropped.json +++ b/src/main/resources/assets/interiors/models/block/floor_chair/left_cropped.json @@ -49,7 +49,7 @@ "east": {"uv": [0, 5, 16, 0], "rotation": 270, "texture": "#side_top"}, "south": {"uv": [0, 16, 16, 0], "texture": "#side_top"}, "west": {"uv": [0, 5, 16, 0], "rotation": 90, "texture": "#side_top"}, - "up": {"uv": [0, 8, 16, 13], "texture": "#top"}, + "up": {"uv": [0, 8, 16, 13], "texture": "#side_top"}, "down": {"uv": [0, 0, 16, 8], "texture": "#missing"} } }, diff --git a/src/main/resources/assets/interiors/models/block/floor_chair/none_cropped.json b/src/main/resources/assets/interiors/models/block/floor_chair/none_cropped.json index 2a9d6759..c4e3a414 100644 --- a/src/main/resources/assets/interiors/models/block/floor_chair/none_cropped.json +++ b/src/main/resources/assets/interiors/models/block/floor_chair/none_cropped.json @@ -35,7 +35,7 @@ "east": {"uv": [0, 5, 16, 0], "rotation": 270, "texture": "#side_top"}, "south": {"uv": [0, 16, 16, 0], "texture": "#side_top"}, "west": {"uv": [0, 5, 16, 0], "rotation": 90, "texture": "#side_top"}, - "up": {"uv": [0, 8, 16, 13], "texture": "#top"}, + "up": {"uv": [0, 8, 16, 13], "texture": "#side_top"}, "down": {"uv": [0, 0, 16, 8], "texture": "#missing"} } }, diff --git a/src/main/resources/assets/interiors/models/block/floor_chair/right_cropped.json b/src/main/resources/assets/interiors/models/block/floor_chair/right_cropped.json index 3554c23c..3f54e3b9 100644 --- a/src/main/resources/assets/interiors/models/block/floor_chair/right_cropped.json +++ b/src/main/resources/assets/interiors/models/block/floor_chair/right_cropped.json @@ -49,7 +49,7 @@ "east": {"uv": [0, 5, 16, 0], "rotation": 270, "texture": "#side_top"}, "south": {"uv": [0, 16, 16, 0], "texture": "#side_top"}, "west": {"uv": [0, 5, 16, 0], "rotation": 90, "texture": "#side_top"}, - "up": {"uv": [0, 8, 16, 13], "texture": "#top"}, + "up": {"uv": [0, 8, 16, 13], "texture": "#side_top"}, "down": {"uv": [0, 0, 16, 8], "texture": "#missing"} } }, diff --git a/src/main/resources/background.png b/src/main/resources/background.png deleted file mode 100644 index 446dc23d..00000000 Binary files a/src/main/resources/background.png and /dev/null differ diff --git a/src/main/resources/interiors.mixins.json b/src/main/resources/interiors.mixins.json index 0cb3c87e..f183462b 100644 --- a/src/main/resources/interiors.mixins.json +++ b/src/main/resources/interiors.mixins.json @@ -5,7 +5,8 @@ "compatibilityLevel": "JAVA_17", "client": [], "mixins": [ - + "AbstractContraptionEntityMixin", + "SeatBlockMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/mod_banner.png b/src/main/resources/mod_banner.png index cd731b0d..96fa196e 100644 Binary files a/src/main/resources/mod_banner.png and b/src/main/resources/mod_banner.png differ diff --git a/src/main/wordmark.png b/src/main/wordmark.png deleted file mode 100644 index cd731b0d..00000000 Binary files a/src/main/wordmark.png and /dev/null differ