mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-03 05:57:40 -05:00
21w37a
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
|
||||
package dev.architectury.hooks.block.fabric;
|
||||
|
||||
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
@@ -42,15 +41,11 @@ public class BlockEntityHooksImpl {
|
||||
* limitations under the License.
|
||||
*/
|
||||
public static void syncData(BlockEntity entity) {
|
||||
if (entity instanceof BlockEntityClientSerializable) {
|
||||
((BlockEntityClientSerializable) entity).sync();
|
||||
var world = Objects.requireNonNull(entity.getLevel());
|
||||
if (!(world instanceof ServerLevel)) {
|
||||
throw new IllegalStateException("Cannot call sync() on the logical client! Did you check world.isClient first?");
|
||||
} else {
|
||||
var world = Objects.requireNonNull(entity.getLevel());
|
||||
if (!(world instanceof ServerLevel)) {
|
||||
throw new IllegalStateException("Cannot call sync() on the logical client! Did you check world.isClient first?");
|
||||
} else {
|
||||
((ServerLevel) world).getChunkSource().blockChanged(entity.getBlockPos());
|
||||
}
|
||||
((ServerLevel) world).getChunkSource().blockChanged(entity.getBlockPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +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.mixin.fabric;
|
||||
|
||||
import dev.architectury.extensions.BlockEntityExtension;
|
||||
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(BlockEntityExtension.class)
|
||||
public interface MixinBlockEntityExtension extends BlockEntityClientSerializable {
|
||||
@Override
|
||||
default void fromClientTag(CompoundTag tag) {
|
||||
var entity = (BlockEntity) this;
|
||||
if (entity.hasLevel()) {
|
||||
((BlockEntityExtension) this).loadClientData(entity.getBlockState(), tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default CompoundTag toClientTag(CompoundTag tag) {
|
||||
return ((BlockEntityExtension) this).saveClientData(tag);
|
||||
}
|
||||
}
|
||||
@@ -20,15 +20,14 @@
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.ChunkEvent;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiManager;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.chunk.*;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -39,11 +38,11 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
@Mixin(ChunkSerializer.class)
|
||||
public class MixinChunkSerializer {
|
||||
@Inject(method = "read", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void load(ServerLevel serverLevel, StructureManager structureManager, PoiManager poiManager, ChunkPos chunkPos, CompoundTag compoundTag,
|
||||
CallbackInfoReturnable<ProtoChunk> cir, ChunkGenerator chunkGenerator, BiomeSource biomeSource, CompoundTag compoundTagLevelData,
|
||||
ChunkBiomeContainer chunkBiomeContainer, UpgradeData upgradeData, ProtoTickList<?> protoTickList, ProtoTickList<?> protoTickList2,
|
||||
boolean bl, ListTag listTag, int i, LevelChunkSection[] levelChunkSections, boolean bl2, ChunkSource chunkSource,
|
||||
LevelLightEngine levelLightEngine, long l, ChunkStatus.ChunkType chunkType, ChunkAccess chunk) {
|
||||
ChunkEvent.LOAD_DATA.invoker().load(chunk, serverLevel, compoundTag);
|
||||
private static void load(ServerLevel serverLevel, PoiManager poiManager, ChunkPos chunkPos, CompoundTag compoundTag,
|
||||
CallbackInfoReturnable<ProtoChunk> cir, CompoundTag compoundTag2, UpgradeData upgradeData,
|
||||
ProtoTickList protoTickList, ProtoTickList protoTickList2, boolean bl, ListTag listTag,
|
||||
int i, LevelChunkSection levelChunkSections[], boolean bl2, ChunkSource chunkSource,
|
||||
LevelLightEngine levelLightEngine, Registry registry, long m, ChunkStatus.ChunkType chunkType, ChunkAccess chunkAccess2) {
|
||||
ChunkEvent.LOAD_DATA.invoker().load(chunkAccess2, serverLevel, compoundTag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,20 +129,6 @@ public class BiomeModificationsImpl {
|
||||
context.setCategory(category);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public BiomeProperties.Mutable setDepth(float depth) {
|
||||
context.setDepth(depth);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public BiomeProperties.Mutable setScale(float scale) {
|
||||
context.setScale(scale);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user