Pedestals entity fix
This commit is contained in:
parent
1ae6d0d63e
commit
30046b25c8
2 changed files with 15 additions and 36 deletions
|
@ -109,7 +109,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
|
||||||
pedestal.setItem(0, itemStack);
|
pedestal.setItem(0, itemStack);
|
||||||
level.blockEntityChanged(pos);
|
level.blockEntityChanged(pos);
|
||||||
checkRitual(level, pos);
|
checkRitual(level, pos);
|
||||||
return InteractionResult.SUCCESS;//InteractionResult.sidedSuccess(level.isClientSide());
|
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ItemStack itemStack = pedestal.getItem(0);
|
ItemStack itemStack = pedestal.getItem(0);
|
||||||
|
@ -117,7 +117,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
|
||||||
pedestal.removeItemNoUpdate(0);
|
pedestal.removeItemNoUpdate(0);
|
||||||
level.blockEntityChanged(pos);
|
level.blockEntityChanged(pos);
|
||||||
checkRitual(level, pos);
|
checkRitual(level, pos);
|
||||||
return InteractionResult.SUCCESS;//InteractionResult.sidedSuccess(level.isClientSide());
|
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||||
}
|
}
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package ru.betterend.blocks.entities;
|
package ru.betterend.blocks.entities;
|
||||||
|
|
||||||
//import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||||
|
@ -15,13 +13,9 @@ import ru.betterend.blocks.basis.PedestalBlock;
|
||||||
import ru.betterend.registry.EndBlockEntities;
|
import ru.betterend.registry.EndBlockEntities;
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
|
|
||||||
// TODO Fix client serialisation
|
public class PedestalBlockEntity extends BlockEntity implements Container {
|
||||||
public class PedestalBlockEntity extends BlockEntity implements Container/*, BlockEntityClientSerializable*/ {
|
|
||||||
private ItemStack activeItem = ItemStack.EMPTY;
|
private ItemStack activeItem = ItemStack.EMPTY;
|
||||||
|
|
||||||
//private final int maxAge = 314;
|
|
||||||
//private int age;
|
|
||||||
|
|
||||||
public PedestalBlockEntity(BlockPos blockPos, BlockState blockState) {
|
public PedestalBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
this(EndBlockEntities.PEDESTAL, blockPos, blockState);
|
this(EndBlockEntities.PEDESTAL, blockPos, blockState);
|
||||||
}
|
}
|
||||||
|
@ -30,13 +24,18 @@ public class PedestalBlockEntity extends BlockEntity implements Container/*, Blo
|
||||||
super(blockEntityType, blockPos, blockState);
|
super(blockEntityType, blockPos, blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public int getAge() {
|
protected void toTag(CompoundTag tag) {
|
||||||
return age;
|
if (activeItem != ItemStack.EMPTY) {
|
||||||
}*/
|
tag.put("active_item", activeItem.save(new CompoundTag()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*public int getMaxAge() {
|
protected void fromTag(CompoundTag tag) {
|
||||||
return maxAge;
|
if (tag.contains("active_item")) {
|
||||||
}*/
|
CompoundTag itemTag = tag.getCompound("active_item");
|
||||||
|
activeItem = ItemStack.of(itemTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getContainerSize() {
|
public int getContainerSize() {
|
||||||
|
@ -114,29 +113,9 @@ public class PedestalBlockEntity extends BlockEntity implements Container/*, Blo
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
super.saveAdditional(tag);
|
super.saveAdditional(tag);
|
||||||
fromTag(tag);
|
toTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fromTag(CompoundTag tag) {
|
|
||||||
if (tag.contains("active_item")) {
|
|
||||||
CompoundTag itemTag = tag.getCompound("active_item");
|
|
||||||
activeItem = ItemStack.of(itemTag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public static <T extends BlockEntity> void tick(Level level, BlockPos blockPos, BlockState blockState, T uncastedEntity) {
|
|
||||||
clientTick(level, blockPos, blockState, (PedestalBlockEntity) uncastedEntity);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*private static void clientTick(Level tickLevel, BlockPos tickPos, BlockState tickState, PedestalBlockEntity blockEntity) {
|
|
||||||
if (!blockEntity.isEmpty()) {
|
|
||||||
blockEntity.age++;
|
|
||||||
if (blockEntity.age > blockEntity.maxAge) {
|
|
||||||
blockEntity.age = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||||
return ClientboundBlockEntityDataPacket.create(this);
|
return ClientboundBlockEntityDataPacket.create(this);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue