This commit is contained in:
shedaniel
2021-09-23 02:44:15 +08:00
parent c3ffa8d976
commit ffe3fbe3f4
15 changed files with 24 additions and 174 deletions

View File

@@ -1,52 +0,0 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 architectury
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package dev.architectury.extensions;
import dev.architectury.hooks.block.BlockEntityHooks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.ApiStatus;
/**
* Extensions to {@link net.minecraft.world.level.block.entity.BlockEntity}, implement this on to your class.
*/
public interface BlockEntityExtension {
/**
* Handles data sent by {@link BlockEntityExtension#saveClientData(CompoundTag)} on the server.
*/
@Environment(EnvType.CLIENT)
void loadClientData(BlockState pos, CompoundTag tag);
/**
* Writes data to sync to the client.
*/
CompoundTag saveClientData(CompoundTag tag);
/**
* Sync data to the clients by {@link BlockEntityExtension#saveClientData(CompoundTag)} and {@link BlockEntityExtension#loadClientData(BlockState, CompoundTag)}.
*/
@ApiStatus.NonExtendable
default void syncData() {
BlockEntityHooks.syncData((BlockEntity) this);
}
}