Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 2094528

Browse files
committed
Fix a bunch of issues
1 parent 9f72b76 commit 2094528

36 files changed

+341
-605
lines changed

common/src/main/java/com/jab125/version/SemanticVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public interface SemanticVersion extends Version {
8585
boolean hasWildcard();
8686

8787
/**
88-
* @deprecated Use {@link #compareTo(Version)} instead
88+
* @deprecated Use {@link #compareTo(Object)} instead
8989
*/
9090
@Deprecated
9191
default int compareTo(SemanticVersion o) {

common/src/main/java/com/jab125/version/VersionInterval.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* <p>The represented version interval is contiguous between its lower and upper limit, disjoint intervals are built
2626
* using collections of {@link VersionInterval}. Empty intervals may be represented by {@code null} or any interval
27-
* @code (x,x)} with x being a non-{@code null} version and both endpoints being exclusive.
27+
* {@code (x,x)} with x being a non-{@code null} version and both endpoints being exclusive.
2828
*/
2929
public interface VersionInterval {
3030
VersionInterval INFINITE = new VersionIntervalImpl(null, false, null, false);

common/src/main/java/dev/ultreon/devices/ClientModEvents.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ public static void registerRenderers() {
245245

246246
public static void registerLayerDefinitions() {
247247
LOGGER.info("Registering layer definitions.");
248-
// EntityModelLayerRegistry.register(PrinterRenderer.PaperModel.LAYER_LOCATION, PrinterRenderer.PaperModel::createBodyLayer);
248+
EntityRendererRegistry entityRendererRegistry = XinexPlatform.client().entityRenderers();
249+
entityRendererRegistry.registerModel(PrinterRenderer.PaperModel.LAYER_LOCATION, PrinterRenderer.PaperModel::createBodyLayer);
249250
}
250251
}

common/src/main/java/dev/ultreon/devices/Devices.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -379,17 +379,17 @@ private static void setupEvents() {
379379
EventSystem.MAIN.on(ServerStoppedEvent.class, event -> server = null);
380380

381381
EventSystem.MAIN.on(UseBlockEvent.class, event -> {
382-
Player player = event.getPlayer();
383-
InteractionHand hand = event.getHand();
384-
BlockPos blockPosition = event.getBlockPosition();
385-
Block block = event.getBlock();
386-
Level level = player.level();
387-
if (!player.getItemInHand(hand).isEmpty() && player.getItemInHand(hand).getItem() == Items.PAPER) {
388-
if (block instanceof PrinterBlock) {
389-
event.cancel(InteractionResult.CONSUME);
390-
//event.setUseBlock(Event.Result.ALLOW); //todo
391-
}
392-
}
382+
// Player player = event.getPlayer();
383+
// InteractionHand hand = event.getHand();
384+
// BlockPos blockPosition = event.getBlockPosition();
385+
// Block block = event.getBlock();
386+
// Level level = player.level();
387+
// if (!player.getItemInHand(hand).isEmpty() && player.getItemInHand(hand).getItem() == Items.PAPER) {
388+
// if (block instanceof PrinterBlock) {
389+
// event.cancel(InteractionResult.CONSUME);
390+
// //event.setUseBlock(Event.Result.ALLOW); //todo
391+
// }
392+
// }
393393
});
394394

395395
EventSystem.MAIN.on(ServerPlayerJoinEvent.class, event -> {

common/src/main/java/dev/ultreon/devices/api/task/Callback.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dev.ultreon.devices.api.task;
22

3+
import net.minecraft.core.HolderLookup;
4+
import net.minecraft.nbt.CompoundTag;
35
import org.jetbrains.annotations.Nullable;
46

57
/**
@@ -13,7 +15,7 @@ public interface Callback<T> {
1315
/**
1416
* Executes the callback. You should perform any changes to
1517
* your UI in this method. The NBT tag contains the same data
16-
* as {@link Task#processResponse(NBTTagCompound)}'s
18+
* as {@link Task#processResponse(HolderLookup.Provider, CompoundTag)}'s
1719
* tag does.
1820
*
1921
* @param t the response object

common/src/main/java/dev/ultreon/devices/block/PaperBlock.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
import net.minecraft.core.BlockPos;
77
import net.minecraft.core.Direction;
88
import net.minecraft.world.InteractionResult;
9+
import net.minecraft.world.entity.Entity;
910
import net.minecraft.world.entity.item.ItemEntity;
1011
import net.minecraft.world.entity.player.Player;
1112
import net.minecraft.world.item.ItemStack;
1213
import net.minecraft.world.item.context.BlockPlaceContext;
1314
import net.minecraft.world.level.BlockGetter;
15+
import net.minecraft.world.level.Explosion;
1416
import net.minecraft.world.level.Level;
1517
import net.minecraft.world.level.block.Block;
1618
import net.minecraft.world.level.block.EntityBlock;
@@ -19,7 +21,9 @@
1921
import net.minecraft.world.level.block.entity.BlockEntity;
2022
import net.minecraft.world.level.block.state.BlockState;
2123
import net.minecraft.world.level.block.state.StateDefinition;
24+
import net.minecraft.world.level.gameevent.GameEvent;
2225
import net.minecraft.world.level.storage.loot.LootParams;
26+
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
2327
import net.minecraft.world.phys.BlockHitResult;
2428
import net.minecraft.world.phys.shapes.CollisionContext;
2529
import net.minecraft.world.phys.shapes.VoxelShape;
@@ -82,19 +86,14 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockP
8286

8387
@Override
8488
public List<ItemStack> getDrops(BlockState pState, LootParams.Builder pBuilder) {
85-
return new ArrayList<>();
86-
}
89+
BlockEntity blockEntity = pBuilder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
90+
if (!(blockEntity instanceof PaperBlockEntity paper)) return new ArrayList<>();
8791

88-
@Override
89-
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
90-
if (!level.isClientSide) {
91-
BlockEntity tileEntity = level.getBlockEntity(pos);
92-
if (tileEntity instanceof PaperBlockEntity paper) {
93-
ItemStack drop = IPrint.generateItem(paper.getPrint());
94-
level.addFreshEntity(new ItemEntity(level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop));
95-
}
96-
}
97-
super.onRemove(state, level, pos, newState, isMoving);
92+
IPrint print = paper.getPrint();
93+
if (print == null) return new ArrayList<>();
94+
95+
ItemStack drop = IPrint.generateItem(print);
96+
return List.of(drop);
9897
}
9998

10099
@Override
@@ -103,6 +102,11 @@ public boolean triggerEvent(@NotNull BlockState state, Level level, @NotNull Blo
103102
return blockEntity != null && blockEntity.triggerEvent(id, param);
104103
}
105104

105+
@Override
106+
public boolean dropFromExplosion(Explosion pExplosion) {
107+
return true;
108+
}
109+
106110
@Override
107111
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
108112
pBuilder.add(FACING);

common/src/main/java/dev/ultreon/devices/block/PrinterBlock.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.ultreon.devices.block;
22

33
import com.mojang.serialization.MapCodec;
4+
import dev.ultreon.devices.Devices;
45
import dev.ultreon.devices.ModDeviceTypes;
56
import dev.ultreon.devices.block.entity.PrinterBlockEntity;
67
import dev.ultreon.devices.util.Colored;
@@ -35,7 +36,7 @@ public class PrinterBlock extends DeviceBlock.Colored implements Colored {
3536
box(12, 0, 12, 15, 5, 14),
3637
box(12, 0, 5, 15, 3, 7),
3738
box(1, 0, 5, 4, 3, 7),
38-
box(1, 0, 12, 4, 5, 14),
39+
box(1, 0, 12, 4, 75, 14),
3940
box(1.1, 0, 7, 14.9, 5, 12),
4041
box(4, 0, 12, 12, 3, 14),
4142
box(3.5, 0.1, 1, 12.5, 1.1, 7.5),
@@ -102,20 +103,17 @@ public VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLev
102103

103104
@Override
104105
protected @NotNull ItemInteractionResult useItemOn(@NotNull ItemStack stack, @NotNull BlockState state, Level level, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hitResult) {
105-
if (level.isClientSide) {
106-
if (player.isCrouching()) {
107-
return ItemInteractionResult.SUCCESS;
108-
} else {
109-
return super.useItemOn(stack, state, level, pos, player, hand, hitResult);
110-
}
106+
if (level.isClientSide && player.isCrouching()) {
107+
return ItemInteractionResult.CONSUME;
111108
}
112109
ItemStack heldItem = player.getItemInHand(hand);
113110
BlockEntity tileEntity = level.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE);
114111
if (tileEntity instanceof PrinterBlockEntity) {
115112
return ((PrinterBlockEntity) tileEntity).addPaper(heldItem, player.isCrouching()) ? ItemInteractionResult.SUCCESS : ItemInteractionResult.FAIL;
113+
} else {
114+
Devices.LOGGER.warn("BlockEntity at {} is not a PrinterBlockEntity", pos);
115+
return ItemInteractionResult.FAIL;
116116
}
117-
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
118-
119117
}
120118

121119
@Override

common/src/main/java/dev/ultreon/devices/block/RouterBlock.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,18 @@
33
import com.mojang.serialization.MapCodec;
44
import dev.ultreon.devices.ModDeviceTypes;
55
import dev.ultreon.devices.block.entity.RouterBlockEntity;
6-
import dev.ultreon.devices.network.PacketHandler;
7-
import dev.ultreon.devices.network.task.SyncBlockPacket;
86
import net.minecraft.core.BlockPos;
97
import net.minecraft.core.Direction;
10-
import net.minecraft.world.InteractionResult;
11-
import net.minecraft.world.entity.player.Player;
128
import net.minecraft.world.item.DyeColor;
139
import net.minecraft.world.item.context.BlockPlaceContext;
1410
import net.minecraft.world.level.BlockGetter;
15-
import net.minecraft.world.level.Level;
1611
import net.minecraft.world.level.block.Block;
1712
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
1813
import net.minecraft.world.level.block.SoundType;
1914
import net.minecraft.world.level.block.entity.BlockEntity;
2015
import net.minecraft.world.level.block.state.BlockState;
2116
import net.minecraft.world.level.block.state.StateDefinition;
2217
import net.minecraft.world.level.block.state.properties.BooleanProperty;
23-
import net.minecraft.world.phys.BlockHitResult;
2418
import net.minecraft.world.phys.shapes.CollisionContext;
2519
import net.minecraft.world.phys.shapes.VoxelShape;
2620
import org.jetbrains.annotations.Contract;
@@ -91,21 +85,6 @@ public RouterBlock(Properties properties) {
9185
};
9286
}
9387

94-
@Override
95-
protected @NotNull InteractionResult useWithoutItem(@NotNull BlockState state, Level level, @NotNull BlockPos pos, @NotNull Player player, @NotNull BlockHitResult hitResult) {
96-
if (level.isClientSide && player.isCreative()) {
97-
BlockEntity blockEntity = level.getBlockEntity(pos);
98-
if (blockEntity instanceof RouterBlockEntity router) {
99-
router.setDebug(true);
100-
if (router.isDebug()) {
101-
PacketHandler.sendToServer(new SyncBlockPacket(pos));
102-
}
103-
}
104-
return InteractionResult.SUCCESS;
105-
}
106-
return super.useWithoutItem(state, level, pos, player, hitResult);
107-
}
108-
10988
@Override
11089
public @Nullable BlockState getStateForPlacement(@NotNull BlockPlaceContext pContext) {
11190
BlockState state = super.getStateForPlacement(pContext);

common/src/main/java/dev/ultreon/devices/block/entity/computer/BiosImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public BiosImpl(ComputerBlockEntity blockEntity) {
1515
@Override
1616
public void systemExit(PowerMode state) {
1717
if (state == PowerMode.SHUTDOWN) {
18-
if (blockEntity.isOpen()) {
19-
blockEntity.openClose(null);
18+
if (blockEntity.isPoweredOn()) {
19+
blockEntity.powerOff();
2020
Minecraft.getInstance().setScreen(null);
2121
}
22-
} else if (!blockEntity.isOpen()) {
22+
} else if (!blockEntity.isPoweredOn()) {
2323
Minecraft.getInstance().setScreen(new ComputerScreen(blockEntity));
2424
}
2525
}

common/src/main/java/dev/ultreon/devices/block/entity/computer/ComputerBlockEntity.java

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,10 @@
2323
import java.util.UUID;
2424

2525
public abstract class ComputerBlockEntity extends NetworkDeviceBlockEntity.Colored {
26-
private static final int OPENED_ANGLE = 102;
27-
28-
private boolean open = false;
29-
3026
private CompoundTag applicationData = new CompoundTag();
3127
private CompoundTag systemData = new CompoundTag();
3228
private FileSystem fileSystem;
3329

34-
private int rotation;
35-
36-
private int prevRotation;
37-
3830
private DyeColor externalDriveColor;
3931

4032
protected ComputerBlockEntity(BlockEntityType<? extends ComputerBlockEntity> type, BlockPos pWorldPosition, BlockState pBlockState) {
@@ -49,37 +41,11 @@ public String getDeviceName() {
4941
@Override
5042
public void tick() {
5143
super.tick();
52-
Level level = this.level;
53-
if (level == null) return;
54-
55-
if (getBlockState().getValue(LaptopBlock.OPEN) != open) {
56-
level.setBlock(getBlockPos(), this.getBlockState().setValue(LaptopBlock.OPEN, open), 2);
57-
}
58-
59-
if (level.isClientSide) {
60-
prevRotation = rotation;
61-
if (!open) {
62-
if (rotation > 0) {
63-
rotation -= 10;
64-
}
65-
} else {
66-
if (rotation < OPENED_ANGLE) {
67-
rotation += 10;
68-
}
69-
}
70-
}
7144
}
7245

7346
@Override
7447
public void loadAdditional(@NotNull CompoundTag compound, HolderLookup.@NotNull Provider registries) {
7548
super.loadAdditional(compound, registries);
76-
if (compound.contains("open")) {
77-
this.open = compound.getBoolean("open");
78-
Level level = getLevel();
79-
if (level != null) {
80-
level.setBlock(getBlockPos(), this.getBlockState().setValue(LaptopBlock.OPEN, open), 2);
81-
}
82-
}
8349
if (compound.contains("system_data", Tag.TAG_COMPOUND)) {
8450
this.systemData = compound.getCompound("system_data");
8551
}
@@ -100,7 +66,6 @@ public void loadAdditional(@NotNull CompoundTag compound, HolderLookup.@NotNull
10066
@Override
10167
public void saveAdditional(@NotNull CompoundTag compound, HolderLookup.@NotNull Provider registries) {
10268
super.saveAdditional(compound, registries);
103-
compound.putBoolean("open", open);
10469

10570
if (systemData != null) {
10671
compound.put("system_data", systemData);
@@ -118,7 +83,6 @@ public void saveAdditional(@NotNull CompoundTag compound, HolderLookup.@NotNull
11883
@Override
11984
public CompoundTag saveSyncTag() {
12085
CompoundTag tag = super.saveSyncTag();
121-
tag.putBoolean("open", open);
12286
tag.put("system_data", getSystemData());
12387

12488
if (getFileSystem().getAttachedDrive() != null) {
@@ -140,34 +104,10 @@ public CompoundTag saveSyncTag() {
140104
// return INFINITE_EXTENT_AABB;
141105
// }
142106

143-
public void openClose(@Nullable Entity entity) {
144-
Level level = this.level;
145-
if (level != null) {
146-
level.gameEvent(!open ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, getBlockPos(), GameEvent.Context.of(entity, this.getBlockState()));
147-
}
148-
boolean oldOpen = open;
149-
open = !getBlockState().getValue(LaptopBlock.OPEN);
150-
if (oldOpen != open) {
151-
pipeline.putBoolean("open", open);
152-
var d = getBlockState().setValue(LaptopBlock.OPEN, open);
153-
this.level.setBlock(this.getBlockPos(), d, 18);
154-
sync();
155-
}
156-
157-
if (level != null) {
158-
markUpdated();
159-
doNeighborUpdates(level, this.getBlockPos(), this.getBlockState());
160-
}
161-
}
162-
163-
private static void doNeighborUpdates(Level level, BlockPos pos, BlockState state) {
107+
protected static void doNeighborUpdates(Level level, BlockPos pos, BlockState state) {
164108
state.updateNeighbourShapes(level, pos, 3);
165109
}
166110

167-
public boolean isOpen() {
168-
return open;
169-
}
170-
171111
public CompoundTag getApplicationData() {
172112
return applicationData != null ? applicationData : new CompoundTag();
173113
}
@@ -200,10 +140,6 @@ public void setApplicationData(String appId, CompoundTag applicationData) {
200140
BlockEntityUtil.markBlockForUpdate(level, worldPosition);
201141
}
202142

203-
public float getScreenAngle(float partialTicks) {
204-
return -OPENED_ANGLE * ((prevRotation + (rotation - prevRotation) * partialTicks) / OPENED_ANGLE);
205-
}
206-
207143
public boolean isExternalDriveAttached() {
208144
return externalDriveColor != null;
209145
}
@@ -219,4 +155,12 @@ public Map<UUID, DriveInfo> getDriveInfo() {
219155
public Bios getBios() {
220156
return new BiosImpl(this);
221157
}
158+
159+
public boolean isPoweredOn() {
160+
return true;
161+
}
162+
163+
public void powerOff() {
164+
165+
}
222166
}

0 commit comments

Comments
 (0)