mirror of
https://github.com/GTNewHorizons/DummyCore.git
synced 2026-11-28 16:06:11 +00:00
1.10
experimental changes
This commit is contained in:
1 parent
74e3c98569
commit
d5ac8090b9
11 files changed
+233
-74
No files matched your search
@@ -69,25 +69,13 @@ public class CoreInitialiser{
|
||||
public static SimpleNetworkWrapper network;
|
||||
@SidedProxy(clientSide = "DummyCore.Utils.NetProxy_Client",serverSide = "DummyCore.Utils.NetProxy_Server")
|
||||
public static NetProxy_Server proxy;
|
||||
@Metadata(value="DummyCore")
|
||||
public static ModMetadata meta = new ModMetadata()
|
||||
{
|
||||
String modId = "DummyCore";
|
||||
String name = "DummyCore";
|
||||
String version = "1.10";
|
||||
String credits = "Modbder";
|
||||
List<String> authorList = Arrays.asList(new String[] {
|
||||
"Dummy Thinking Team; Modbder; TheDen2099"
|
||||
});
|
||||
String description ="Dummy Core is a required package to launch mods made by Dummy Thinking team.";
|
||||
};
|
||||
|
||||
public static final DummyPacketHandler packetHandler = new DummyPacketHandler();
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e)
|
||||
{
|
||||
e.getModMetadata().autogenerated = false;
|
||||
e.getModMetadata().modId = "DummyCore";
|
||||
e.getModMetadata().name="Dummy Core";
|
||||
e.getModMetadata().version = "1.10";
|
||||
@@ -102,10 +90,6 @@ public class CoreInitialiser{
|
||||
network.registerMessage(DummyPacketHandler.class, DummyPacketIMSG.class, 0, Side.CLIENT);
|
||||
network.registerMessage(DummyTilePacketHandler.class, DummyPacketIMSG_Tile.class, 1, Side.SERVER);
|
||||
network.registerMessage(DummyTilePacketHandler.class, DummyPacketIMSG_Tile.class, 1, Side.CLIENT);
|
||||
for(int i = 0; i < 16; ++i)
|
||||
{
|
||||
Core.lightColors.add(EnumLightColor.values()[i]);
|
||||
}
|
||||
try
|
||||
{
|
||||
Core.registerModAbsolute(getClass(), "DummyCore", e.getModConfigurationDirectory().getAbsolutePath(),cfg);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package DummyCore.Events;
|
||||
|
||||
import DummyCore.Utils.DataStorage;
|
||||
import DummyCore.Utils.DummyData;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -10,8 +12,9 @@ public class DummyEvent_OnClientGUIButtonPress extends Event{
|
||||
public String client_ButtonClassPath;
|
||||
public EntityPlayer presser;
|
||||
public int x, y, z;
|
||||
public DummyData[] additionalData;
|
||||
|
||||
public DummyEvent_OnClientGUIButtonPress(int bID, String s, String s_1, EntityPlayer player,int dx, int dy, int dz)
|
||||
public DummyEvent_OnClientGUIButtonPress(int bID, String s, String s_1, EntityPlayer player,int dx, int dy, int dz, DummyData[] data)
|
||||
{
|
||||
buttonID = bID;
|
||||
client_ParentClassPath = s;
|
||||
@@ -20,6 +23,7 @@ public class DummyEvent_OnClientGUIButtonPress extends Event{
|
||||
x = dx;
|
||||
y = dy;
|
||||
z = dz;
|
||||
additionalData = data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,9 @@ import net.minecraftforge.common.config.Configuration;
|
||||
import DummyCore.Core.Core;
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import DummyCore.Utils.IDummyMultiItem;
|
||||
import DummyCore.Utils.Notifier;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@@ -30,10 +32,9 @@ public class ItemRegistry {
|
||||
* Use this to register new simple items.
|
||||
* @version From DummyCore 1.0
|
||||
* @param i - the item to be registered.
|
||||
* @param name - in-game name of the item. Will be written to the corresponding .lang file
|
||||
* @param name - name of the item in the itemregistry
|
||||
* @param modClass - class file of your mod. If registered from the mod itself, use getClass(), else just put in this field something like YourModClassName.class
|
||||
*/
|
||||
@Deprecated
|
||||
public static void registerItem(Item i, String name, Class modClass)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
@@ -42,6 +43,7 @@ public class ItemRegistry {
|
||||
i.setCreativeTab(Core.getItemTabForMod(modClass));
|
||||
itemsList.put(i, Core.getItemTabForMod(modClass).getTabLabel());
|
||||
}
|
||||
GameRegistry.registerItem(i, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,8 +52,10 @@ public class ItemRegistry {
|
||||
* @param i - the item to be registered.
|
||||
* @param modClass - class file of your mod. If registered from the mod itself, use getClass(), else just put in this field something like YourModClassName.class
|
||||
*/
|
||||
@Deprecated
|
||||
public static void registerItem(Item i, Class modClass)
|
||||
{
|
||||
Notifier.notifyCustomMod("DummyCore", "[Warning] Mod "+Core.getModName(Core.getIdForMod(modClass))+" tries to register items in an outdated way, may cause errors!");
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
@@ -59,4 +63,6 @@ public class ItemRegistry {
|
||||
itemsList.put(i, Core.getItemTabForMod(modClass).getTabLabel());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import ec3.common.entity.EntityMRUPresence;
|
||||
import ec3.utils.common.ECUtils;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
@@ -6,6 +6,7 @@ public class DummyConfig implements IDummyConfig{
|
||||
|
||||
public int MultiItemUID;
|
||||
public int MultiBlockUID;
|
||||
public static int dummyCoreSyncTimer;
|
||||
private static int mainMenuID;
|
||||
public boolean removeMissingTexturesErrors;
|
||||
public static boolean enableNotifierLogging;
|
||||
@@ -18,6 +19,7 @@ public class DummyConfig implements IDummyConfig{
|
||||
enableNotifierLogging = config.getBoolean("enableNotifierLogging", "GLOBAL", true, "");
|
||||
shouldChangeImage = config.getBoolean("shouldChangeImageInCreativeTabs", "GLOBAL", true, "");
|
||||
mainMenuID = config.getInt("mainMenuID", "GLOBAL", 0,0,Integer.MAX_VALUE, "");
|
||||
dummyCoreSyncTimer = config.getInt("syncTimer", "GLOBAL", 100, 10, 1000, "Time inbetween syncing of data. The more the number is, the worse the sync is going to be, hwever, the less packets will be sent, and, therefore, the less annoying the server lag will be.");
|
||||
}
|
||||
|
||||
public static void setMainMenu(int i)
|
||||
|
||||
@@ -44,10 +44,11 @@ public class DummyDataUtils {
|
||||
@SubscribeEvent
|
||||
public void serverWorldLoad(WorldEvent.Load event)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
World w = event.world;
|
||||
if(w != null && !w.isRemote && w.provider != null && w.provider.dimensionId == 0 && w.provider instanceof WorldProviderSurface)
|
||||
if(w != null && !w.isRemote && w.provider != null && w.provider.dimensionId == 0)
|
||||
{
|
||||
File f = event.world.getSaveHandler().getWorldDirectory();
|
||||
if(f != null)
|
||||
@@ -380,6 +381,8 @@ public class DummyDataUtils {
|
||||
|
||||
public static void syncGlobalDataToClient(String modid, String dataName)
|
||||
{
|
||||
SyncUtils.addRequiresSync(modid, dataName);
|
||||
/*
|
||||
if(MiscUtils.registeredServerWorldData.containsKey(modid+"|"+dataName))
|
||||
{
|
||||
String dataString = "||mod:DummyCore.InfoSync"+"||"+modid+":"+dataName+"||ddata:"+MiscUtils.registeredServerWorldData.get(modid+"|"+dataName);
|
||||
@@ -389,10 +392,13 @@ public class DummyDataUtils {
|
||||
{
|
||||
Notifier.notifyCustomMod(modid, "The sync packet for data "+modid+"|"+dataName+" could not be generated - the requested server data does not exist!");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static void syncGlobalDataToClient(String modid)
|
||||
{
|
||||
SyncUtils.addRequiresSync(modid, modid);
|
||||
/*
|
||||
if(MiscUtils.registeredServerWorldData.containsKey(modid+"|"+modid))
|
||||
{
|
||||
String dataString = "||mod:DummyCore.InfoSync"+"||"+modid+":"+modid+"||ddata:"+MiscUtils.registeredServerWorldData.get(modid+"|"+modid);
|
||||
@@ -402,10 +408,13 @@ public class DummyDataUtils {
|
||||
{
|
||||
Notifier.notifyCustomMod(modid, "The sync packet for data "+modid+ "could not be generated - the requested server data does not exist!");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static void syncPlayerDataToClient(String playerName, String modid, String dataName)
|
||||
{
|
||||
SyncUtils.addRequiresSync(playerName, modid, dataName);
|
||||
/*
|
||||
if(MiscUtils.registeredServerData.containsKey(playerName+"_"+modid+"|"+dataName))
|
||||
{
|
||||
String dataString = "||mod:DummyCore.PlayerInfoSync"+"||"+"playerName:"+playerName+"||"+modid+ ":" + dataName+"||ddata:"+MiscUtils.registeredServerData.get(playerName+"_"+modid+"|"+dataName);
|
||||
@@ -415,6 +424,7 @@ public class DummyDataUtils {
|
||||
{
|
||||
Notifier.notifyCustomMod(modid, "The sync packet for data "+playerName+"_"+modid+ "could not be generated - the requested server data does not exist!");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -51,6 +52,7 @@ import cpw.mods.fml.server.FMLServerHandler;
|
||||
*/
|
||||
public class DummyEventHandler {
|
||||
|
||||
public static int syncTime;
|
||||
public static boolean[] isKeyPressed;
|
||||
|
||||
public void onBlockBeeingBroken(PlayerEvent.BreakSpeed event)
|
||||
@@ -228,13 +230,16 @@ public class DummyEventHandler {
|
||||
int x = Integer.parseInt(packetData[5].fieldValue);
|
||||
int y = Integer.parseInt(packetData[6].fieldValue);
|
||||
int z = Integer.parseInt(packetData[7].fieldValue);
|
||||
DummyData[] data = new DummyData[packetData.length-8];
|
||||
for(int i = 8; i < packetData.length; ++i)
|
||||
data[i-8] = packetData[i];
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(side == Side.SERVER)
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
ServerConfigurationManager manager = server.getConfigurationManager();
|
||||
EntityPlayer player = manager.func_152612_a(username);
|
||||
MinecraftForge.EVENT_BUS.post(new DummyEvent_OnClientGUIButtonPress(id, pClName, bClName, player,x,y,z));
|
||||
MinecraftForge.EVENT_BUS.post(new DummyEvent_OnClientGUIButtonPress(id, pClName, bClName, player,x,y,z,data));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -441,5 +446,19 @@ public class DummyEventHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerTick(TickEvent.ServerTickEvent event)
|
||||
{
|
||||
if(event.phase == Phase.END)
|
||||
{
|
||||
++syncTime;
|
||||
if(syncTime >= DummyConfig.dummyCoreSyncTimer)
|
||||
{
|
||||
syncTime = 0;
|
||||
SyncUtils.makeSync_LotsSmallPackets();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -131,10 +131,13 @@ public class MiscUtils {
|
||||
* @param texture - path to your thexture.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void bindTexture(String mod, String texture)
|
||||
{
|
||||
//I hope, that MC does not touches the files upon registering a new one of these.
|
||||
ResourceLocation loc = new ResourceLocation(mod,texture);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(loc);
|
||||
//Not sure, if this is required due to gc, but removing the possible leak anyway?
|
||||
loc = null;
|
||||
}
|
||||
|
||||
@@ -175,54 +178,64 @@ public class MiscUtils {
|
||||
*/
|
||||
public static void dropItemsOnBlockBreak(World par1World, int par2, int par3, int par4, Block par5, int par6)
|
||||
{
|
||||
IInventory inv = (IInventory)par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
if (inv != null)
|
||||
{
|
||||
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1)
|
||||
{
|
||||
ItemStack itemstack = inv.getStackInSlot(j1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
float f = par1World.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = par1World.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = par1World.rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.stackSize > 0)
|
||||
{
|
||||
int k1 = par1World.rand.nextInt(21) + 10;
|
||||
|
||||
if (k1 > itemstack.stackSize)
|
||||
{
|
||||
k1 = itemstack.stackSize;
|
||||
}
|
||||
|
||||
itemstack.stackSize -= k1;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (double)((float)par1World.rand.nextGaussian() * f3);
|
||||
entityitem.motionY = (double)((float)par1World.rand.nextGaussian() * f3 + 0.2F);
|
||||
entityitem.motionZ = (double)((float)par1World.rand.nextGaussian() * f3);
|
||||
par1World.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Was causing too much issues, had to add a try/catch statement...
|
||||
try
|
||||
{
|
||||
IInventory inv = (IInventory)par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
if (inv != null)
|
||||
{
|
||||
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1)
|
||||
{
|
||||
ItemStack itemstack = inv.getStackInSlot(j1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
float f = par1World.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = par1World.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = par1World.rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.stackSize > 0)
|
||||
{
|
||||
int k1 = par1World.rand.nextInt(21) + 10;
|
||||
|
||||
if (k1 > itemstack.stackSize)
|
||||
{
|
||||
k1 = itemstack.stackSize;
|
||||
}
|
||||
|
||||
itemstack.stackSize -= k1;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (double)((float)par1World.rand.nextGaussian() * f3);
|
||||
entityitem.motionY = (double)((float)par1World.rand.nextGaussian() * f3 + 0.2F);
|
||||
entityitem.motionZ = (double)((float)par1World.rand.nextGaussian() * f3);
|
||||
par1World.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception ex)
|
||||
{
|
||||
Notifier.notifyCustomMod("DummyCore", "[ERROR]Trying to drop items upon block breaking, but caught an exception:");
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* More readable way of getting entity's health
|
||||
* More readable way of getting entity's health(used untill the renaming)
|
||||
* @version From DummyCore 1.0
|
||||
* @param e - the Entity itself
|
||||
* @return The amount of health that entity has.
|
||||
*/
|
||||
@Deprecated
|
||||
public static float getEntityHealth(EntityLivingBase e)
|
||||
{
|
||||
return e.getHealth();
|
||||
@@ -249,12 +262,14 @@ public class MiscUtils {
|
||||
|
||||
/**
|
||||
* Adds the given ItemStack to the given inventory, also updating the inventory.
|
||||
* Need to re-write the code, something here does not seem right.
|
||||
* @version From DummyCore 1.4
|
||||
* @param s - the stack to add
|
||||
* @param i - the inventory for the stack
|
||||
* @param remote - use world.isRemote here. This function is usually called on both sides, however, you can call it on server only, it will be ok, then put false in this field
|
||||
* @return true if adding was successful, false if not.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean addItemToInventory(ItemStack s, IInventory i, boolean remote)
|
||||
{
|
||||
|
||||
@@ -639,7 +654,7 @@ public class MiscUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if the given class actually has the named method. Used when working with APIs of different mods
|
||||
* Used to check if the given class actually has the named method. Used when working with APIs of different mods(actually not)
|
||||
* @param c - the class
|
||||
* @param mName - the name of the method
|
||||
* @param classes - actual parameters of the method
|
||||
@@ -719,9 +734,9 @@ public class MiscUtils {
|
||||
{
|
||||
Chunk chunk = w.getChunkFromBlockCoords(x,z);
|
||||
byte[] b = chunk.getBiomeArray();
|
||||
byte cbiome = b[(z & 0xf) << 4 | x & 0xf];
|
||||
byte cbiome = b[(z & 0xf) << 4 | x & 0xf]; //What is even going on here? Can this code be a little bit more readable?
|
||||
cbiome = (byte)(biome.biomeID & 0xff);
|
||||
b[(z & 0xf) << 4 | x & 0xf] = cbiome;
|
||||
b[(z & 0xf) << 4 | x & 0xf] = cbiome; //Looks like not.
|
||||
chunk.setBiomeArray(b);
|
||||
notifyBiomeChange(x,z,biome.biomeID);
|
||||
}
|
||||
@@ -803,10 +818,11 @@ public class MiscUtils {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderItemStack_Full(ItemStack stk,double posX, double posY, double posZ, double screenPosX, double screenPosY, double screenPosZ, float rotation, float rotationZ, float colorRed, float colorGreen, float colorBlue, float offsetX, float offsetY, float offsetZ)
|
||||
{
|
||||
ItemStack itemstack = stk;
|
||||
ItemStack itemstack = stk.copy();
|
||||
itemstack.stackSize = 1; //Doing this so no weird glitches occur.
|
||||
final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
||||
RenderBlocks renderBlocksRi = new RenderBlocks();
|
||||
Random random = new Random();
|
||||
Random random = new Random();
|
||||
boolean renderWithColor = true;
|
||||
float zLevel;
|
||||
|
||||
@@ -934,6 +950,7 @@ public class MiscUtils {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(Minecraft.getMinecraft().renderEngine.getResourceLocation(stk.getItemSpriteNumber()));
|
||||
TextureUtil.func_147945_b();
|
||||
}
|
||||
itemstack = null; //Again, there is a gc for that, but removing possible leaks is never a bad thing to do...
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1240,12 +1257,13 @@ public class MiscUtils {
|
||||
* @param value - what you actually want to be set in the variable field
|
||||
* @param fieldNames - the names of the field you are changing. Should be both for obfuscated and compiled code.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setPrivateFinalValue(Class classToAccess, Object instance, Object value, String fieldNames[])
|
||||
{
|
||||
Field field = ReflectionHelper.findField(classToAccess, ObfuscationReflectionHelper.remapFieldNames(classToAccess.getName(), fieldNames));
|
||||
try
|
||||
{
|
||||
ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldNames);
|
||||
ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldNames); //Sooo... Why would I use this method, if there is a ReflectionHelper?
|
||||
//Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
//modifiersField.setAccessible(true);
|
||||
//modifiersField.setInt(field, field.getModifiers() & 0xffffffef);
|
||||
@@ -1344,6 +1362,20 @@ public class MiscUtils {
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void handleButtonPress(int buttonID, Class<? extends Gui> parentClass, Class<? extends GuiButton> buttonClass, EntityPlayer presser, int bX, int bY, int bZ)
|
||||
{
|
||||
handleButtonPress(buttonID, parentClass, buttonClass, presser, bX, bY, bZ, "||data:no data");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the packet to the server, that notifies the server about GUI button pressed. This can be actually used for any GUI, not only in world, but why would you like to do it?
|
||||
* @param buttonID - the ID on the button in the code. Can be get via yourGuiButton.id
|
||||
* @param parentClass - the GUI class, that contains the button
|
||||
* @param buttonClass - the GUI class of the button
|
||||
* @param presser - the player, who presses the button. Usually Minecraft.getMinecraft().thePlayer but sometimes you may want to send packets of other SMP players(maybe?)
|
||||
* @param additionalData - Some additional data, that you might want to carry around. Should be a String, representing the DummyData, otherwise will get added tp the Z coordinate and make it unreadable.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void handleButtonPress(int buttonID, Class<? extends Gui> parentClass, Class<? extends GuiButton> buttonClass, EntityPlayer presser, int bX, int bY, int bZ, String additionalData)
|
||||
{
|
||||
String dataString = "||mod:DummyCore.guiButton";
|
||||
DummyData id = new DummyData("id",buttonID);
|
||||
@@ -1361,7 +1393,7 @@ public class MiscUtils {
|
||||
DataStorage.addDataToString(dy);
|
||||
DataStorage.addDataToString(dz);
|
||||
String newDataString = DataStorage.getDataString();
|
||||
dataString+=newDataString;
|
||||
dataString+=newDataString+additionalData;
|
||||
DummyPacketIMSG simplePacket = new DummyPacketIMSG(dataString);
|
||||
CoreInitialiser.packetHandler.sendToServer(simplePacket);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class NetProxy_Client extends NetProxy_Server{
|
||||
public void choseDisplayStack(CreativePageBlocks blocks)
|
||||
{
|
||||
World w = Minecraft.getMinecraft().theWorld;
|
||||
if(w.isRemote && w.getWorldTime() % 20 == 0)
|
||||
if(w.isRemote && w.getWorldTime() % 60 == 0)
|
||||
{
|
||||
blocks.delayTime = 0;
|
||||
blocks.blockList = blocks.initialiseBlocksList();
|
||||
@@ -128,7 +128,7 @@ public class NetProxy_Client extends NetProxy_Server{
|
||||
public void choseDisplayStack(CreativePageItems items)
|
||||
{
|
||||
World w = Minecraft.getMinecraft().theWorld;
|
||||
if(w.isRemote && w.getWorldTime() % 20 == 0)
|
||||
if(w.isRemote && w.getWorldTime() % 60 == 0)
|
||||
{
|
||||
items.delayTime = 0;
|
||||
items.itemList = items.initialiseItemsList();
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
|
||||
public class SyncUtils {
|
||||
|
||||
public static List<String> needsSyncing_Global = new ArrayList();
|
||||
public static List<String> needsSyncing_Player = new ArrayList();
|
||||
|
||||
public static void addRequiresSync(String playerName, String modid, String dataName)
|
||||
{
|
||||
String mainSyncString = playerName+"|"+modid+":"+dataName;
|
||||
if(!needsSyncing_Player.contains(mainSyncString))
|
||||
needsSyncing_Player.add(mainSyncString);
|
||||
}
|
||||
|
||||
public static void addRequiresSync(String modid, String dataName)
|
||||
{
|
||||
String mainSyncString = modid+":"+dataName;
|
||||
if(!needsSyncing_Global.contains(mainSyncString))
|
||||
needsSyncing_Global.add(mainSyncString);
|
||||
}
|
||||
|
||||
public static void makeSync_LotsSmallPackets()
|
||||
{
|
||||
for(int i = 0; i < needsSyncing_Global.size(); ++i)
|
||||
{
|
||||
String syncID = needsSyncing_Global.get(i);
|
||||
int indexOfStrip = syncID.indexOf(":");
|
||||
if(indexOfStrip != -1)
|
||||
{
|
||||
String modid = syncID.substring(0,indexOfStrip);
|
||||
String dataName = syncID.substring(indexOfStrip+1);
|
||||
if(MiscUtils.registeredServerWorldData.containsKey(modid+"|"+dataName))
|
||||
{
|
||||
String dataString = "||mod:DummyCore.InfoSync"+"||"+modid+":"+dataName+"||ddata:"+MiscUtils.registeredServerWorldData.get(modid+"|"+dataName);
|
||||
DummyPacketIMSG simplePacket = new DummyPacketIMSG(dataString);
|
||||
CoreInitialiser.packetHandler.sendToAll(simplePacket);
|
||||
}else
|
||||
{
|
||||
Notifier.notifyCustomMod(modid, "The sync packet for data "+modid+"|"+dataName+" could not be generated - the requested server data does not exist!");
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < needsSyncing_Player.size(); ++i)
|
||||
{
|
||||
String syncID = needsSyncing_Player.get(i);
|
||||
int indexOfStrip = syncID.indexOf(":");
|
||||
int indexOfPlayer = syncID.indexOf("|");
|
||||
if(indexOfPlayer != -1 && indexOfStrip != -1)
|
||||
{
|
||||
String playerName = syncID.substring(0, indexOfPlayer);
|
||||
String modid = syncID.substring(indexOfPlayer+1,indexOfStrip);
|
||||
String dataName = syncID.substring(indexOfStrip+1);
|
||||
if(MiscUtils.registeredServerData.containsKey(playerName+"_"+modid+"|"+dataName))
|
||||
{
|
||||
String dataString = "||mod:DummyCore.PlayerInfoSync"+"||"+"playerName:"+playerName+"||"+modid+ ":" + dataName+"||ddata:"+MiscUtils.registeredServerData.get(playerName+"_"+modid+"|"+dataName);
|
||||
DummyPacketIMSG simplePacket = new DummyPacketIMSG(dataString);
|
||||
CoreInitialiser.packetHandler.sendToAll(simplePacket);
|
||||
}else
|
||||
{
|
||||
Notifier.notifyCustomMod(modid, "The sync packet for data "+playerName+"_"+modid+ "could not be generated - the requested server data does not exist!");
|
||||
}
|
||||
}
|
||||
}
|
||||
needsSyncing_Global.clear();
|
||||
needsSyncing_Player.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
/**
|
||||
@@ -19,6 +21,11 @@ public class UnformedItemStack {
|
||||
|
||||
public List<ItemStack> possibleStacks = new ArrayList<ItemStack>();
|
||||
|
||||
public UnformedItemStack()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UnformedItemStack(ItemStack is)
|
||||
{
|
||||
possibleStacks.add(is);
|
||||
@@ -120,4 +127,28 @@ public class UnformedItemStack {
|
||||
if(size <= 0)return null;
|
||||
return this.possibleStacks.get((int)(((int)(time/30))%size));
|
||||
}
|
||||
|
||||
public void writeToNBTTagCompound(NBTTagCompound tag)
|
||||
{
|
||||
NBTTagList items = new NBTTagList();
|
||||
for(ItemStack is : this.possibleStacks)
|
||||
{
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
is.writeToNBT(itemTag);
|
||||
items.appendTag(itemTag);
|
||||
}
|
||||
tag.setTag("unformedISList", items);
|
||||
}
|
||||
|
||||
public void readFromNBTTagCompound(NBTTagCompound tag)
|
||||
{
|
||||
NBTTagList items = tag.getTagList("unformedISList", 10);
|
||||
for(int i = 0; i < items.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound itemTag = items.getCompoundTagAt(i);
|
||||
ItemStack is = ItemStack.loadItemStackFromNBT(itemTag);
|
||||
this.possibleStacks.add(is);
|
||||
}
|
||||
this.sort();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user