update to 18w47b.10, add BlockEntityRendererRegistry

This commit is contained in:
asie 2018-11-28 17:55:59 +01:00
parent 88abb5f006
commit 9240854fff
15 changed files with 123 additions and 41 deletions

View file

@ -30,8 +30,8 @@ minecraft {
}
dependencies {
minecraft "com.mojang:minecraft:18w47a"
mappings "net.fabricmc:pomf:18w47a.2"
minecraft "com.mojang:minecraft:18w47b"
mappings "net.fabricmc:pomf:18w47b.10"
modCompile "net.fabricmc:fabric-loader:18w44a-0.1.0.46"
}

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2016, 2017, 2018 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.client.render;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.render.block.entity.BlockEntityRenderManager;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import java.util.Map;
public class FabricBlockEntityRendererRegistry {
public static final FabricBlockEntityRendererRegistry INSTANCE = new FabricBlockEntityRendererRegistry();
private Map<Class<? extends BlockEntity>, BlockEntityRenderer<? extends BlockEntity>> blockEntityRenderers;
private FabricBlockEntityRendererRegistry() {
}
public void setBlockEntityRendererMap(Map<Class<? extends BlockEntity>, BlockEntityRenderer<? extends BlockEntity>> map) {
if (blockEntityRenderers != null && blockEntityRenderers != map) {
throw new RuntimeException("Tried to set blockEntityRenderers twice!");
}
blockEntityRenderers = map;
}
public void register(Class<? extends BlockEntity> blockEntityClass, BlockEntityRenderer<? extends BlockEntity> blockEntityRenderer) {
// TODO: warn on duplicate
blockEntityRenderers.put(blockEntityClass, blockEntityRenderer);
blockEntityRenderer.setRenderManager(BlockEntityRenderManager.instance);
}
}

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.commands;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.command.ServerCommandSource;
import net.minecraft.server.command.ServerCommandSource;
import java.util.ArrayList;
import java.util.Collections;

View file

@ -18,8 +18,8 @@ package net.fabricmc.fabric.mixin.commands;
import com.mojang.brigadier.CommandDispatcher;
import net.fabricmc.fabric.commands.CommandRegistry;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.command.ServerCommandSource;
import net.minecraft.server.command.ServerCommandManager;
import net.minecraft.server.command.ServerCommandSource;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

View file

@ -21,12 +21,9 @@ import net.fabricmc.fabric.networking.CustomPayloadHandlerRegistry;
import net.fabricmc.fabric.networking.PacketContext;
import net.fabricmc.fabric.networking.SPacketCustomPayloadAccessor;
import net.minecraft.client.MinecraftGame;
import net.minecraft.client.network.handler.ClientPlayNetworkHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerServer;
import net.minecraft.network.handler.ServerPlayNetworkHandler;
import net.minecraft.network.packet.client.CPacketCustomPayload;
import net.minecraft.network.packet.server.SPacketCustomPayload;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.packet.CustomPayloadClientPacket;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ThreadTaskQueue;
import org.spongepowered.asm.mixin.Mixin;
@ -41,7 +38,7 @@ public class MixinClientPlayNetworkHandler implements PacketContext {
private MinecraftGame game;
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true)
public void onCustomPayload(CPacketCustomPayload packet, CallbackInfo info) {
public void onCustomPayload(CustomPayloadClientPacket packet, CallbackInfo info) {
if (CustomPayloadHandlerRegistry.CLIENT.accept(packet.getChannel(), this, packet.getData())) {
info.cancel();
}
@ -53,7 +50,7 @@ public class MixinClientPlayNetworkHandler implements PacketContext {
}
@Override
public EntityPlayer getPlayer() {
public PlayerEntity getPlayer() {
return game.player;
}

View file

@ -17,13 +17,13 @@
package net.fabricmc.fabric.mixin.networking;
import net.fabricmc.fabric.networking.SPacketCustomPayloadAccessor;
import net.minecraft.network.packet.server.SPacketCustomPayload;
import net.minecraft.server.network.packet.CustomPayloadServerPacket;
import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(SPacketCustomPayload.class)
@Mixin(CustomPayloadServerPacket.class)
public class MixinSPacketCustomPayload implements SPacketCustomPayloadAccessor {
@Shadow
private Identifier channel;

View file

@ -20,11 +20,11 @@ import net.fabricmc.api.Side;
import net.fabricmc.fabric.networking.CustomPayloadHandlerRegistry;
import net.fabricmc.fabric.networking.PacketContext;
import net.fabricmc.fabric.networking.SPacketCustomPayloadAccessor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerServer;
import net.minecraft.network.handler.ServerPlayNetworkHandler;
import net.minecraft.network.packet.server.SPacketCustomPayload;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.network.packet.CustomPayloadServerPacket;
import net.minecraft.util.ThreadTaskQueue;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -37,10 +37,10 @@ public class MixinServerPlayNetworkHandler implements PacketContext {
@Shadow
private MinecraftServer server;
@Shadow
private EntityPlayerServer player;
private ServerPlayerEntity player;
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true)
public void onCustomPayload(SPacketCustomPayload packet, CallbackInfo info) {
public void onCustomPayload(CustomPayloadServerPacket packet, CallbackInfo info) {
SPacketCustomPayloadAccessor accessor = ((SPacketCustomPayloadAccessor) packet);
if (CustomPayloadHandlerRegistry.SERVER.accept(accessor.getChannel(), this, accessor.getData())) {
@ -54,7 +54,7 @@ public class MixinServerPlayNetworkHandler implements PacketContext {
}
@Override
public EntityPlayer getPlayer() {
public PlayerEntity getPlayer() {
return player;
}

View file

@ -23,8 +23,8 @@ import net.fabricmc.fabric.registry.ListenableRegistry;
import net.fabricmc.fabric.registry.RegistryListener;
import net.fabricmc.fabric.registry.RemapException;
import net.fabricmc.fabric.registry.RemappableRegistry;
import net.minecraft.class_3513;
import net.minecraft.util.Identifier;
import net.minecraft.util.Int2ObjectBiMap;
import net.minecraft.util.registry.DefaultMappedRegistry;
import net.minecraft.util.registry.IdRegistry;
import org.apache.logging.log4j.LogManager;
@ -40,7 +40,7 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
@Shadow
protected static Logger ID_LOGGER;
@Shadow
protected class_3513<T> idStore;
protected Int2ObjectBiMap<T> idStore;
@Shadow
protected BiMap<Identifier, T> objectMap;
@Shadow
@ -147,7 +147,7 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
// objectMap.put(identifier, object);
}
idStore.method_15230(object, id);
idStore.put(object, id);
if (nextId <= id) {
nextId = id + 1;
}

View file

@ -21,13 +21,11 @@ import net.fabricmc.fabric.networking.CustomPayloadHandlerRegistry;
import net.fabricmc.fabric.networking.PacketContext;
import net.fabricmc.fabric.networking.SPacketCustomPayloadAccessor;
import net.fabricmc.fabric.registry.RegistrySyncManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerServer;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.Packet;
import net.minecraft.network.handler.ServerPlayNetworkHandler;
import net.minecraft.network.packet.server.SPacketCustomPayload;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ThreadTaskQueue;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -41,7 +39,7 @@ public abstract class MixinServerPlayNetworkHandler {
public abstract void sendPacket(Packet<?> var1);
@Inject(method = "<init>", at = @At("RETURN"))
public void init(MinecraftServer server, ClientConnection connection, EntityPlayerServer player, CallbackInfo info) {
public void init(MinecraftServer server, ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) {
//if (server.isDedicated()) {
sendPacket(RegistrySyncManager.createPacket());
//}

View file

@ -20,7 +20,7 @@ import net.fabricmc.fabric.registry.RegistrySyncManager;
import net.fabricmc.fabric.registry.RemapException;
import net.minecraft.nbt.TagCompound;
import net.minecraft.nbt.TagStorageHelper;
import net.minecraft.world.WorldSaveHandlerOld;
import net.minecraft.world.OldWorldSaveHandler;
import net.minecraft.world.level.LevelProperties;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
@ -34,7 +34,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@Mixin(value = WorldSaveHandlerOld.class)
@Mixin(value = OldWorldSaveHandler.class)
public class MixinWorldSaveHandler {
private static final int ID_REGISTRY_BACKUPS = 3;

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2016, 2017, 2018 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.render;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.client.render.FabricBlockEntityRendererRegistry;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.render.block.entity.BlockEntityRenderManager;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Map;
@Mixin(BlockEntityRenderManager.class)
public class MixinBlockEntityRenderManager {
@Shadow
private Map<Class<? extends BlockEntity>, BlockEntityRenderer<? extends BlockEntity>> blockEntityRenderers;
@Inject(method = "<init>()V", at = @At("RETURN"))
public void init(CallbackInfo info) {
FabricBlockEntityRendererRegistry.INSTANCE.setBlockEntityRendererMap(blockEntityRenderers);
}
}

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.networking;
import net.fabricmc.api.Side;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ThreadTaskQueue;
/**
@ -27,6 +27,6 @@ import net.minecraft.util.ThreadTaskQueue;
*/
public interface PacketContext {
Side getNetworkSide();
EntityPlayer getPlayer();
PlayerEntity getPlayer();
ThreadTaskQueue getTaskQueue();
}

View file

@ -22,9 +22,8 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.fabricmc.fabric.networking.CustomPayloadHandlerRegistry;
import net.fabricmc.fabric.networking.PacketContext;
import net.minecraft.entity.player.EntityPlayerServer;
import net.minecraft.client.network.packet.CustomPayloadClientPacket;
import net.minecraft.nbt.TagCompound;
import net.minecraft.network.packet.client.CPacketCustomPayload;
import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.util.registry.IdRegistry;
@ -44,11 +43,11 @@ public final class RegistrySyncManager {
}
public static CPacketCustomPayload createPacket() {
public static CustomPayloadClientPacket createPacket() {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeTagCompound(toTag(true));
CPacketCustomPayload packet = new CPacketCustomPayload(ID, buf);
CustomPayloadClientPacket packet = new CustomPayloadClientPacket(ID, buf);
return packet;
}

View file

@ -19,7 +19,7 @@ package net.fabricmc.fabric.registry.listeners;
import net.fabricmc.fabric.registry.ExtendedIdList;
import net.fabricmc.fabric.registry.RegistryListener;
import net.minecraft.item.Item;
import net.minecraft.item.block.ItemBlock;
import net.minecraft.item.block.BlockItem;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
@ -32,8 +32,8 @@ public class BootstrapItemRegistryListener implements RegistryListener<Item> {
@Override
public void beforeRegistryRegistration(Registry<Item> registry, int id, Identifier identifier, Item object, boolean isNew) {
// refer net.minecraft.item.Items
if (object instanceof ItemBlock) {
((ItemBlock) object).registerBlockItemMap(Item.BLOCK_ITEM_MAP, object);
if (object instanceof BlockItem) {
((BlockItem) object).registerBlockItemMap(Item.BLOCK_ITEM_MAP, object);
}
}
}

View file

@ -7,6 +7,7 @@
"registry.client.MixinBlockColorMap",
"registry.client.MixinItemColorMap",
"registry.client.MixinItemModelMap",
"render.MixinBlockEntityRenderManager",
"resources.MixinMinecraftGame"
],
"injectors": {