Skip to content

Commit

Permalink
textures & networking fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Sep 8, 2024
1 parent 719a5f1 commit 35a5c18
Show file tree
Hide file tree
Showing 33 changed files with 317 additions and 178 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// 1.21.1 2024-09-08T20:54:17.6791305 Item Models: modjam
207e815e9b4c9ebca4f444f877e2488a5ce9b1c5 assets/modjam/models/item/aquarine_steel.json
// 1.21.1 2024-09-08T20:58:34.718144882 Item Models: modjam
51765874ad3111adf69684269ad9a422bfbaac4a assets/modjam/models/item/aquarine_steel_block.json
e674d6859446f65b4ee805ed6e9f47d6cde82515 assets/modjam/models/item/aquarine_steel_ingot.json
098a336dd0b210f2b650174de2346a665b921edd assets/modjam/models/item/aquarine_steel_wrench.json
dd0c37deb1f33fb0844da4a540706681887fc3d4 assets/modjam/models/item/aquatic_catalyst.json
66eb6899181dacf931e95e546a991d5e25dcc5da assets/modjam/models/item/atlantic_gold_ingot.json
246cda7a0fca8b278dd6ed5392d0ce745d9fa097 assets/modjam/models/item/chiseled_dark_prismarine.json
4d6b8c829a1afa42db37e92f67ddf057d763b124 assets/modjam/models/item/crate.json
b918bbc26234f9f47c0330279cee33fb368261df assets/modjam/models/item/crowbar.json
5dd5fd7a7c348bbaf51df14605c5241bf75e18ae assets/modjam/models/item/dark_prismarine_pillar.json
4d48047a9639345841262719f87f57c3494e4a55 assets/modjam/models/item/deep_sea_drain.json
945ba48b672ffdee7c76e0939012a2b60ce471a6 assets/modjam/models/item/eas_bucket.json
5b6b9e8621c065cb4167e4b6dfdfaecb0fd7186d assets/modjam/models/item/eas_vial.json
f0f9891cd57b3a66f7440a71b925348bb8ea745b assets/modjam/models/item/glass_vial.json
dab337d602d93b0a4930b69e652b1155300c6502 assets/modjam/models/item/prism_monocle.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// 1.21.1 2024-09-08T12:32:55.0498344 Recipes
// 1.21.1 2024-09-08T20:58:34.720183238 Recipes
212d75a5fccad42ec0cc51d1e1dfe77b53a8b988 data/minecraft/recipe/netherite_ingot.json
e6305710cc75c951fede63dbafbfde7bbd146a5d data/modjam/recipe/aquarine_steel.json
6a3498b9b03ea934405ac04d33c6714f372eeb3f data/modjam/recipe/aquarine_steel_ingot.json

This file was deleted.

10 changes: 0 additions & 10 deletions src/generated/resources/data/modjam/recipe/aquarine_steel.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ private void checkConnections() {
BlockPos pos = worldPosition.relative(direction, i);
BlockState state = level.getBlockState(pos);

if (state.getBlock() instanceof LaserBlock) {
laserDistances.put(direction, i);
break;
if (level.getBlockEntity(pos) instanceof LaserBlockEntity laserBlockEntity) {
if (laserBlockEntity.getLaserInputs().contains(direction.getOpposite())) {
laserDistances.put(direction, i);
break;
}
}

if (!state.canBeReplaced() || i == MAX_DISTANCE - 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, Block

@Override
public void onRemove(BlockState p_60515_, Level level, BlockPos pos, BlockState p_60518_, boolean p_60519_) {
if (!p_60515_.is(p_60518_.getBlock())) {
BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity instanceof ContainerBlockEntity containerBlockEntity && containerBlockEntity.getItemHandler() != null) {
containerBlockEntity.drop();
}
}
super.onRemove(p_60515_, level, pos, p_60518_, p_60519_);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package com.portingdeadmods.modjam.api.blocks.blockentities;

import com.google.common.collect.ImmutableSet;
import com.portingdeadmods.modjam.ModJam;
import com.portingdeadmods.modjam.registries.MJDataAttachments;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;

public abstract class LaserBlock extends ContainerBlock {
public LaserBlock(Properties properties) {
super(properties);
Expand All @@ -17,18 +10,4 @@ public boolean tickingEnabled() {
return true;
}

@Override
protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) {
super.onPlace(state, level, pos, oldState, movedByPiston);
// ChunkAccess chunk = level.getChunk(pos);
// Set<BlockPos> chunkLasers = chunk.getData(MJDataAttachments.CHUNK_LASERS);
// ImmutableSet<BlockPos> newSet = ImmutableSet.<BlockPos>builder().addAll(chunkLasers).add(pos).build();
// chunk.setData(MJDataAttachments.CHUNK_LASERS, newSet);
// ModJam.LOGGER.debug("Chunk lasers: {}", chunkLasers);
}

@Override
public void onRemove(BlockState p_60515_, Level level, BlockPos pos, BlockState p_60518_, boolean p_60519_) {
super.onRemove(p_60515_, level, pos, p_60518_, p_60519_);
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
package com.portingdeadmods.modjam.capabilities.augmentation;

public enum Slot {
HEAD(0),
BODY(1),
ARMS(2),
LEGS(3),
HEART(4),
NONE(-1);
HEAD(0),
BODY(1),
ARMS(2),
LEGS(3),
HEART(4),
NONE(-1);

public int slotId;
Slot(int id){
this.slotId = id;
}
public boolean Compare(int i){return slotId == i;}
public static Slot GetValue(int _id)
{
Slot[] Slots = Slot.values();
for(int i = 0; i < Slots.length; i++)
{
if(Slots[i].Compare(_id))
return Slots[i];
}
return Slot.NONE;
public int slotId;

Slot(int id) {
this.slotId = id;
}

public boolean Compare(int i) {
return slotId == i;
}

public static Slot GetValue(int _id) {
Slot[] Slots = Slot.values();
for (int i = 0; i < Slots.length; i++) {
if (Slots[i].Compare(_id))
return Slots[i];
}
return Slot.NONE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ public class DrainTopModel extends Model {
// This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(ModJam.MODID, "drain_top"), "main");
private final ModelPart top;
private final ModelPart valve;

public DrainTopModel(ModelPart root) {
super(RenderType::entityTranslucent);
this.top = root.getChild("top");
this.valve = root.getChild("valve");
}

public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();

PartDefinition top = partdefinition.addOrReplaceChild("top", CubeListBuilder.create().texOffs(0, 0).addBox(-30.0F, -19.0F, -14.0F, 44.0F, 3.0F, 44.0F, new CubeDeformation(0.0F))
.texOffs(0, 47).addBox(-20.0F, -21.0F, -4.0F, 24.0F, 2.0F, 24.0F, new CubeDeformation(0.0F))
.texOffs(0, 16).addBox(-10.0F, -25.0F, 6.0F, 4.0F, 4.0F, 4.0F, new CubeDeformation(0.0F))
.texOffs(56, 47).addBox(-16.0F, -25.0F, 0.0F, 16.0F, 0.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offset(8.0F, 40.0F, -8.0F));
.texOffs(0, 47).addBox(-20.0F, -21.0F, -4.0F, 24.0F, 2.0F, 24.0F, new CubeDeformation(0.0F)), PartPose.offset(8.0F, 40.0F, -8.0F));

PartDefinition cube_r1 = top.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, -2.0F, -3.0F, 4.0F, 2.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-9.0F, -18.0042F, -5.9937F, 0.3927F, 0.0F, 0.0F));

Expand All @@ -43,6 +43,9 @@ public static LayerDefinition createBodyLayer() {

PartDefinition cube_r4 = top.addOrReplaceChild("cube_r4", CubeListBuilder.create().texOffs(0, 8).addBox(-3.0F, -2.0F, -3.0F, 4.0F, 2.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-7.0F, -18.0042F, 22.0063F, -0.3927F, 0.0F, 0.0F));

PartDefinition valve = partdefinition.addOrReplaceChild("valve", CubeListBuilder.create().texOffs(56, 47).addBox(-8.0F, -9.0F, -8.0F, 16.0F, 0.0F, 16.0F, new CubeDeformation(0.0F))
.texOffs(0, 16).addBox(-2.0F, -9.0F, -2.0F, 4.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F));

return LayerDefinition.create(meshdefinition, 256, 256);
}

Expand All @@ -51,7 +54,8 @@ public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packe
poseStack.pushPose();
{
poseStack.translate(1.0625, 0, 1.0625);
top.render(poseStack, buffer, packedLight, packedOverlay, color);
this.top.render(poseStack, buffer, packedLight, packedOverlay, color);
this.valve.render(poseStack, buffer, packedLight, packedOverlay, color);
}
poseStack.popPose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,60 +18,56 @@
public class AugmentHelper {
private static final HashMap<Integer, StaticAugment> augmentHashMap = new HashMap<>();

public static void AddAugment(StaticAugment augment, int id){
public static void AddAugment(StaticAugment augment, int id) {
augmentHashMap.put(id, augment);
}
public static StaticAugment getAugment(Player player, Slot slot){

public static StaticAugment getAugment(Player player, Slot slot) {
int id = getId(player, slot);
return augmentHashMap.get(id);
}
public static Supplier<AttachmentType<Integer>> getAttachment(Slot slot){
switch (slot){
case HEAD -> {
return MJDataAttachments.HEAD_AUGMENTATION;
}
case BODY -> {
return MJDataAttachments.BODY_AUGMENTATION;
}
case LEGS -> {
return MJDataAttachments.LEGS_AUGMENTATION;
}
case ARMS -> {
return MJDataAttachments.ARMS_AUGMENTATION;
}
case HEART -> {
return MJDataAttachments.HEART_AUGMENTATION;
}
}
ModJam.LOGGER.warn("Error parsing slot {} (I thought this was unreachable)", slot.name());
return MJDataAttachments.HEAD_AUGMENTATION;

public static Supplier<AttachmentType<Integer>> getAttachment(Slot slot) {
return switch (slot) {
case HEAD -> MJDataAttachments.HEAD_AUGMENTATION;
case BODY -> MJDataAttachments.BODY_AUGMENTATION;
case LEGS -> MJDataAttachments.LEGS_AUGMENTATION;
case ARMS -> MJDataAttachments.ARMS_AUGMENTATION;
case HEART -> MJDataAttachments.HEART_AUGMENTATION;
case NONE -> null;
};
}

public static int getId(Player player, Slot slot){
return player.getData(getAttachment(slot));
public static int getId(Player player, Slot slot) {
return player.getData(getAttachment(slot).get());
// return -2;
}

public static void setId(Player player, Slot slot , int id){
if (player.level().isClientSide){
PacketDistributor.sendToServer(new SetAugmentDataPayload(id , slot.slotId));
public static void setId(Player player, Slot slot, int id) {
player.setData(getAttachment(slot).get(), id);
}

public static void setIdAndUpdate(Player player, Slot slot, int id) {
if (player.level().isClientSide()) {
PacketDistributor.sendToServer(new SetAugmentDataPayload(id, slot.slotId));
} else {
PacketDistributor.sendToPlayer((ServerPlayer) player, new SetAugmentDataPayload(id, slot.slotId));
}
setId(player, slot, id);
}

public static void incId(Player player, Slot slot){
setId(player, slot, AugmentHelper.getId(player, slot) + 1);
player.sendSystemMessage(Component.literal("Incremented to Id "+getId(player, slot)+" for slot "+slot.name()));
public static void incId(Player player, Slot slot) {
setIdAndUpdate(player, slot, AugmentHelper.getId(player, slot) + 1);
player.sendSystemMessage(Component.literal("Incremented to Id " + getId(player, slot) + " for slot " + slot.name()));

}

public static void decId(Player player, Slot slot){
setId(player, slot, AugmentHelper.getId(player, slot) - 1);
player.sendSystemMessage(Component.literal("Decremented to Id "+getId(player, slot)+" for slot "+slot.name()));
public static void decId(Player player, Slot slot) {
setIdAndUpdate(player, slot, AugmentHelper.getId(player, slot) - 1);
player.sendSystemMessage(Component.literal("Decremented to Id " + getId(player, slot) + " for slot " + slot.name()));
}

public static StaticAugment getAugment(int id){
public static StaticAugment getAugment(int id) {
return augmentHashMap.get(id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,39 @@

import com.google.common.collect.ImmutableMap;
import com.portingdeadmods.modjam.api.blockentities.LaserBlockEntity;
import com.portingdeadmods.modjam.api.blockentities.multiblock.FakeBlockEntity;
import com.portingdeadmods.modjam.api.blockentities.multiblock.SavesControllerPosBlockEntity;
import com.portingdeadmods.modjam.capabilities.IOActions;
import com.portingdeadmods.modjam.registries.MJBlockEntityTypes;
import it.unimi.dsi.fastutil.Pair;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.capabilities.BlockCapability;
import org.jetbrains.annotations.Nullable;

public class DrainPartBlockEntity extends LaserBlockEntity {
public class DrainPartBlockEntity extends LaserBlockEntity implements FakeBlockEntity, SavesControllerPosBlockEntity {
private BlockPos controllerPos;
private Direction laserPort;

public DrainPartBlockEntity(BlockPos blockPos, BlockState blockState) {
super(MJBlockEntityTypes.DRAIN_PART.get(), blockPos, blockState);
}

public void setLaserPort(Direction laserPort) {
this.laserPort = laserPort;
}

public boolean hasLaserPort() {
return laserPort != null;
}

@Override
public ObjectSet<Direction> getLaserInputs() {
return ObjectSet.of();
return ObjectSet.of(laserPort);
}

@Override
Expand All @@ -31,4 +46,48 @@ public ObjectSet<Direction> getLaserOutputs() {
public <T> ImmutableMap<Direction, Pair<IOActions, int[]>> getSidedInteractions(BlockCapability<T, @Nullable Direction> capability) {
return ImmutableMap.of();
}

@Override
public boolean actualBlockEntity() {
return false;
}

@Override
public @Nullable BlockPos getActualBlockEntityPos() {
return this.controllerPos;
}

@Override
public void setControllerPos(BlockPos blockPos) {
this.controllerPos = blockPos;
}

@Override
protected void loadData(CompoundTag tag, HolderLookup.Provider provider) {
super.loadData(tag, provider);
boolean hasControllerPos = tag.getBoolean("hasControllerPos");
boolean hasLaserPort = tag.getBoolean("hasLaserPort");
if (hasControllerPos) {
this.controllerPos = BlockPos.of(tag.getLong("controllerPos"));
}

if (hasLaserPort) {
this.laserPort = Direction.values()[tag.getInt("laserPort")];
}
}

@Override
protected void saveData(CompoundTag tag, HolderLookup.Provider provider) {
super.saveData(tag, provider);
tag.putBoolean("hasControllerPos", this.controllerPos != null);
tag.putBoolean("hasLaserPort", this.laserPort != null);

if (this.controllerPos != null) {
tag.putLong("controllerPos", this.controllerPos.asLong());
}

if (this.laserPort != null) {
tag.putInt("laserPort", this.laserPort.ordinal());
}
}
}
Loading

0 comments on commit 35a5c18

Please sign in to comment.