Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
IAFEnvoy committed Jan 8, 2025
1 parent cad9528 commit 794ddf6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.iafenvoy.sow.item.block.entity.WallsOfTimeBlockEntity;
import com.iafenvoy.sow.registry.SowItemGroups;
import net.minecraft.block.BlockState;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -13,6 +14,7 @@
import net.minecraft.util.Hand;
import net.minecraft.util.Rarity;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -52,9 +54,12 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> too

@Override
public ActionResult useOnBlock(ItemUsageContext context) {
if (context.getWorld().getBlockEntity(context.getBlockPos()) instanceof WallsOfTimeBlockEntity blockEntity) {
World world = context.getWorld();
BlockPos pos = context.getBlockPos();
BlockState state = world.getBlockState(pos);
if (world.getBlockEntity(pos) instanceof WallsOfTimeBlockEntity blockEntity) {
WallsOfTimeBlockEntity.EditType.valueOf(context.getStack().getOrCreateNbt().getString(EDIT_TYPE_KEY)).getProcess().accept(blockEntity.getContents());
blockEntity.sync();
world.updateListeners(pos, state, state, 0);
return ActionResult.SUCCESS;
}
return super.useOnBlock(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
NbtList nbtList = stack.getOrCreateNbt().getList("pages", 8);
if (nbtList != null) {
blockEntity.getContents().withContent(stack.copy()).withDirection(hit.getSide());
blockEntity.sync();
world.updateListeners(pos, state, state, 0);
return ActionResult.SUCCESS;
}
} else if (stack.isOf(Items.WRITABLE_BOOK)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class ArdoniGraveBlockEntity extends BlockEntity {
private boolean fixed;
private Identifier texturePath = Identifier.tryParse("");
private ArdoniType ardoniType = ArdoniType.NONE;
private boolean fulfulled = false;

public ArdoniGraveBlockEntity(BlockPos pos, BlockState state) {
super(SowBlockEntities.ARDONI_GRAVE.get(), pos, state);
Expand All @@ -44,7 +43,6 @@ protected void writeNbt(NbtCompound nbt) {
nbt.putBoolean("fixed", this.isFixed());
nbt.putString("type", this.getArdoniType().id());
nbt.putString("texturePath", this.getTexturePath().toString());
this.fulfulled = true;
}

public boolean isFixed() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.iafenvoy.sow.item.block.entity;

import com.iafenvoy.neptune.ServerHelper;
import com.iafenvoy.neptune.network.ServerNetworkHelper;
import com.iafenvoy.sow.SongsOfWar;
import com.iafenvoy.sow.registry.SowBlockEntities;
import com.iafenvoy.sow.util.BookUtils;
Expand All @@ -16,7 +14,6 @@
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.Nullable;
Expand All @@ -26,7 +23,6 @@

public class WallsOfTimeBlockEntity extends BlockEntity {
private WotContents contents = WotContents.EMPTY.get();
private boolean fulfilled = false;

public WallsOfTimeBlockEntity(BlockPos pos, BlockState state) {
super(SowBlockEntities.WALLS_OF_TIME.get(), pos, state);
Expand All @@ -36,7 +32,6 @@ public WallsOfTimeBlockEntity(BlockPos pos, BlockState state) {
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
this.contents = WotContents.CODEC.parse(NbtOps.INSTANCE, nbt.get("content")).resultOrPartial(SongsOfWar.LOGGER::error).orElse(WotContents.EMPTY.get());
this.fulfilled = true;
}

@Override
Expand All @@ -49,12 +44,6 @@ public WotContents getContents() {
return this.contents;
}

public void sync() {
if (this.world != null && this.world.isClient || ServerHelper.server == null) return;
for (ServerPlayerEntity player : ServerHelper.server.getPlayerManager().getPlayerList())
ServerNetworkHelper.sendBlockEntityData(player, this.pos, this);
}

@Nullable
@Override
public Packet<ClientPlayPacketListener> toUpdatePacket() {
Expand Down

0 comments on commit 794ddf6

Please sign in to comment.