mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-26 15:03:04 +00:00
Merge branch 'master' of https://github.com/MinecraftForge/FML
Conflicts: src/main/java/cpw/mods/fml/client/FMLClientHandler.java src/main/java/cpw/mods/fml/client/GuiModItemsMissing.java src/main/java/cpw/mods/fml/common/FMLContainer.java src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java src/main/java/cpw/mods/fml/common/registry/GameData.java
This commit is contained in:
commit
038fa17ad3
57 files changed
+562
-556
No files matched your search
@@ -341,7 +341,7 @@ public class FMLCommonHandler
|
||||
{
|
||||
for (ICrashCallable call: crashCallables)
|
||||
{
|
||||
category.func_71500_a(call.getLabel(), call);
|
||||
category.addCrashSectionCallable(call.getLabel(), call);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ public class FMLCommonHandler
|
||||
if (wac != null)
|
||||
{
|
||||
NBTTagCompound dataForWriting = wac.getDataForWriting(handler, worldInfo);
|
||||
tagCompound.func_74782_a(mc.getModId(), dataForWriting);
|
||||
tagCompound.setTag(mc.getModId(), dataForWriting);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -383,7 +383,7 @@ public class FMLCommonHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
wac.readData(handler, worldInfo, additionalProperties, tagCompound.func_74775_l(mc.getModId()));
|
||||
wac.readData(handler, worldInfo, additionalProperties, tagCompound.getCompoundTag(mc.getModId()));
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
|
||||
@@ -94,45 +94,45 @@ public class FMLContainer extends DummyModContainer implements WorldAccessContai
|
||||
for (ModContainer mc : Loader.instance().getActiveModList())
|
||||
{
|
||||
NBTTagCompound mod = new NBTTagCompound();
|
||||
mod.func_74778_a("ModId", mc.getModId());
|
||||
mod.func_74778_a("ModVersion", mc.getVersion());
|
||||
list.func_74742_a(mod);
|
||||
mod.setString("ModId", mc.getModId());
|
||||
mod.setString("ModVersion", mc.getVersion());
|
||||
list.appendTag(mod);
|
||||
}
|
||||
fmlData.func_74782_a("ModList", list);
|
||||
fmlData.setTag("ModList", list);
|
||||
// name <-> id mappings
|
||||
NBTTagList dataList = new NBTTagList();
|
||||
FMLLog.fine("Gathering id map for writing to world save %s", info.func_76065_j());
|
||||
FMLLog.fine("Gathering id map for writing to world save %s", info.getWorldName());
|
||||
Map<String,Integer> itemList = GameData.buildItemDataList();
|
||||
for (Entry<String, Integer> item : itemList.entrySet())
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.func_74778_a("K",item.getKey());
|
||||
tag.func_74768_a("V",item.getValue());
|
||||
dataList.func_74742_a(tag);
|
||||
tag.setString("K",item.getKey());
|
||||
tag.setInteger("V",item.getValue());
|
||||
dataList.appendTag(tag);
|
||||
}
|
||||
fmlData.func_74782_a("ItemData", dataList);
|
||||
fmlData.setTag("ItemData", dataList);
|
||||
// blocked ids
|
||||
fmlData.func_74783_a("BlockedItemIds", GameData.getBlockedIds());
|
||||
fmlData.setIntArray("BlockedItemIds", GameData.getBlockedIds());
|
||||
// block aliases
|
||||
NBTTagList blockAliasList = new NBTTagList();
|
||||
for (Entry<String, String> entry : GameData.getBlockRegistry().getAliases().entrySet())
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.func_74778_a("K", entry.getKey());
|
||||
tag.func_74778_a("V", entry.getValue());
|
||||
blockAliasList.func_74742_a(tag);
|
||||
tag.setString("K", entry.getKey());
|
||||
tag.setString("V", entry.getValue());
|
||||
blockAliasList.appendTag(tag);
|
||||
}
|
||||
fmlData.func_74782_a("BlockAliases", blockAliasList);
|
||||
fmlData.setTag("BlockAliases", blockAliasList);
|
||||
// item aliases
|
||||
NBTTagList itemAliasList = new NBTTagList();
|
||||
for (Entry<String, String> entry : GameData.getItemRegistry().getAliases().entrySet())
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.func_74778_a("K", entry.getKey());
|
||||
tag.func_74778_a("V", entry.getValue());
|
||||
itemAliasList.func_74742_a(tag);
|
||||
tag.setString("K", entry.getKey());
|
||||
tag.setString("V", entry.getValue());
|
||||
itemAliasList.appendTag(tag);
|
||||
}
|
||||
fmlData.func_74782_a("ItemAliases", itemAliasList);
|
||||
fmlData.setTag("ItemAliases", itemAliasList);
|
||||
|
||||
return fmlData;
|
||||
}
|
||||
@@ -140,14 +140,14 @@ public class FMLContainer extends DummyModContainer implements WorldAccessContai
|
||||
@Override
|
||||
public void readData(SaveHandler handler, WorldInfo info, Map<String, NBTBase> propertyMap, NBTTagCompound tag)
|
||||
{
|
||||
if (tag.func_74764_b("ModList"))
|
||||
if (tag.hasKey("ModList"))
|
||||
{
|
||||
NBTTagList modList = tag.func_150295_c("ModList", (byte)10);
|
||||
for (int i = 0; i < modList.func_74745_c(); i++)
|
||||
NBTTagList modList = tag.getTagList("ModList", (byte)10);
|
||||
for (int i = 0; i < modList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound mod = modList.func_150305_b(i);
|
||||
String modId = mod.func_74779_i("ModId");
|
||||
String modVersion = mod.func_74779_i("ModVersion");
|
||||
NBTTagCompound mod = modList.getCompoundTagAt(i);
|
||||
String modId = mod.getString("ModId");
|
||||
String modVersion = mod.getString("ModVersion");
|
||||
ModContainer container = Loader.instance().getIndexedModList().get(modId);
|
||||
if (container == null)
|
||||
{
|
||||
@@ -160,20 +160,20 @@ public class FMLContainer extends DummyModContainer implements WorldAccessContai
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tag.func_74764_b("ModItemData"))
|
||||
if (tag.hasKey("ModItemData"))
|
||||
{
|
||||
FMLLog.info("Attempting to convert old world data to new system. This may be trouble!");
|
||||
NBTTagList modList = tag.func_150295_c("ModItemData", (byte)10);
|
||||
NBTTagList modList = tag.getTagList("ModItemData", (byte)10);
|
||||
Map<String,Integer> dataList = Maps.newLinkedHashMap();
|
||||
for (int i = 0; i < modList.func_74745_c(); i++)
|
||||
for (int i = 0; i < modList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound itemTag = modList.func_150305_b(i);
|
||||
String modId = itemTag.func_74779_i("ModId");
|
||||
String itemType = itemTag.func_74779_i("ItemType");
|
||||
int itemId = itemTag.func_74762_e("ItemId");
|
||||
int ordinal = itemTag.func_74762_e("ordinal");
|
||||
String forcedModId = itemTag.func_74764_b("ForcedModId") ? itemTag.func_74779_i("ForcedModId") : null;
|
||||
String forcedName = itemTag.func_74764_b("ForcedName") ? itemTag.func_74779_i("ForcedName") : null;
|
||||
NBTTagCompound itemTag = modList.getCompoundTagAt(i);
|
||||
String modId = itemTag.getString("ModId");
|
||||
String itemType = itemTag.getString("ItemType");
|
||||
int itemId = itemTag.getInteger("ItemId");
|
||||
int ordinal = itemTag.getInteger("ordinal");
|
||||
String forcedModId = itemTag.hasKey("ForcedModId") ? itemTag.getString("ForcedModId") : null;
|
||||
String forcedName = itemTag.hasKey("ForcedName") ? itemTag.getString("ForcedName") : null;
|
||||
if (forcedName == null)
|
||||
{
|
||||
FMLLog.warning("Found unlabelled item in world save, this may cause problems. The item type %s:%d will not be present", itemType, ordinal);
|
||||
@@ -206,18 +206,18 @@ public class FMLContainer extends DummyModContainer implements WorldAccessContai
|
||||
throw new GameRegistryException("Failed to load the world - there are fatal block and item id issues", failedElements);
|
||||
}
|
||||
}
|
||||
else if (tag.func_74764_b("ItemData"))
|
||||
else if (tag.hasKey("ItemData"))
|
||||
{
|
||||
// name <-> id mappings
|
||||
NBTTagList list = tag.func_150295_c("ItemData", 10);
|
||||
NBTTagList list = tag.getTagList("ItemData", 10);
|
||||
Map<String,Integer> dataList = Maps.newLinkedHashMap();
|
||||
for (int i = 0; i < list.func_74745_c(); i++)
|
||||
for (int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound dataTag = list.func_150305_b(i);
|
||||
dataList.put(dataTag.func_74779_i("K"), dataTag.func_74762_e("V"));
|
||||
NBTTagCompound dataTag = list.getCompoundTagAt(i);
|
||||
dataList.put(dataTag.getString("K"), dataTag.getInteger("V"));
|
||||
}
|
||||
|
||||
if (!tag.func_74764_b("BlockedItemIds")) // no blocked id info -> old 1.7 save
|
||||
if (!tag.hasKey("BlockedItemIds")) // no blocked id info -> old 1.7 save
|
||||
{
|
||||
// old 1.7 save potentially affected by the registry mapping bug
|
||||
// fix the ids the best we can...
|
||||
@@ -225,22 +225,22 @@ public class FMLContainer extends DummyModContainer implements WorldAccessContai
|
||||
}
|
||||
|
||||
// blocked ids
|
||||
int[] blockedIds = tag.func_74759_k("BlockedItemIds");
|
||||
int[] blockedIds = tag.getIntArray("BlockedItemIds");
|
||||
// block aliases
|
||||
Map<String, String> blockAliases = new HashMap<String, String>();
|
||||
list = tag.func_150295_c("BlockAliases", 10);
|
||||
for (int i = 0; i < list.func_74745_c(); i++)
|
||||
list = tag.getTagList("BlockAliases", 10);
|
||||
for (int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound dataTag = list.func_150305_b(i);
|
||||
blockAliases.put(dataTag.func_74779_i("K"), dataTag.func_74779_i("V"));
|
||||
NBTTagCompound dataTag = list.getCompoundTagAt(i);
|
||||
blockAliases.put(dataTag.getString("K"), dataTag.getString("V"));
|
||||
}
|
||||
// item aliases
|
||||
Map<String, String> itemAliases = new HashMap<String, String>();
|
||||
list = tag.func_150295_c("ItemAliases", 10);
|
||||
for (int i = 0; i < list.func_74745_c(); i++)
|
||||
list = tag.getTagList("ItemAliases", 10);
|
||||
for (int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound dataTag = list.func_150305_b(i);
|
||||
itemAliases.put(dataTag.func_74779_i("K"), dataTag.func_74779_i("V"));
|
||||
NBTTagCompound dataTag = list.getCompoundTagAt(i);
|
||||
itemAliases.put(dataTag.getString("K"), dataTag.getString("V"));
|
||||
}
|
||||
|
||||
List<String> failedElements = GameData.injectWorldIDMap(dataList, blockedIds, blockAliases, itemAliases, true, true);
|
||||
|
||||
@@ -193,4 +193,4 @@ public interface ILanguageAdapter {
|
||||
// Nothing to do here.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class FMLServerStartingEvent extends FMLStateEvent
|
||||
|
||||
public void registerServerCommand(ICommand command)
|
||||
{
|
||||
CommandHandler ch = (CommandHandler) getServer().func_71187_D();
|
||||
ch.func_71560_a(command);
|
||||
CommandHandler ch = (CommandHandler) getServer().getCommandManager();
|
||||
ch.registerCommand(command);
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,4 @@ public class ArtifactVersionNameFunction implements Function<ArtifactVersion, St
|
||||
{
|
||||
return v.getLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class ByteBufUtils {
|
||||
PacketBuffer pb = new PacketBuffer(to);
|
||||
try
|
||||
{
|
||||
pb.func_150788_a(stack);
|
||||
pb.writeItemStackToBuffer(stack);
|
||||
} catch (IOException e)
|
||||
{
|
||||
// Unpossible?
|
||||
@@ -165,7 +165,7 @@ public class ByteBufUtils {
|
||||
PacketBuffer pb = new PacketBuffer(from);
|
||||
try
|
||||
{
|
||||
return pb.func_150791_c();
|
||||
return pb.readItemStackFromBuffer();
|
||||
} catch (IOException e)
|
||||
{
|
||||
// Unpossible?
|
||||
@@ -184,7 +184,7 @@ public class ByteBufUtils {
|
||||
PacketBuffer pb = new PacketBuffer(to);
|
||||
try
|
||||
{
|
||||
pb.func_150786_a(tag);
|
||||
pb.writeNBTTagCompoundToBuffer(tag);
|
||||
} catch (IOException e)
|
||||
{
|
||||
// Unpossible?
|
||||
@@ -203,7 +203,7 @@ public class ByteBufUtils {
|
||||
PacketBuffer pb = new PacketBuffer(from);
|
||||
try
|
||||
{
|
||||
return pb.func_150793_b();
|
||||
return pb.readNBTTagCompoundFromBuffer();
|
||||
} catch (IOException e)
|
||||
{
|
||||
// Unpossible?
|
||||
|
||||
@@ -64,4 +64,4 @@ public class FMLEmbeddedChannel extends EmbeddedChannel {
|
||||
}
|
||||
return targetName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class FMLEventChannel {
|
||||
if (msg.handler() instanceof NetHandlerPlayClient)
|
||||
{
|
||||
NetHandlerPlayClient client = (NetHandlerPlayClient) msg.handler();
|
||||
event = new FMLNetworkEvent.ClientCustomPacketEvent(client.func_147298_b(), msg);
|
||||
event = new FMLNetworkEvent.ClientCustomPacketEvent(client.getNetworkManager(), msg);
|
||||
}
|
||||
else if (msg.handler() instanceof NetHandlerPlayServer)
|
||||
{
|
||||
|
||||
@@ -32,8 +32,8 @@ public class FMLNetworkEvent<T extends INetHandler> extends Event {
|
||||
public final String connectionType;
|
||||
public ClientConnectedToServerEvent(NetworkManager manager, String connectionType)
|
||||
{
|
||||
super((INetHandlerPlayClient) manager.func_150729_e(), INetHandlerPlayClient.class, manager);
|
||||
this.isLocal = manager.func_150731_c();
|
||||
super((INetHandlerPlayClient) manager.getNetHandler(), INetHandlerPlayClient.class, manager);
|
||||
this.isLocal = manager.isLocalChannel();
|
||||
this.connectionType = connectionType;
|
||||
}
|
||||
}
|
||||
@@ -48,8 +48,8 @@ public class FMLNetworkEvent<T extends INetHandler> extends Event {
|
||||
public final boolean isLocal;
|
||||
public ServerConnectionFromClientEvent(NetworkManager manager)
|
||||
{
|
||||
super((INetHandlerPlayServer) manager.func_150729_e(), INetHandlerPlayServer.class, manager);
|
||||
this.isLocal = manager.func_150731_c();
|
||||
super((INetHandlerPlayServer) manager.getNetHandler(), INetHandlerPlayServer.class, manager);
|
||||
this.isLocal = manager.isLocalChannel();
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ public class FMLNetworkEvent<T extends INetHandler> extends Event {
|
||||
public static class ServerDisconnectionFromClientEvent extends FMLNetworkEvent<INetHandlerPlayServer> {
|
||||
public ServerDisconnectionFromClientEvent(NetworkManager manager)
|
||||
{
|
||||
super((INetHandlerPlayServer) manager.func_150729_e(), INetHandlerPlayServer.class, manager);
|
||||
super((INetHandlerPlayServer) manager.getNetHandler(), INetHandlerPlayServer.class, manager);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ public class FMLNetworkEvent<T extends INetHandler> extends Event {
|
||||
public static class ClientDisconnectionFromServerEvent extends FMLNetworkEvent<INetHandlerPlayClient> {
|
||||
public ClientDisconnectionFromServerEvent(NetworkManager manager)
|
||||
{
|
||||
super((INetHandlerPlayClient) manager.func_150729_e(), INetHandlerPlayClient.class, manager);
|
||||
super((INetHandlerPlayClient) manager.getNetHandler(), INetHandlerPlayClient.class, manager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class FMLNetworkEvent<T extends INetHandler> extends Event {
|
||||
public final Side side;
|
||||
public CustomPacketRegistrationEvent(NetworkManager manager, Set<String> registrations, String operation, Side side, Class<S> type)
|
||||
{
|
||||
super(type.cast(manager.func_150729_e()), type, manager);
|
||||
super(type.cast(manager.getNetHandler()), type, manager);
|
||||
this.registrations = ImmutableSet.copyOf(registrations);
|
||||
this.side = side;
|
||||
this.operation = operation;
|
||||
@@ -124,7 +124,7 @@ public class FMLNetworkEvent<T extends INetHandler> extends Event {
|
||||
public static class ClientCustomPacketEvent extends CustomPacketEvent<INetHandlerPlayClient> {
|
||||
public ClientCustomPacketEvent(NetworkManager manager, FMLProxyPacket packet)
|
||||
{
|
||||
super((INetHandlerPlayClient) manager.func_150729_e(), INetHandlerPlayClient.class, manager, packet);
|
||||
super((INetHandlerPlayClient) manager.getNetHandler(), INetHandlerPlayClient.class, manager, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,7 +142,7 @@ public class FMLNetworkEvent<T extends INetHandler> extends Event {
|
||||
public static class ServerCustomPacketEvent extends CustomPacketEvent<INetHandlerPlayServer> {
|
||||
public ServerCustomPacketEvent(NetworkManager manager, FMLProxyPacket packet)
|
||||
{
|
||||
super((INetHandlerPlayServer) manager.func_150729_e(), INetHandlerPlayServer.class, manager, packet);
|
||||
super((INetHandlerPlayServer) manager.getNetHandler(), INetHandlerPlayServer.class, manager, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -106,7 +106,7 @@ public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter {
|
||||
public List<NetworkDispatcher> selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet)
|
||||
{
|
||||
EntityPlayerMP player = (EntityPlayerMP) args;
|
||||
NetworkDispatcher dispatcher = player.field_71135_a.field_147371_a.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||
NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||
return ImmutableList.of(dispatcher);
|
||||
}
|
||||
},
|
||||
@@ -126,9 +126,9 @@ public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter {
|
||||
public List<NetworkDispatcher> selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet)
|
||||
{
|
||||
ImmutableList.Builder<NetworkDispatcher> builder = ImmutableList.<NetworkDispatcher>builder();
|
||||
for (EntityPlayerMP player : (List<EntityPlayerMP>)FMLCommonHandler.instance().getMinecraftServerInstance().func_71203_ab().field_72404_b)
|
||||
for (EntityPlayerMP player : (List<EntityPlayerMP>)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList)
|
||||
{
|
||||
NetworkDispatcher dispatcher = player.field_71135_a.field_147371_a.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||
NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||
builder.add(dispatcher);
|
||||
}
|
||||
return builder.build();
|
||||
@@ -155,11 +155,11 @@ public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter {
|
||||
{
|
||||
int dimension = (Integer)args;
|
||||
ImmutableList.Builder<NetworkDispatcher> builder = ImmutableList.<NetworkDispatcher>builder();
|
||||
for (EntityPlayerMP player : (List<EntityPlayerMP>)FMLCommonHandler.instance().getMinecraftServerInstance().func_71203_ab().field_72404_b)
|
||||
for (EntityPlayerMP player : (List<EntityPlayerMP>)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList)
|
||||
{
|
||||
if (dimension == player.field_71093_bK)
|
||||
if (dimension == player.dimension)
|
||||
{
|
||||
NetworkDispatcher dispatcher = player.field_71135_a.field_147371_a.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||
NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||
builder.add(dispatcher);
|
||||
}
|
||||
}
|
||||
@@ -189,17 +189,17 @@ public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter {
|
||||
{
|
||||
TargetPoint tp = (TargetPoint)args;
|
||||
ImmutableList.Builder<NetworkDispatcher> builder = ImmutableList.<NetworkDispatcher>builder();
|
||||
for (EntityPlayerMP player : (List<EntityPlayerMP>)FMLCommonHandler.instance().getMinecraftServerInstance().func_71203_ab().field_72404_b)
|
||||
for (EntityPlayerMP player : (List<EntityPlayerMP>)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList)
|
||||
{
|
||||
if (player.field_71093_bK == tp.dimension)
|
||||
if (player.dimension == tp.dimension)
|
||||
{
|
||||
double d4 = tp.x - player.field_70165_t;
|
||||
double d5 = tp.y - player.field_70163_u;
|
||||
double d6 = tp.z - player.field_70161_v;
|
||||
double d4 = tp.x - player.posX;
|
||||
double d5 = tp.y - player.posY;
|
||||
double d6 = tp.z - player.posZ;
|
||||
|
||||
if (d4 * d4 + d5 * d5 + d6 * d6 < tp.range * tp.range)
|
||||
{
|
||||
NetworkDispatcher dispatcher = player.field_71135_a.field_147371_a.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||
NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||
builder.add(dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,4 +136,4 @@ enum FMLHandshakeClientState implements IHandshakeState<FMLHandshakeClientState>
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -91,4 +91,4 @@ enum FMLHandshakeServerState implements IHandshakeState<FMLHandshakeServerState>
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
this.handshakeChannel.attr(FML_DISPATCHER).set(this);
|
||||
this.handshakeChannel.attr(NetworkRegistry.CHANNEL_SOURCE).set(Side.SERVER);
|
||||
this.handshakeChannel.attr(NetworkRegistry.FML_CHANNEL).set("FML|HS");
|
||||
this.handshakeChannel.attr(IS_LOCAL).set(manager.func_150731_c());
|
||||
this.handshakeChannel.attr(IS_LOCAL).set(manager.isLocalChannel());
|
||||
}
|
||||
|
||||
public NetworkDispatcher(NetworkManager manager, ServerConfigurationManager scm)
|
||||
@@ -102,7 +102,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
this.handshakeChannel.attr(FML_DISPATCHER).set(this);
|
||||
this.handshakeChannel.attr(NetworkRegistry.CHANNEL_SOURCE).set(Side.CLIENT);
|
||||
this.handshakeChannel.attr(NetworkRegistry.FML_CHANNEL).set("FML|HS");
|
||||
this.handshakeChannel.attr(IS_LOCAL).set(manager.func_150731_c());
|
||||
this.handshakeChannel.attr(IS_LOCAL).set(manager.isLocalChannel());
|
||||
}
|
||||
|
||||
public void serverToClientHandshake(EntityPlayerMP player)
|
||||
@@ -139,17 +139,17 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
this.state = ConnectionState.AWAITING_HANDSHAKE;
|
||||
this.manager.channel().pipeline().addFirst("fml:vanilla_detector", new VanillaTimeoutWaiter());
|
||||
// Need to start the handler here, so we can send custompayload packets
|
||||
serverHandler = new NetHandlerPlayServer(scm.func_72365_p(), manager, player);
|
||||
serverHandler = new NetHandlerPlayServer(scm.getServerInstance(), manager, player);
|
||||
this.netHandler = serverHandler;
|
||||
// NULL the play server here - we restore it further on. If not, there are packets sent before the login
|
||||
player.field_71135_a = null;
|
||||
player.playerNetServerHandler = null;
|
||||
// manually for the manager into the PLAY state, so we can send packets later
|
||||
this.manager.func_150723_a(EnumConnectionState.PLAY);
|
||||
this.manager.setConnectionState(EnumConnectionState.PLAY);
|
||||
}
|
||||
|
||||
void clientListenForServerHandshake()
|
||||
{
|
||||
manager.func_150723_a(EnumConnectionState.PLAY);
|
||||
manager.setConnectionState(EnumConnectionState.PLAY);
|
||||
FMLCommonHandler.instance().waitForPlayClient();
|
||||
this.netHandler = FMLCommonHandler.instance().getClientPlayHandler();
|
||||
this.state = ConnectionState.AWAITING_HANDSHAKE;
|
||||
@@ -169,7 +169,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
|
||||
this.state = ConnectionState.CONNECTED;
|
||||
FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
|
||||
scm.func_72355_a(manager, player, serverHandler);
|
||||
scm.initializeConnectionToPlayer(manager, player, serverHandler);
|
||||
}
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception
|
||||
@@ -228,12 +228,12 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
private void kickWithMessage(String message)
|
||||
{
|
||||
final ChatComponentText chatcomponenttext = new ChatComponentText(message);
|
||||
manager.func_150725_a(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener<Future<?>>()
|
||||
manager.scheduleOutboundPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener<Future<?>>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(Future<?> result)
|
||||
{
|
||||
manager.func_150718_a(chatcomponenttext);
|
||||
manager.closeChannel(chatcomponenttext);
|
||||
}
|
||||
});
|
||||
manager.channel().config().setAutoRead(false);
|
||||
@@ -337,7 +337,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
|
||||
public void sendProxy(FMLProxyPacket msg)
|
||||
{
|
||||
manager.func_150725_a(msg);
|
||||
manager.scheduleOutboundPacket(msg);
|
||||
}
|
||||
|
||||
public void rejectHandshake(String result)
|
||||
|
||||
@@ -41,12 +41,12 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler<FMLMessage.E
|
||||
|
||||
private void adjustEntity(EntityAdjustMessage msg)
|
||||
{
|
||||
Entity ent = FMLClientHandler.instance().getWorldClient().func_73045_a(msg.entityId);
|
||||
Entity ent = FMLClientHandler.instance().getWorldClient().getEntityByID(msg.entityId);
|
||||
if (ent != null)
|
||||
{
|
||||
ent.field_70118_ct = msg.serverX;
|
||||
ent.field_70117_cu = msg.serverY;
|
||||
ent.field_70116_cv = msg.serverZ;
|
||||
ent.serverPosX = msg.serverX;
|
||||
ent.serverPosY = msg.serverY;
|
||||
ent.serverPosZ = msg.serverZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -72,50 +72,50 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler<FMLMessage.E
|
||||
{
|
||||
entity = (Entity) (cls.getConstructor(World.class).newInstance(wc));
|
||||
|
||||
int offset = spawnMsg.entityId - entity.func_145782_y();
|
||||
entity.func_145769_d(spawnMsg.entityId);
|
||||
entity.func_70012_b(spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch);
|
||||
int offset = spawnMsg.entityId - entity.getEntityId();
|
||||
entity.setEntityId(spawnMsg.entityId);
|
||||
entity.setLocationAndAngles(spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch);
|
||||
if (entity instanceof EntityLiving)
|
||||
{
|
||||
((EntityLiving) entity).field_70759_as = spawnMsg.scaledHeadYaw;
|
||||
((EntityLiving) entity).rotationYawHead = spawnMsg.scaledHeadYaw;
|
||||
}
|
||||
|
||||
Entity parts[] = entity.func_70021_al();
|
||||
Entity parts[] = entity.getParts();
|
||||
if (parts != null)
|
||||
{
|
||||
for (int j = 0; j < parts.length; j++)
|
||||
{
|
||||
parts[j].func_145769_d(parts[j].func_145782_y() + offset);
|
||||
parts[j].setEntityId(parts[j].getEntityId() + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entity.field_70118_ct = spawnMsg.rawX;
|
||||
entity.field_70117_cu = spawnMsg.rawY;
|
||||
entity.field_70116_cv = spawnMsg.rawZ;
|
||||
entity.serverPosX = spawnMsg.rawX;
|
||||
entity.serverPosY = spawnMsg.rawY;
|
||||
entity.serverPosZ = spawnMsg.rawZ;
|
||||
|
||||
EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
|
||||
if (entity instanceof IThrowableEntity)
|
||||
{
|
||||
Entity thrower = clientPlayer.func_145782_y() == spawnMsg.throwerId ? clientPlayer : wc.func_73045_a(spawnMsg.throwerId);
|
||||
Entity thrower = clientPlayer.getEntityId() == spawnMsg.throwerId ? clientPlayer : wc.getEntityByID(spawnMsg.throwerId);
|
||||
((IThrowableEntity) entity).setThrower(thrower);
|
||||
}
|
||||
|
||||
if (spawnMsg.dataWatcherList != null)
|
||||
{
|
||||
entity.func_70096_w().func_75687_a((List<?>) spawnMsg.dataWatcherList);
|
||||
entity.getDataWatcher().updateWatchedObjectsFromList((List<?>) spawnMsg.dataWatcherList);
|
||||
}
|
||||
|
||||
if (spawnMsg.throwerId > 0)
|
||||
{
|
||||
entity.func_70016_h(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ);
|
||||
entity.setVelocity(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ);
|
||||
}
|
||||
|
||||
if (entity instanceof IEntityAdditionalSpawnData)
|
||||
{
|
||||
((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream);
|
||||
}
|
||||
wc.func_73027_a(spawnMsg.entityId, entity);
|
||||
wc.addEntityToWorld(spawnMsg.entityId, entity);
|
||||
System.out.println("Entity spawned on client");
|
||||
} catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ public abstract class FMLMessage {
|
||||
@Override
|
||||
void toBytes(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt(entity.func_145782_y());
|
||||
buf.writeInt(entity.getEntityId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,23 +170,23 @@ public abstract class FMLMessage {
|
||||
ByteBufUtils.writeUTF8String(buf, modId);
|
||||
buf.writeInt(modEntityTypeId);
|
||||
// posX, posY, posZ
|
||||
buf.writeInt(MathHelper.func_76128_c(entity.field_70165_t * 32D));
|
||||
buf.writeInt(MathHelper.func_76128_c(entity.field_70163_u * 32D));
|
||||
buf.writeInt(MathHelper.func_76128_c(entity.field_70161_v * 32D));
|
||||
buf.writeInt(MathHelper.floor_double(entity.posX * 32D));
|
||||
buf.writeInt(MathHelper.floor_double(entity.posY * 32D));
|
||||
buf.writeInt(MathHelper.floor_double(entity.posZ * 32D));
|
||||
// yaw, pitch
|
||||
buf.writeByte((byte)(entity.field_70177_z * 256.0F / 360.0F));
|
||||
buf.writeByte((byte) (entity.field_70125_A * 256.0F / 360.0F));
|
||||
buf.writeByte((byte)(entity.rotationYaw * 256.0F / 360.0F));
|
||||
buf.writeByte((byte) (entity.rotationPitch * 256.0F / 360.0F));
|
||||
// head yaw
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
buf.writeByte((byte) (((EntityLivingBase)entity).field_70759_as * 256.0F / 360.0F));
|
||||
buf.writeByte((byte) (((EntityLivingBase)entity).rotationYawHead * 256.0F / 360.0F));
|
||||
}
|
||||
|
||||
ByteBuf tmpBuf = Unpooled.buffer();
|
||||
PacketBuffer pb = new PacketBuffer(tmpBuf);
|
||||
try
|
||||
{
|
||||
entity.func_70096_w().func_151509_a(pb);
|
||||
entity.getDataWatcher().func_151509_a(pb);
|
||||
} catch (IOException e)
|
||||
{
|
||||
// Sigh
|
||||
@@ -196,11 +196,11 @@ public abstract class FMLMessage {
|
||||
if (entity instanceof IThrowableEntity)
|
||||
{
|
||||
Entity owner = ((IThrowableEntity)entity).getThrower();
|
||||
buf.writeInt(owner == null ? entity.func_145782_y() : owner.func_145782_y());
|
||||
buf.writeInt(owner == null ? entity.getEntityId() : owner.getEntityId());
|
||||
double maxVel = 3.9D;
|
||||
double mX = entity.field_70159_w;
|
||||
double mY = entity.field_70181_x;
|
||||
double mZ = entity.field_70179_y;
|
||||
double mX = entity.motionX;
|
||||
double mY = entity.motionY;
|
||||
double mZ = entity.motionZ;
|
||||
if (mX < -maxVel) mX = -maxVel;
|
||||
if (mY < -maxVel) mY = -maxVel;
|
||||
if (mZ < -maxVel) mZ = -maxVel;
|
||||
@@ -239,7 +239,7 @@ public abstract class FMLMessage {
|
||||
scaledHeadYaw = dat.readByte() * 360F / 256F;
|
||||
try
|
||||
{
|
||||
dataWatcherList = DataWatcher.func_151508_b(new PacketBuffer(dat));
|
||||
dataWatcherList = DataWatcher.readWatchedListFromPacketBuffer(new PacketBuffer(dat));
|
||||
} catch (IOException e)
|
||||
{
|
||||
// Sigh
|
||||
|
||||
@@ -75,17 +75,17 @@ public class FMLNetworkHandler
|
||||
Container remoteGuiContainer = NetworkRegistry.INSTANCE.getRemoteGuiContainer(mc, entityPlayerMP, modGuiId, world, x, y, z);
|
||||
if (remoteGuiContainer != null)
|
||||
{
|
||||
entityPlayerMP.func_71117_bO();
|
||||
entityPlayerMP.func_71128_l();
|
||||
int windowId = entityPlayerMP.field_71139_cq;
|
||||
entityPlayerMP.getNextWindowId();
|
||||
entityPlayerMP.closeContainer();
|
||||
int windowId = entityPlayerMP.currentWindowId;
|
||||
FMLMessage.OpenGui openGui = new FMLMessage.OpenGui(windowId, mc.getModId(), modGuiId, x, y, z);
|
||||
EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
|
||||
embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER);
|
||||
embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityPlayerMP);
|
||||
embeddedChannel.writeOutbound(openGui);
|
||||
entityPlayerMP.field_71070_bA = remoteGuiContainer;
|
||||
entityPlayerMP.field_71070_bA.field_75152_c = windowId;
|
||||
entityPlayerMP.field_71070_bA.func_75132_a(entityPlayerMP);
|
||||
entityPlayerMP.openContainer = remoteGuiContainer;
|
||||
entityPlayerMP.openContainer.windowId = windowId;
|
||||
entityPlayerMP.openContainer.addCraftingToCrafters(entityPlayerMP);
|
||||
}
|
||||
}
|
||||
else if (FMLCommonHandler.instance().getSide().equals(Side.CLIENT))
|
||||
|
||||
@@ -47,19 +47,19 @@ public class FMLProxyPacket extends Packet {
|
||||
this.payload = payload;
|
||||
}
|
||||
@Override
|
||||
public void func_148837_a(PacketBuffer packetbuffer) throws IOException
|
||||
public void readPacketData(PacketBuffer packetbuffer) throws IOException
|
||||
{
|
||||
// NOOP - we are not built this way
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_148840_b(PacketBuffer packetbuffer) throws IOException
|
||||
public void writePacketData(PacketBuffer packetbuffer) throws IOException
|
||||
{
|
||||
// NOOP - we are not built this way
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_148833_a(INetHandler inethandler)
|
||||
public void processPacket(INetHandler inethandler)
|
||||
{
|
||||
this.netHandler = inethandler;
|
||||
EmbeddedChannel internalChannel = NetworkRegistry.INSTANCE.getChannel(this.channel, this.target);
|
||||
|
||||
@@ -12,9 +12,9 @@ public class OpenGuiHandler extends SimpleChannelInboundHandler<FMLMessage.OpenG
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, OpenGui msg) throws Exception
|
||||
{
|
||||
EntityPlayer player = FMLClientHandler.instance().getClient().field_71439_g;
|
||||
player.openGui(msg.modId, msg.modGuiId, player.field_70170_p, msg.x, msg.y, msg.z);
|
||||
player.field_71070_bA.field_75152_c = msg.windowId;
|
||||
EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
|
||||
player.openGui(msg.modId, msg.modGuiId, player.worldObj, msg.x, msg.y, msg.z);
|
||||
player.openContainer.windowId = msg.windowId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
* should be unique for this channelName - it is used to discriminate between different types of message that might
|
||||
* occur on this channel (a simple form of message channel multiplexing, if you will).
|
||||
* <li>To get a packet suitable for presenting to the rest of minecraft, you can call {@link #getPacketFrom(IMessage)}. The return result
|
||||
* is suitable for returning from things like {@link TileEntity#func_145844_m()} for example.
|
||||
* is suitable for returning from things like {@link TileEntity#func_145844_m} for example.
|
||||
* <li>Finally, use the sendXXX to send unsolicited messages to various classes of recipients.
|
||||
* </ul>
|
||||
*
|
||||
@@ -87,7 +87,7 @@ public class SimpleNetworkWrapper {
|
||||
|
||||
/**
|
||||
* Construct a minecraft packet from the supplied message. Can be used where minecraft packets are required, such as
|
||||
* {@link TileEntity#func_145844_m()}.
|
||||
* {@link TileEntity#func_145844_m}.
|
||||
*
|
||||
* @param message The message to translate into packet form
|
||||
* @return A minecraft {@link Packet} suitable for use in minecraft APIs
|
||||
|
||||
@@ -127,7 +127,7 @@ public class EntityRegistry
|
||||
{
|
||||
availableIndicies = new BitSet(256);
|
||||
availableIndicies.set(1,255);
|
||||
for (Object id : EntityList.field_75623_d.keySet())
|
||||
for (Object id : EntityList.IDtoClassMapping.keySet())
|
||||
{
|
||||
availableIndicies.clear((Integer)id);
|
||||
}
|
||||
@@ -158,11 +158,11 @@ public class EntityRegistry
|
||||
{
|
||||
entityClassRegistrations.put(entityClass, er);
|
||||
entityNames.put(entityName, mc);
|
||||
if (!EntityList.field_75626_c.containsKey(entityClass))
|
||||
if (!EntityList.classToStringMapping.containsKey(entityClass))
|
||||
{
|
||||
String entityModName = String.format("%s.%s", mc.getModId(), entityName);
|
||||
EntityList.field_75626_c.put(entityClass, entityModName);
|
||||
EntityList.field_75625_b.put(entityModName, entityClass);
|
||||
EntityList.classToStringMapping.put(entityClass, entityModName);
|
||||
EntityList.stringToClassMapping.put(entityModName, entityClass);
|
||||
FMLLog.finer("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName);
|
||||
}
|
||||
else
|
||||
@@ -180,7 +180,7 @@ public class EntityRegistry
|
||||
|
||||
public static void registerGlobalEntityID(Class <? extends Entity > entityClass, String entityName, int id)
|
||||
{
|
||||
if (EntityList.field_75626_c.containsKey(entityClass))
|
||||
if (EntityList.classToStringMapping.containsKey(entityClass))
|
||||
{
|
||||
ModContainer activeModContainer = Loader.instance().activeModContainer();
|
||||
String modId = "unknown";
|
||||
@@ -196,7 +196,7 @@ public class EntityRegistry
|
||||
return;
|
||||
}
|
||||
id = instance().validateAndClaimId(id);
|
||||
EntityList.func_75618_a(entityClass, entityName, id);
|
||||
EntityList.addMapping(entityClass, entityName, id);
|
||||
}
|
||||
|
||||
private int validateAndClaimId(int id)
|
||||
@@ -232,7 +232,7 @@ public class EntityRegistry
|
||||
|
||||
public static void registerGlobalEntityID(Class <? extends Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
|
||||
{
|
||||
if (EntityList.field_75626_c.containsKey(entityClass))
|
||||
if (EntityList.classToStringMapping.containsKey(entityClass))
|
||||
{
|
||||
ModContainer activeModContainer = Loader.instance().activeModContainer();
|
||||
String modId = "unknown";
|
||||
@@ -248,7 +248,7 @@ public class EntityRegistry
|
||||
return;
|
||||
}
|
||||
instance().validateAndClaimId(id);
|
||||
EntityList.func_75614_a(entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
|
||||
EntityList.addMapping(entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
|
||||
}
|
||||
|
||||
public static void addSpawn(Class <? extends EntityLiving > entityClass, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
|
||||
@@ -256,16 +256,16 @@ public class EntityRegistry
|
||||
for (BiomeGenBase biome : biomes)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> spawns = biome.func_76747_a(typeOfCreature);
|
||||
List<SpawnListEntry> spawns = biome.getSpawnableList(typeOfCreature);
|
||||
|
||||
for (SpawnListEntry entry : spawns)
|
||||
{
|
||||
//Adjusting an existing spawn entry
|
||||
if (entry.field_76300_b == entityClass)
|
||||
if (entry.entityClass == entityClass)
|
||||
{
|
||||
entry.field_76292_a = weightedProb;
|
||||
entry.field_76301_c = min;
|
||||
entry.field_76299_d = max;
|
||||
entry.itemWeight = weightedProb;
|
||||
entry.minGroupCount = min;
|
||||
entry.maxGroupCount = max;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,7 @@ public class EntityRegistry
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
Class <? extends Entity > entityClazz = (Class<? extends Entity>) EntityList.field_75625_b.get(entityName);
|
||||
Class <? extends Entity > entityClazz = (Class<? extends Entity>) EntityList.stringToClassMapping.get(entityName);
|
||||
|
||||
if (EntityLiving.class.isAssignableFrom(entityClazz))
|
||||
{
|
||||
@@ -290,12 +290,12 @@ public class EntityRegistry
|
||||
for (BiomeGenBase biome : biomes)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<SpawnListEntry> spawns = biome.func_76747_a(typeOfCreature).iterator();
|
||||
Iterator<SpawnListEntry> spawns = biome.getSpawnableList(typeOfCreature).iterator();
|
||||
|
||||
while (spawns.hasNext())
|
||||
{
|
||||
SpawnListEntry entry = spawns.next();
|
||||
if (entry.field_76300_b == entityClass)
|
||||
if (entry.entityClass == entityClass)
|
||||
{
|
||||
spawns.remove();
|
||||
}
|
||||
@@ -306,7 +306,7 @@ public class EntityRegistry
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
Class <? extends Entity > entityClazz = (Class<? extends Entity>) EntityList.field_75625_b.get(entityName);
|
||||
Class <? extends Entity > entityClazz = (Class<? extends Entity>) EntityList.stringToClassMapping.get(entityName);
|
||||
|
||||
if (EntityLiving.class.isAssignableFrom(entityClazz))
|
||||
{
|
||||
@@ -361,7 +361,7 @@ public class EntityRegistry
|
||||
EntityRegistration er = lookupModSpawn(entity.getClass(), true);
|
||||
if (er != null)
|
||||
{
|
||||
entityTracker.func_72785_a(entity, er.getTrackingRange(), er.getUpdateFrequency(), er.sendsVelocityUpdates());
|
||||
entityTracker.addEntityToTracker(entity, er.getTrackingRange(), er.getUpdateFrequency(), er.sendsVelocityUpdates());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -6,10 +6,12 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.util.ObjectIntIdentityMap;
|
||||
import net.minecraft.util.RegistryNamespaced;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
@@ -45,12 +47,12 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
this.minId = registry.minId;
|
||||
this.aliases.clear();
|
||||
this.aliases.putAll(registry.aliases);
|
||||
field_148759_a = new ObjectIntIdentityMap();
|
||||
field_82596_a.clear();
|
||||
underlyingIntegerMap = new ObjectIntIdentityMap();
|
||||
registryObjects.clear();
|
||||
|
||||
for (I thing : (Iterable<I>) registry)
|
||||
{
|
||||
super.func_148756_a(registry.getId(thing), registry.func_148750_c(thing), thing);
|
||||
super.addObject(registry.getId(thing), registry.getNameForObject(thing), thing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,49 +65,41 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void func_148756_a(int id, String name, Object thing)
|
||||
public void addObject(int id, String name, Object thing)
|
||||
{
|
||||
GameData.getMain().register(thing, name, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public I func_82594_a(String name)
|
||||
public I getObject(String name)
|
||||
{
|
||||
I object = getRaw(name);
|
||||
return object == null ? this.optionalDefaultObject : object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public I func_148754_a(int id)
|
||||
public I getObjectById(int id)
|
||||
{
|
||||
I object = getRaw(id);
|
||||
return object == null ? this.optionalDefaultObject : object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object identified by the specified id.
|
||||
*
|
||||
* The default object is the air block for the block registry or null for the item registry.
|
||||
*
|
||||
* @param id Block/Item id.
|
||||
* @return Block/Item object or the default object if it wasn't found.
|
||||
* @deprecated use getObjectById instead
|
||||
*/
|
||||
@Deprecated
|
||||
public I get(int id)
|
||||
{
|
||||
return func_148754_a(id);
|
||||
return getObjectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object identified by the specified name.
|
||||
*
|
||||
* The default object is the air block for the block registry or null for the item registry.
|
||||
*
|
||||
* @param name Block/Item name.
|
||||
* @return Block/Item object or the default object if it wasn't found.
|
||||
* @deprecated use getObject instead
|
||||
*/
|
||||
@Deprecated
|
||||
public I get(String name)
|
||||
{
|
||||
return func_82594_a(name);
|
||||
return getObject(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +115,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
*/
|
||||
public int getId(I thing)
|
||||
{
|
||||
return func_148757_b(thing);
|
||||
return getIDForObject(thing);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +126,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
*/
|
||||
public I getRaw(int id)
|
||||
{
|
||||
return superType.cast(super.func_148754_a(id));
|
||||
return superType.cast(super.getObjectById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +137,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
*/
|
||||
public I getRaw(String name)
|
||||
{
|
||||
I ret = superType.cast(super.func_82594_a(name));
|
||||
I ret = superType.cast(super.getObject(name));
|
||||
|
||||
if (ret == null) // no match, try aliases recursively
|
||||
{
|
||||
@@ -156,15 +150,15 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_148741_d(String name)
|
||||
public boolean containsKey(String name)
|
||||
{
|
||||
boolean ret = super.func_148741_d(name);
|
||||
boolean ret = super.containsKey(name);
|
||||
|
||||
if (!ret) // no match, try aliases recursively
|
||||
{
|
||||
name = aliases.get(name);
|
||||
|
||||
if (name != null) return func_148741_d(name);
|
||||
if (name != null) return containsKey(name);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -189,9 +183,13 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
return getId(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use containsKey instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean contains(String itemName)
|
||||
{
|
||||
return func_148741_d(itemName);
|
||||
return containsKey(itemName);
|
||||
}
|
||||
|
||||
// internal
|
||||
@@ -201,7 +199,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
{
|
||||
for (I thing : (Iterable<I>) this)
|
||||
{
|
||||
idMapping.put(discriminator+func_148750_c(thing), getId(thing));
|
||||
idMapping.put(discriminator+getNameForObject(thing), getId(thing));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +210,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
|
||||
int add(int id, String name, I thing, BitSet availabilityMap)
|
||||
{
|
||||
if (thing == null) throw new NullPointerException("Can't add null-object to the registry.");
|
||||
if (name.equals(optionalDefaultName))
|
||||
{
|
||||
this.optionalDefaultObject = thing;
|
||||
@@ -233,7 +232,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
String prefix = mc.getModId();
|
||||
name = prefix + ":"+ name;
|
||||
}
|
||||
super.func_148756_a(idToUse, name, thing);
|
||||
super.addObject(idToUse, name, thing);
|
||||
FMLLog.finer("Add : %s %d %s", name, idToUse, thing);
|
||||
return idToUse;
|
||||
}
|
||||
@@ -250,7 +249,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
|
||||
for (I thing : (Iterable<I>) this)
|
||||
{
|
||||
if (!registry.field_148758_b.containsKey(thing)) ret.put(func_148750_c(thing), getId(thing));
|
||||
if (!registry.field_148758_b.containsKey(thing)) ret.put(getNameForObject(thing), getId(thing));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -272,7 +271,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
for (int id : ids)
|
||||
{
|
||||
I thing = getRaw(id);
|
||||
FMLLog.finer("Registry : %s %d %s", func_148750_c(thing), id, thing);
|
||||
FMLLog.finer("Registry : %s %d %s", getNameForObject(thing), id, thing);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,13 +156,13 @@ public class GameData {
|
||||
|
||||
static Item findItem(String modId, String name)
|
||||
{
|
||||
return (Item) getMain().iItemRegistry.func_82594_a(modId + ":" + name);
|
||||
return (Item) getMain().iItemRegistry.getObject(modId + ":" + name);
|
||||
}
|
||||
|
||||
static Block findBlock(String modId, String name)
|
||||
{
|
||||
String key = modId + ":" + name;
|
||||
return getMain().iBlockRegistry.contains(key) ? getMain().iBlockRegistry.func_82594_a(key) : null;
|
||||
return getMain().iBlockRegistry.containsKey(key) ? getMain().iBlockRegistry.getObject(key) : null;
|
||||
}
|
||||
|
||||
static ItemStack findItemStack(String modId, String name)
|
||||
@@ -195,7 +195,7 @@ public class GameData {
|
||||
static UniqueIdentifier getUniqueName(Block block)
|
||||
{
|
||||
if (block == null) return null;
|
||||
String name = getMain().iBlockRegistry.func_148750_c(block);
|
||||
String name = getMain().iBlockRegistry.getNameForObject(block);
|
||||
UniqueIdentifier ui = new UniqueIdentifier(name);
|
||||
if (customItemStacks.contains(ui.modId, ui.name))
|
||||
{
|
||||
@@ -208,7 +208,7 @@ public class GameData {
|
||||
static UniqueIdentifier getUniqueName(Item item)
|
||||
{
|
||||
if (item == null) return null;
|
||||
String name = getMain().iItemRegistry.func_148750_c(item);
|
||||
String name = getMain().iItemRegistry.getNameForObject(item);
|
||||
UniqueIdentifier ui = new UniqueIdentifier(name);
|
||||
if (customItemStacks.contains(ui.modId, ui.name))
|
||||
{
|
||||
@@ -360,7 +360,7 @@ public class GameData {
|
||||
isBlock ? "block" : "item",
|
||||
itemName,
|
||||
newId,
|
||||
isBlock ? newData.iBlockRegistry.get(newId) : newData.iItemRegistry.get(newId)));
|
||||
isBlock ? newData.iBlockRegistry.getObjectById(newId) : newData.iItemRegistry.getObjectById(newId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -387,11 +387,11 @@ public class GameData {
|
||||
|
||||
if (isBlock)
|
||||
{
|
||||
newId = newData.registerBlock(frozen.iBlockRegistry.get(itemName), itemName, null, currId);
|
||||
newId = newData.registerBlock(frozen.iBlockRegistry.getRaw(itemName), itemName, null, currId);
|
||||
}
|
||||
else
|
||||
{
|
||||
newId = newData.registerItem(frozen.iItemRegistry.get(itemName), itemName, null, currId);
|
||||
newId = newData.registerItem(frozen.iItemRegistry.getRaw(itemName), itemName, null, currId);
|
||||
}
|
||||
|
||||
FMLLog.info("Injected new block/item %s : %d (was %d)", itemName, newId, currId);
|
||||
@@ -432,7 +432,7 @@ public class GameData {
|
||||
if (remap.type == Type.BLOCK)
|
||||
{
|
||||
currId = getMain().iBlockRegistry.getId((Block) remap.getTarget());
|
||||
newName = getMain().iBlockRegistry.func_148750_c(remap.getTarget());
|
||||
newName = getMain().iBlockRegistry.getNameForObject(remap.getTarget());
|
||||
FMLLog.fine("The Block %s is being remapped to %s.", remap.name, newName);
|
||||
|
||||
newId = gameData.registerBlock((Block) remap.getTarget(), newName, null, remap.id);
|
||||
@@ -441,7 +441,7 @@ public class GameData {
|
||||
else
|
||||
{
|
||||
currId = getMain().iItemRegistry.getId((Item) remap.getTarget());
|
||||
newName = getMain().iItemRegistry.func_148750_c(remap.getTarget());
|
||||
newName = getMain().iItemRegistry.getNameForObject(remap.getTarget());
|
||||
FMLLog.fine("The Item %s is being remapped to %s.", remap.name, newName);
|
||||
|
||||
newId = gameData.registerItem((Item) remap.getTarget(), newName, null, remap.id);
|
||||
@@ -597,9 +597,9 @@ public class GameData {
|
||||
throw new RuntimeException("Cannot register an itemblock before its block");
|
||||
}
|
||||
|
||||
if (iItemRegistry.get(idHint) != null)
|
||||
if (iItemRegistry.getObjectById(idHint) != null)
|
||||
{
|
||||
throw new IllegalStateException(String.format("The Item Registry slot %d is already used by %s", idHint, iItemRegistry.get(idHint)));
|
||||
throw new IllegalStateException(String.format("The Item Registry slot %d is already used by %s", idHint, iItemRegistry.getObjectById(idHint)));
|
||||
}
|
||||
|
||||
if (!freeSlot(idHint)) // temporarily free the slot occupied by the Block for the ItemBlock registration
|
||||
|
||||
@@ -90,7 +90,7 @@ public class GameRegistry
|
||||
{
|
||||
computeSortedGeneratorList();
|
||||
}
|
||||
long worldSeed = world.func_72905_C();
|
||||
long worldSeed = world.getSeed();
|
||||
Random fmlRandom = new Random(worldSeed);
|
||||
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
@@ -214,38 +214,38 @@ public class GameRegistry
|
||||
|
||||
public static IRecipe addShapedRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
return CraftingManager.func_77594_a().func_92103_a(output, params);
|
||||
return CraftingManager.getInstance().addRecipe(output, params);
|
||||
}
|
||||
|
||||
public static void addShapelessRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
CraftingManager.func_77594_a().func_77596_b(output, params);
|
||||
CraftingManager.getInstance().addShapelessRecipe(output, params);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addRecipe(IRecipe recipe)
|
||||
{
|
||||
CraftingManager.func_77594_a().func_77592_b().add(recipe);
|
||||
CraftingManager.getInstance().getRecipeList().add(recipe);
|
||||
}
|
||||
|
||||
public static void addSmelting(Block input, ItemStack output, float xp)
|
||||
{
|
||||
FurnaceRecipes.func_77602_a().func_151393_a(input, output, xp);
|
||||
FurnaceRecipes.smelting().func_151393_a(input, output, xp);
|
||||
}
|
||||
|
||||
public static void addSmelting(Item input, ItemStack output, float xp)
|
||||
{
|
||||
FurnaceRecipes.func_77602_a().func_151396_a(input, output, xp);
|
||||
FurnaceRecipes.smelting().func_151396_a(input, output, xp);
|
||||
}
|
||||
|
||||
public static void addSmelting(ItemStack input, ItemStack output, float xp)
|
||||
{
|
||||
FurnaceRecipes.func_77602_a().func_151394_a(input, output, xp);
|
||||
FurnaceRecipes.smelting().func_151394_a(input, output, xp);
|
||||
}
|
||||
|
||||
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id)
|
||||
{
|
||||
TileEntity.func_145826_a(tileEntityClass, id);
|
||||
TileEntity.addMapping(tileEntityClass, id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,8 +258,8 @@ public class GameRegistry
|
||||
*/
|
||||
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
|
||||
{
|
||||
TileEntity.func_145826_a(tileEntityClass, id);
|
||||
Map<String,Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "field_145855_i");
|
||||
TileEntity.addMapping(tileEntityClass, id);
|
||||
Map<String,Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "nameToClassMap");
|
||||
for (String s: alternatives)
|
||||
{
|
||||
if (!teMappings.containsKey(s))
|
||||
@@ -334,8 +334,8 @@ public class GameRegistry
|
||||
ItemStack foundStack = GameData.findItemStack(modId, name);
|
||||
if (foundStack != null)
|
||||
{
|
||||
ItemStack is = foundStack.func_77946_l();
|
||||
is.field_77994_a = Math.min(stackSize, is.func_77976_d());
|
||||
ItemStack is = foundStack.copy();
|
||||
is.stackSize = Math.min(stackSize, is.getMaxStackSize());
|
||||
return is;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -127,11 +127,11 @@ public class LanguageRegistry
|
||||
{
|
||||
String objectName;
|
||||
if (objectToName instanceof Item) {
|
||||
objectName=((Item)objectToName).func_77658_a();
|
||||
objectName=((Item)objectToName).getUnlocalizedName();
|
||||
} else if (objectToName instanceof Block) {
|
||||
objectName=((Block)objectToName).func_149739_a();
|
||||
objectName=((Block)objectToName).getUnlocalizedName();
|
||||
} else if (objectToName instanceof ItemStack) {
|
||||
objectName=((ItemStack)objectToName).func_77973_b().func_77667_c((ItemStack)objectToName);
|
||||
objectName=((ItemStack)objectToName).getItem().getUnlocalizedName((ItemStack)objectToName);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("Illegal object for naming %s",objectToName));
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class VillagerRegistry
|
||||
public static Object getVillageComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random,
|
||||
int p1, int p2, int p3, int p4, int p5)
|
||||
{
|
||||
return instance().villageCreationHandlers.get(villagePiece.field_75090_a).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, p4, p5);
|
||||
return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, p4, p5);
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ public class VillagerRegistry
|
||||
{
|
||||
if (min > 0 && max > 0)
|
||||
{
|
||||
EntityVillager.field_70958_bB.put(item, new Tuple(min, max));
|
||||
EntityVillager.villagersSellingList.put(item, new Tuple(min, max));
|
||||
}
|
||||
EntityVillager.func_146091_a(list, item, random, chance);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ public class VillagerRegistry
|
||||
{
|
||||
if (min > 0 && max > 0)
|
||||
{
|
||||
EntityVillager.field_70960_bC.put(item, new Tuple(min, max));
|
||||
EntityVillager.blacksmithSellingList.put(item, new Tuple(min, max));
|
||||
}
|
||||
EntityVillager.func_146089_b(list, item, random, chance);
|
||||
}
|
||||
@@ -245,6 +245,6 @@ public class VillagerRegistry
|
||||
{
|
||||
int extra = instance().newVillagerIds.size();
|
||||
int trade = rand.nextInt(5 + extra);
|
||||
villager.func_70938_b(trade < 5 ? trade : instance().newVillagerIds.get(trade - 5));
|
||||
villager.setProfession(trade < 5 ? trade : instance().newVillagerIds.get(trade - 5));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user