diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityNuclearReactorCore.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityNuclearReactorCore.java index 0643905a3..2d8c10617 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityNuclearReactorCore.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityNuclearReactorCore.java @@ -257,8 +257,7 @@ public void onUnregisterPost() { @Override public Function getMultiTexture() { return direction -> { - Direction direction1 = coverHandler.map(c -> c.get(direction).isEmpty() ? direction : Direction.UP).orElse(direction); - return type.getBaseTexture(this.tier, direction1, this.machineState); + return type.getBaseTexture(this.tier, UP, this.machineState); }; } diff --git a/common/src/main/java/muramasa/gregtech/client/ReactorBakedModel.java b/common/src/main/java/muramasa/gregtech/client/ReactorBakedModel.java index a06131d98..95ff2deab 100644 --- a/common/src/main/java/muramasa/gregtech/client/ReactorBakedModel.java +++ b/common/src/main/java/muramasa/gregtech/client/ReactorBakedModel.java @@ -1,17 +1,23 @@ package muramasa.gregtech.client; import com.google.common.collect.ImmutableMap; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import muramasa.antimatter.AntimatterProperties; import muramasa.antimatter.Ref; import muramasa.antimatter.blockentity.BlockEntityMachine; import muramasa.antimatter.client.ModelUtils; import muramasa.antimatter.client.baked.MachineBakedModel; +import muramasa.antimatter.cover.ICover; import muramasa.antimatter.machine.MachineState; +import muramasa.antimatter.texture.Texture; import muramasa.gregtech.blockentity.single.BlockEntityNuclearReactorCore; +import muramasa.gregtech.data.GregTechCovers; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.entity.BlockEntity; @@ -22,6 +28,7 @@ import java.util.Collections; import java.util.List; import java.util.Random; +import java.util.function.Function; public class ReactorBakedModel extends MachineBakedModel { private final BakedModel[] rodModels; @@ -32,19 +39,45 @@ public ReactorBakedModel(TextureAtlasSprite particle, ImmutableMap getBlockQuads(BlockState state, Direction side, Random rand, BlockAndTintGetter level, @NotNull BlockPos pos) { - List superBlockQuads = super.getBlockQuads(state, side, rand, level, pos); + if (side == null) { + return Collections.emptyList(); + } + BlockEntity tile = level.getBlockEntity(pos); + if (!(tile instanceof BlockEntityNuclearReactorCore core)) return Collections.emptyList(); + AntimatterProperties.MachineProperties props = getMachineProperty(core); + if (props == null) return Collections.emptyList(); + List superBlockQuads = new ObjectArrayList<>(20); + List coverQuads = getCoverQuads(state, side, rand, props, core, level, pos); + ICover cover = props.covers[side.get3DDataValue()]; + boolean isOutputCover = cover.getFactory() == GregTechCovers.COVER_REACTOR_OUTPUT || cover.getFactory() == GregTechCovers.COVER_REACTOR_OUTPUT_SECONDARY; + if (!coverQuads.isEmpty()) { + if (isOutputCover) { + return coverQuads; + } + Function ft = core.getMultiTexture(); + List machineQuads = props.machineTexturer.getQuads("machine", new ObjectArrayList<>(), state, props.type, new BlockEntityMachine.DynamicKey(new ResourceLocation(props.type.getId()), ft.apply(side), side, props.state, props), side.get3DDataValue(), level, pos); + for (int i = 0; i < 2; i++) { + BakedQuad quad = machineQuads.get(i); + if (quad.getDirection() == side.getOpposite()) + coverQuads.add(quad); + } + return coverQuads; + } + BakedModel model = getModel(state, side, props.state, props.type); + for (Direction dir : Ref.DIRS) { + superBlockQuads.addAll(ModelUtils.getQuadsFromBaked(model, state, dir, rand, level, pos)); + } + superBlockQuads.addAll(ModelUtils.getQuadsFromBaked(model, state, null, rand, level, pos)); if (side == Direction.UP){ List list = new ArrayList<>(); - BlockEntity tile = level.getBlockEntity(pos); - if (!(tile instanceof BlockEntityNuclearReactorCore core)) return Collections.emptyList(); for (int i = 0; i < 4; i++) { ItemStack rod = core.getRod(i); if (rod.isEmpty()) continue; - BakedModel model = rodModels[i]; + BakedModel rodModel = rodModels[i]; for (Direction dir : Ref.DIRS) { - list.addAll(ModelUtils.getQuadsFromBaked(model, state, dir, rand, level, pos)); + list.addAll(ModelUtils.getQuadsFromBaked(rodModel, state, dir, rand, level, pos)); } - list.addAll(ModelUtils.getQuadsFromBaked(model, state, null, rand, level, pos)); + list.addAll(ModelUtils.getQuadsFromBaked(rodModel, state, null, rand, level, pos)); } list.addAll(superBlockQuads); return list; diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverReactorOutput.java b/common/src/main/java/muramasa/gregtech/cover/CoverReactorOutput.java index a3bb64bba..340755323 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverReactorOutput.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverReactorOutput.java @@ -7,6 +7,7 @@ import muramasa.antimatter.cover.CoverOutput; import muramasa.antimatter.machine.MachineState; import muramasa.antimatter.machine.Tier; +import muramasa.gregtech.GTIRef; import muramasa.gregtech.blockentity.single.BlockEntityNuclearReactorCore; import muramasa.gregtech.blockentity.single.BlockEntitySteamMachine; import net.fabricmc.api.EnvType; @@ -39,7 +40,7 @@ public boolean canPlace() { @Override public ResourceLocation getModel(String type, Direction dir) { if (type.equals("pipe")) return PIPE_COVER_MODEL; - return getBasicModel(); + return new ResourceLocation(GTIRef.ID + ":block/cover/nuclear"); } @Override diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverReactorOutputSecondary.java b/common/src/main/java/muramasa/gregtech/cover/CoverReactorOutputSecondary.java index f0f5516e0..89646bbdb 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverReactorOutputSecondary.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverReactorOutputSecondary.java @@ -2,6 +2,7 @@ import earth.terrarium.botarium.common.fluid.base.FluidHolder; import earth.terrarium.botarium.common.fluid.base.PlatformFluidHandler; +import muramasa.antimatter.Ref; import muramasa.antimatter.blockentity.BlockEntityCache; import muramasa.antimatter.capability.ICoverHandler; import muramasa.antimatter.capability.machine.MachineFluidHandler; @@ -10,6 +11,7 @@ import muramasa.antimatter.cover.CoverOutput; import muramasa.antimatter.machine.Tier; import muramasa.antimatter.util.Utils; +import muramasa.gregtech.GTIRef; import muramasa.gregtech.blockentity.single.BlockEntityNuclearReactorCore; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -30,7 +32,7 @@ public boolean canPlace() { @Override public ResourceLocation getModel(String type, Direction dir) { if (type.equals("pipe")) return PIPE_COVER_MODEL; - return getBasicModel(); + return new ResourceLocation(GTIRef.ID + ":block/cover/nuclear"); } @Override diff --git a/common/src/main/resources/assets/gti/models/block/cover/nuclear.json b/common/src/main/resources/assets/gti/models/block/cover/nuclear.json new file mode 100644 index 000000000..4f2120297 --- /dev/null +++ b/common/src/main/resources/assets/gti/models/block/cover/nuclear.json @@ -0,0 +1,21 @@ +{ + "credit": "Made with Blockbench", + "elements": [ + { + "from": [0, 0, 14], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0}, + "south": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} + } + }, + { + "from": [0, 0, 14], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#overlay"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#overlay"} + } + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/down.json b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/down.json index a6a1e6ec0..2ed9f09f8 100644 --- a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/down.json +++ b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/down.json @@ -1,17 +1,20 @@ { + "credit": "Made with Blockbench", "elements": [ { "from": [0, 0, 0], - "to": [16, 0, 16], + "to": [16, 2, 16], "faces": { + "up": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0}, "down": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} } }, { "from": [0, 0, 0], - "to": [16, 0, 16], + "to": [16, 2, 16], "faces": { - "down": {"uv": [0, 0, 16, 16], "texture": "#overlay", "tintindex": -1} + "up": {"uv": [0, 0, 16, 16], "texture": "#overlay"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#overlay"} } } ] diff --git a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/east.json b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/east.json index 033310dd9..6337fe283 100644 --- a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/east.json +++ b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/east.json @@ -1,17 +1,20 @@ { + "credit": "Made with Blockbench", "elements": [ { - "from": [16, 0, 0], + "from": [14, 0, 0], "to": [16, 16, 16], "faces": { - "east": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} + "east": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0}, + "west": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} } }, { - "from": [16, 0, 0], + "from": [14, 0, 0], "to": [16, 16, 16], "faces": { - "east": {"uv": [0, 0, 16, 16], "texture": "#overlay", "tintindex": -1} + "east": {"uv": [0, 0, 16, 16], "texture": "#overlay"}, + "west": {"uv": [0, 0, 16, 16], "texture": "#overlay"} } } ] diff --git a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/north.json b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/north.json index c42c6354f..e35411e80 100644 --- a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/north.json +++ b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/north.json @@ -1,17 +1,20 @@ { + "credit": "Made with Blockbench", "elements": [ { "from": [0, 0, 0], - "to": [16, 16, 0], + "to": [16, 16, 2], "faces": { - "north": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} + "north": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0}, + "south": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} } }, { "from": [0, 0, 0], - "to": [16, 16, 0], + "to": [16, 16, 2], "faces": { - "north": {"uv": [0, 0, 16, 16], "texture": "#overlay", "tintindex": -1} + "north": {"uv": [0, 0, 16, 16], "texture": "#overlay"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#overlay"} } } ] diff --git a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/south.json b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/south.json index b837dfe87..4f2120297 100644 --- a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/south.json +++ b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/south.json @@ -1,17 +1,20 @@ { + "credit": "Made with Blockbench", "elements": [ { - "from": [0, 0, 16], + "from": [0, 0, 14], "to": [16, 16, 16], "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0}, "south": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} } }, { - "from": [0, 0, 16], + "from": [0, 0, 14], "to": [16, 16, 16], "faces": { - "south": {"uv": [0, 0, 16, 16], "texture": "#overlay", "tintindex": -1} + "north": {"uv": [0, 0, 16, 16], "texture": "#overlay"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#overlay"} } } ] diff --git a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/up.json b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/up.json index 0525968a0..511c4df87 100644 --- a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/up.json +++ b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/up.json @@ -2,17 +2,19 @@ "credit": "Made with Blockbench", "elements": [ { - "from": [0, 16, 0], + "from": [0, 14, 0], "to": [16, 16, 16], "faces": { - "up": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} + "up": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0}, + "down": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} } }, { - "from": [0, 16, 0], + "from": [0, 14, 0], "to": [16, 16, 16], "faces": { - "up": {"uv": [0, 0, 16, 16], "texture": "#overlay", "tintindex": -1} + "up": {"uv": [0, 0, 16, 16], "texture": "#overlay"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#overlay"} } } ] diff --git a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/west.json b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/west.json index 0397ce929..959f1c3d8 100644 --- a/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/west.json +++ b/common/src/main/resources/assets/gti/models/block/machine/overlay/nuclear_reactor_core/west.json @@ -1,17 +1,20 @@ { + "credit": "Made with Blockbench", "elements": [ { "from": [0, 0, 0], - "to": [0, 16, 16], + "to": [2, 16, 16], "faces": { + "east": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0}, "west": {"uv": [0, 0, 16, 16], "texture": "#base", "tintindex": 0} } }, { "from": [0, 0, 0], - "to": [0, 16, 16], + "to": [2, 16, 16], "faces": { - "west": {"uv": [0, 0, 16, 16], "texture": "#overlay", "tintindex": -1} + "east": {"uv": [0, 0, 16, 16], "texture": "#overlay"}, + "west": {"uv": [0, 0, 16, 16], "texture": "#overlay"} } } ]