ExDeorum/src/main/java/thedarkcolour/exdeorum/blockentity/EBlockEntity.java
2026-04-05 12:44:54 -07:00

82 lines
2.8 KiB
Java

/*
* Ex Deorum
* Copyright (c) 2024 thedarkcolour
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package thedarkcolour.exdeorum.blockentity;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Connection;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import thedarkcolour.exdeorum.network.VisualUpdateTracker;
public abstract class EBlockEntity extends BlockEntity {
public EBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}
// todo is this even necessary?
@Override
public CompoundTag getUpdateTag(HolderLookup.Provider registries) {
return saveWithoutMetadata(registries);
}
@Override
public ClientboundBlockEntityDataPacket getUpdatePacket() {
return ClientboundBlockEntityDataPacket.create(this);
}
@Override
public void onDataPacket(Connection net, ValueInput valueInput) {
loadAdditional(valueInput);
}
public void markUpdated() {
setChanged();
VisualUpdateTracker.sendVisualUpdate(this);
}
public void writeVisualData(RegistryFriendlyByteBuf buffer) {
}
public void readVisualData(RegistryFriendlyByteBuf buffer) {
}
// Only called when data is sent by a local server
public void copyVisualData(BlockEntity fromIntegratedServer) {
}
public InteractionResult useItemOn(Level level, Player player, ItemStack stack, InteractionHand hand) {
return InteractionResult.TRY_WITH_EMPTY_HAND;
}
public InteractionResult useWithoutItem(Level level, Player player) {
return InteractionResult.PASS;
}
}