mirror of
https://github.com/GTNewHorizons/DummyCore.git
synced 2026-11-08 12:34:47 +00:00
Merge remote-tracking branch 'origin/Dev-Bui'
Conflicts: DummyCore/Core/CoreInitialiser.java DummyCore/Utils/ColoredLightHandler.java
This commit is contained in:
commit
45381b5e62
56 files changed
+4324
-1254
No files matched your search
@@ -4,14 +4,15 @@ import java.util.Hashtable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import DummyCore.Core.Core;
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import DummyCore.Items.MultiItem;
|
||||
import DummyCore.Utils.IDummyMultiBlock;
|
||||
import DummyCore.Utils.IDummyMultiItem;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -44,50 +45,17 @@ public class BlocksRegistry {
|
||||
conf.save();
|
||||
if(blockClass == null)
|
||||
{
|
||||
GameRegistry.registerBlock(b, Core.getModName(Core.getIdForMod(modClass))+".block."+name);
|
||||
GameRegistry.registerBlock(b, name);
|
||||
}else
|
||||
{
|
||||
GameRegistry.registerBlock(b, blockClass, Core.getModName(Core.getIdForMod(modClass))+".block."+name);
|
||||
GameRegistry.registerBlock(b, blockClass, name);
|
||||
}
|
||||
LanguageRegistry.addName(b, blockName);
|
||||
b.setCreativeTab(Core.getBlockTabForMod(modClass));
|
||||
blocksList.put(b, Core.getBlockTabForMod(modClass).getTabLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to add your block to the MultiBlock storage system. This will add your block to the DummyCore creative tab. This does not requires creating new Block variable, and allows you to register lots of blocks, while not using more ID's
|
||||
* @param unlocalisedName - the name of your block in code. Always remember to check this! This is the way to get your blocks if you need to!
|
||||
* @param inGameName - in-game name of the block. Will be written to the corresponding .lang file
|
||||
* @param texturePath - path to the texture file, that will be used for this block. Should be modname:texturename
|
||||
* @param multiBlockHandler - should be an initialized! object, that implements IDummyMultiBlock. Usually it is just an empty .class file. Used to handle different actions, happening with your multiblock. Always remember to check for your block's name! Can be null, then none of actions will be handled.
|
||||
* @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
|
||||
* @version From DummyCore 1.1
|
||||
*/
|
||||
public static void registerMultiBlock(String unlocalisedName, String inGameName, String texturePath, IDummyMultiBlock multiBlockHandler, Class modClass)
|
||||
{
|
||||
String blockName = inGameName;
|
||||
Configuration conf = Core.getLangFileForMod(modClass);
|
||||
conf.load();
|
||||
blockName = conf.get("Blocks Names", unlocalisedName, inGameName).getString();
|
||||
conf.save();
|
||||
if(multiBlockHandler != null)
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
MultiBlock.registerMultiBlock(unlocalisedName, inGameName, texturePath, multiBlockHandler);
|
||||
}else
|
||||
{
|
||||
MultiBlock.registerMultiBlock(unlocalisedName, inGameName, texturePath);
|
||||
b.setCreativeTab(Core.getBlockTabForMod(modClass));
|
||||
blocksList.put(b, Core.getBlockTabForMod(modClass).getTabLabel());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to handle the single id for all of the multiblocks. Do not change this!
|
||||
* @return the id of all the multiblocks
|
||||
* @version From DummyCore 1.1
|
||||
*/
|
||||
public static int getMultiBlockID()
|
||||
{
|
||||
return CoreInitialiser.mBlock.blockuid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package DummyCore.Blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.1
|
||||
* @Description This is used for MultiBlocks handling. Do not change anything here! No explanation will be given to any functions in here, because you do not need this.
|
||||
*/
|
||||
public class ItemMultiBlock extends ItemBlock{
|
||||
|
||||
public ItemMultiBlock(int par1) {
|
||||
super(par1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceItemBlockOnSide(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer, ItemStack par7ItemStack)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(MultiBlock.handler[i] != null)
|
||||
return MultiBlock.handler[i].canPlaceItemBlockOnSide(par1World, par2, par3, par4, par5, par6EntityPlayer, par7ItemStack);
|
||||
}
|
||||
return super.canPlaceItemBlockOnSide(par1World, par2, par3, par4, par5, par6EntityPlayer, par7ItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
int amount = 0;
|
||||
for(int i = 0; i < MultiBlock.blockNamesUnlocalisedList.size(); ++i)
|
||||
{
|
||||
if(MultiBlock.blockNamesUnlocalisedList.get(i) != null)
|
||||
{
|
||||
++amount;
|
||||
}
|
||||
}
|
||||
if(amount > 0)
|
||||
{
|
||||
MultiBlock.icon = new Icon[amount];
|
||||
for(int i = 0; i < MultiBlock.blockTextures.size(); ++i)
|
||||
{
|
||||
if(MultiBlock.blockTextures.get(i) != null)
|
||||
{
|
||||
MultiBlock.icon[i] = par1IconRegister.registerIcon(MultiBlock.blockTextures.get(i));
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(MultiBlock.handler[i] != null)
|
||||
MultiBlock.handler[i].registerIcons(par1IconRegister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int par1)
|
||||
{
|
||||
return MultiBlock.icon[par1];
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemDisplayName(ItemStack par1ItemStack)
|
||||
{
|
||||
return MultiBlock.blockNames.get(par1ItemStack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for(int i = 0; i < MultiBlock.blockNamesUnlocalisedList.size(); ++i)
|
||||
if(MultiBlock.blockNamesUnlocalisedList.get(i) != null)
|
||||
par3List.add(i, new ItemStack(par1,1,i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(MultiBlock.handler[i] != null)
|
||||
MultiBlock.handler[i].onItemBlockUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(MultiBlock.handler[i] != null)
|
||||
MultiBlock.handler[i].addInformation(par1ItemStack, par2EntityPlayer, par3List, par4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack par1ItemStack)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(MultiBlock.handler[i] != null)
|
||||
return MultiBlock.handler[i].getRarity(par1ItemStack);
|
||||
}
|
||||
return EnumRarity.common;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
package DummyCore.Blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import DummyCore.Utils.IDummyMultiBlock;
|
||||
import DummyCore.Utils.IDummyMultiItem;
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.1
|
||||
* @Description Used to handle all the multiblocks. Do not change anything here! Some explanation to the required functions will be given.
|
||||
*/
|
||||
public class MultiBlock extends Block{
|
||||
|
||||
protected static List<String> blockNames = new ArrayList();
|
||||
protected static List<String> blockNamesUnlocalisedList = new ArrayList();
|
||||
protected static Hashtable<String,Integer> blockNamesUnlocalised = new Hashtable();
|
||||
protected static List<String> blockTextures = new ArrayList();
|
||||
protected static int id = -1;
|
||||
public static int blockuid;
|
||||
protected static Icon[] icon;
|
||||
protected static IDummyMultiBlock[] handler = new IDummyMultiBlock[1024];
|
||||
public MultiBlock(int par1) {
|
||||
super(par1, Material.circuits);
|
||||
blockuid = par1;
|
||||
}
|
||||
|
||||
private static void addBlockName(int i, String name)
|
||||
{
|
||||
blockNames.add(i, name);
|
||||
}
|
||||
|
||||
private static void addBlockNameMain(int i, String name)
|
||||
{
|
||||
blockNamesUnlocalisedList.add(i, name);
|
||||
}
|
||||
|
||||
private static void addBlockTexture(int i, String texture)
|
||||
{
|
||||
blockTextures.add(i, texture);
|
||||
}
|
||||
|
||||
private static int getNextFreeID()
|
||||
{
|
||||
return ++id;
|
||||
}
|
||||
|
||||
private static void registerMain(int i, String s)
|
||||
{
|
||||
blockNamesUnlocalised.put(s, i);
|
||||
addBlockNameMain(i,s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the metadata(aka. damage) of your block.
|
||||
* @version From DummyCore 1.1
|
||||
* @param unlocalisedName - name of your block. Remember, that this is the in-code name!
|
||||
* @return the metadata, that was given to your block.
|
||||
*/
|
||||
public static int getMetadataByName(String unlocalisedName)
|
||||
{
|
||||
int i = -1;
|
||||
if(blockNamesUnlocalised.containsKey(unlocalisedName))
|
||||
{
|
||||
i = blockNamesUnlocalised.get(unlocalisedName);
|
||||
}else
|
||||
{
|
||||
throw new RuntimeException("No blocks with "+unlocalisedName+" index were found!");
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the corresponding ItemStack of your block.
|
||||
* @version From DummyCore 1.1
|
||||
* @param unlocalisedName - name of your block. Remember, that this is the in-code name!
|
||||
* @param size - the size of this stack. max is 64.
|
||||
* @return automatically generated ItemStack for your block, with MultiBlock id, metadata of your block and size that was given.
|
||||
*/
|
||||
public static ItemStack getStackByName(String unlocalisedName, int size)
|
||||
{
|
||||
ItemStack s = new ItemStack(blockuid,getMetadataByName(unlocalisedName),size);
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to register multiblocks without handler.
|
||||
* @version From DummyCore 1.1
|
||||
* @param unlocalisedName - name of your block. Remember, that this is the in-code name!
|
||||
* @param inGameName - in-game name of the block.
|
||||
* @param texturePath - path to the texture file, that will be used for this block. Should be modname:texturename
|
||||
*/
|
||||
public static void registerMultiBlock(String unlocalisedName, String inGameName, String texturePath)
|
||||
{
|
||||
int blockMeta = getNextFreeID();
|
||||
registerMain(blockMeta,unlocalisedName);
|
||||
addBlockName(blockMeta,inGameName);
|
||||
addBlockTexture(blockMeta,texturePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to register multiblocks with handler.
|
||||
* @param unlocalisedName - name of your block. Remember, that this is the in-code name!
|
||||
* @param inGameName - in-game name of the block.
|
||||
* @param texturePath - path to the texture file, that will be used for this block. Should be modname:texturename
|
||||
* @param multiblockHandler - should be an initialized! object, that implements IDummyMultiBlock. Usually it is just an empty .class file. Used to handle different actions, happening with your multiblock. Always remember to check for your block's name!
|
||||
*/
|
||||
public static void registerMultiBlock(String unlocalisedName, String inGameName, String texturePath, IDummyMultiBlock multiblockHandler)
|
||||
{
|
||||
registerMultiBlock(unlocalisedName,inGameName,texturePath);
|
||||
handler[getMetadataByName(unlocalisedName)] = multiblockHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
return handler[i].getBlockHardness(MiscUtils.getBlock(par1World, par2, par3, par4),par1World, par2, par3, par4);
|
||||
}
|
||||
return this.blockHardness;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public float getBlockBrightness(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
return handler[i].getBlockBrightness(MiscUtils.getBlock(par1IBlockAccess, par2, par3, par4),par1IBlockAccess, par2, par3, par4);
|
||||
}
|
||||
return super.getBlockBrightness(par1IBlockAccess, par2, par3, par4);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
return handler[i].getBlockTexture(MiscUtils.getBlock(par1IBlockAccess, par2, par3, par4), par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
return icon[par1IBlockAccess.getBlockMetadata(par2,par3,par4)];
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
return handler[i].getSelectedBoundingBoxFromPool(MiscUtils.getBlock(par1World, par2, par3, par4), par1World, par2, par3, par4);
|
||||
}
|
||||
return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
public static String getUnlocalisedNameByMetadata(int meta)
|
||||
{
|
||||
return blockNamesUnlocalisedList.get(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
return handler[i].getCollisionBoundingBoxFromPool(MiscUtils.getBlock(par1World, par2, par3, par4), par1World, par2, par3, par4);
|
||||
}
|
||||
return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
handler[i].randomDisplayTick(MiscUtils.getBlock(par1World, par2, par3, par4), par1World, par2, par3, par4, par5Random);
|
||||
}
|
||||
super.randomDisplayTick(par1World, par2, par3, par4, par5Random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
handler[i].onBlockDestroyedByPlayer(MiscUtils.getBlock(par1World, par2, par3, par4), par1World, par2, par3, par4, par5);
|
||||
}
|
||||
super.onBlockDestroyedByPlayer(par1World, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
handler[i].onNeighborBlockChange(MiscUtils.getBlock(par1World, par2, par3, par4), par1World, par2, par3, par4, par5);
|
||||
}
|
||||
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
handler[i].onBlockAdded(MiscUtils.getBlock(par1World, par2, par3, par4), par1World, par2, par3, par4);
|
||||
}
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
return handler[i].onBlockActivated(MiscUtils.getBlock(par1World, par2, par3, par4), par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
|
||||
}
|
||||
return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
for(int i = 0; i < 1024; ++i)
|
||||
{
|
||||
if(handler[i] != null)
|
||||
handler[i].setBlockBoundsBasedOnState(MiscUtils.getBlock(par1IBlockAccess, par2, par3, par4), par1IBlockAccess, par2, par3, par4);
|
||||
}
|
||||
super.setBlockBoundsBasedOnState(par1IBlockAccess, par2, par3, par4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package DummyCore.Client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiButton_ChangeGUI extends GuiButton{
|
||||
|
||||
public GuiButton_ChangeGUI(int p_i1021_1_, int p_i1021_2_, int p_i1021_3_,int p_i1021_4_, int p_i1021_5_, String p_i1021_6_) {
|
||||
super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, p_i1021_6_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_146113_a(SoundHandler p_146113_1_)
|
||||
{
|
||||
p_146113_1_.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiMenuList(Minecraft.getMinecraft().currentScreen));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package DummyCore.Client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiCommon extends GuiContainer{
|
||||
|
||||
public List<GuiElement> elementList = new ArrayList();
|
||||
public TileEntity genericTile;
|
||||
public ResourceLocation guiGenLocation = new ResourceLocation("textures/gui/container/dispenser.png");
|
||||
public ResourceLocation slotLocation = new ResourceLocation("textures/gui/container/dispenser.png");;
|
||||
|
||||
public GuiCommon(Container c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
public GuiCommon(Container c, TileEntity tile) {
|
||||
this(c);
|
||||
genericTile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f1,int i1, int i2) {
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.mc.renderEngine.bindTexture(guiGenLocation);
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
this.drawTexturedModalRect(k+60, l+16, 6, 6, 28, 54);
|
||||
this.drawTexturedModalRect(k+88, l+16, 6, 6, 28, 54);
|
||||
for(int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i)
|
||||
{
|
||||
Slot slt = (Slot) this.inventorySlots.inventorySlots.get(i);
|
||||
renderSlot(slt);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
}
|
||||
for(int i = 0; i < this.elementList.size(); ++i)
|
||||
{
|
||||
GuiElement element = elementList.get(i);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(element.getElementTexture());
|
||||
element.draw(k+element.getX(),l+element.getY());
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderSlot(Slot slt)
|
||||
{
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.mc.renderEngine.bindTexture(slotLocation);
|
||||
this.drawTexturedModalRect(k+slt.xDisplayPosition-1, l+slt.yDisplayPosition-1, 7, 83, 18, 18);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package DummyCore.Client;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class GuiElement {
|
||||
int zLevel = 0;
|
||||
|
||||
public abstract ResourceLocation getElementTexture();
|
||||
|
||||
public abstract void draw(int posX, int posY);
|
||||
|
||||
public abstract int getX();
|
||||
|
||||
public abstract int getY();
|
||||
|
||||
public void drawTexturedModalRect(int p_73729_1_, int p_73729_2_, int p_73729_3_, int p_73729_4_, int p_73729_5_, int p_73729_6_)
|
||||
{
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public void drawTexturedModelRectFromIcon(int p_94065_1_, int p_94065_2_, IIcon p_94065_3_, int p_94065_4_, int p_94065_5_)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double)(p_94065_1_ + 0), (double)(p_94065_2_ + p_94065_5_), (double)this.zLevel, (double)p_94065_3_.getMinU(), (double)p_94065_3_.getMaxV());
|
||||
tessellator.addVertexWithUV((double)(p_94065_1_ + p_94065_4_), (double)(p_94065_2_ + p_94065_5_), (double)this.zLevel, (double)p_94065_3_.getMaxU(), (double)p_94065_3_.getMaxV());
|
||||
tessellator.addVertexWithUV((double)(p_94065_1_ + p_94065_4_), (double)(p_94065_2_ + 0), (double)this.zLevel, (double)p_94065_3_.getMaxU(), (double)p_94065_3_.getMinV());
|
||||
tessellator.addVertexWithUV((double)(p_94065_1_ + 0), (double)(p_94065_2_ + 0), (double)this.zLevel, (double)p_94065_3_.getMinU(), (double)p_94065_3_.getMinV());
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void func_146110_a(int p_146110_0_, int p_146110_1_, float p_146110_2_, float p_146110_3_, int p_146110_4_, int p_146110_5_, float p_146110_6_, float p_146110_7_)
|
||||
{
|
||||
float f4 = 1.0F / p_146110_6_;
|
||||
float f5 = 1.0F / p_146110_7_;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double)p_146110_0_, (double)(p_146110_1_ + p_146110_5_), 0.0D, (double)(p_146110_2_ * f4), (double)((p_146110_3_ + (float)p_146110_5_) * f5));
|
||||
tessellator.addVertexWithUV((double)(p_146110_0_ + p_146110_4_), (double)(p_146110_1_ + p_146110_5_), 0.0D, (double)((p_146110_2_ + (float)p_146110_4_) * f4), (double)((p_146110_3_ + (float)p_146110_5_) * f5));
|
||||
tessellator.addVertexWithUV((double)(p_146110_0_ + p_146110_4_), (double)p_146110_1_, 0.0D, (double)((p_146110_2_ + (float)p_146110_4_) * f4), (double)(p_146110_3_ * f5));
|
||||
tessellator.addVertexWithUV((double)p_146110_0_, (double)p_146110_1_, 0.0D, (double)(p_146110_2_ * f4), (double)(p_146110_3_ * f5));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void func_152125_a(int p_152125_0_, int p_152125_1_, float p_152125_2_, float p_152125_3_, int p_152125_4_, int p_152125_5_, int p_152125_6_, int p_152125_7_, float p_152125_8_, float p_152125_9_)
|
||||
{
|
||||
float f4 = 1.0F / p_152125_8_;
|
||||
float f5 = 1.0F / p_152125_9_;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double)p_152125_0_, (double)(p_152125_1_ + p_152125_7_), 0.0D, (double)(p_152125_2_ * f4), (double)((p_152125_3_ + (float)p_152125_5_) * f5));
|
||||
tessellator.addVertexWithUV((double)(p_152125_0_ + p_152125_6_), (double)(p_152125_1_ + p_152125_7_), 0.0D, (double)((p_152125_2_ + (float)p_152125_4_) * f4), (double)((p_152125_3_ + (float)p_152125_5_) * f5));
|
||||
tessellator.addVertexWithUV((double)(p_152125_0_ + p_152125_6_), (double)p_152125_1_, 0.0D, (double)((p_152125_2_ + (float)p_152125_4_) * f4), (double)(p_152125_3_ * f5));
|
||||
tessellator.addVertexWithUV((double)p_152125_0_, (double)p_152125_1_, 0.0D, (double)(p_152125_2_ * f4), (double)(p_152125_3_ * f5));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package DummyCore.Client;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiLabel;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import DummyCore.Utils.EnumGuiPosition;
|
||||
import DummyCore.Utils.IMainMenu;
|
||||
|
||||
public class GuiMainMenuOld extends GuiMainMenu implements IMainMenu{
|
||||
|
||||
private static final ResourceLocation minecraftTitleTextures = new ResourceLocation("textures/gui/title/minecraft.png");
|
||||
private String splashText;
|
||||
protected static final ResourceLocation buttonTextures = new ResourceLocation("textures/gui/widgets.png");
|
||||
private static final Random rand = new Random(); private static final ResourceLocation splashTexts = new ResourceLocation("texts/splashes.txt");
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
BufferedReader bufferedreader = null;
|
||||
|
||||
try
|
||||
{
|
||||
ArrayList arraylist = new ArrayList();
|
||||
bufferedreader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(splashTexts).getInputStream(), Charsets.UTF_8));
|
||||
String s;
|
||||
|
||||
while ((s = bufferedreader.readLine()) != null)
|
||||
{
|
||||
s = s.trim();
|
||||
|
||||
if (!s.isEmpty())
|
||||
{
|
||||
arraylist.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (!arraylist.isEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
this.splashText = (String)arraylist.get(rand.nextInt(arraylist.size()));
|
||||
}
|
||||
while (this.splashText.hashCode() == 125780783);
|
||||
}
|
||||
}
|
||||
catch (IOException ioexception1)
|
||||
{
|
||||
;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (bufferedreader != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferedreader.close();
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
short short1 = 274;
|
||||
int k = this.width / 2 - short1 / 2;
|
||||
byte b0 = 30;
|
||||
this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 16777215);
|
||||
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
|
||||
this.drawBackground(10);
|
||||
this.mc.getTextureManager().bindTexture(minecraftTitleTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
{
|
||||
this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 155, 44);
|
||||
this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44);
|
||||
}
|
||||
|
||||
tessellator.setColorOpaque_I(-1);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)(this.width / 2 + 90), 70.0F, 0.0F);
|
||||
GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F);
|
||||
float f1 = 1.8F - MathHelper.abs(MathHelper.sin((float)(Minecraft.getSystemTime() % 1000L) / 1000.0F * (float)Math.PI * 2.0F) * 0.1F);
|
||||
f1 = f1 * 100.0F / (float)(this.fontRendererObj.getStringWidth(this.splashText) + 32);
|
||||
GL11.glScalef(f1, f1, f1);
|
||||
this.drawCenteredString(this.fontRendererObj, this.splashText, 0, -8, -256);
|
||||
GL11.glPopMatrix();
|
||||
String s = "Minecraft 1.7.10";
|
||||
|
||||
if (this.mc.isDemo())
|
||||
{
|
||||
s = s + " Demo";
|
||||
}
|
||||
|
||||
List<String> brandings = Lists.reverse(FMLCommonHandler.instance().getBrandings(true));
|
||||
for (int i = 0; i < brandings.size(); i++)
|
||||
{
|
||||
String brd = brandings.get(i);
|
||||
if (!Strings.isNullOrEmpty(brd))
|
||||
{
|
||||
this.drawString(this.fontRendererObj, brd, 2, this.height - ( 10 + i * (this.fontRendererObj.FONT_HEIGHT + 1)), 16777215);
|
||||
}
|
||||
}
|
||||
ForgeHooksClient.renderMainMenu(this, fontRendererObj, width, height);
|
||||
String s1 = "Copyright Mojang AB. Do not distribute!";
|
||||
this.drawString(this.fontRendererObj, s1, this.width - this.fontRendererObj.getStringWidth(s1) - 2, this.height - 10, -1);
|
||||
|
||||
int k1;
|
||||
|
||||
for (k1 = 0; k1 < this.buttonList.size(); ++k1)
|
||||
{
|
||||
drawButton(((GuiButton)this.buttonList.get(k1)),this.mc, p_73863_1_, p_73863_2_);
|
||||
}
|
||||
|
||||
for (k1 = 0; k1 < this.labelList.size(); ++k1)
|
||||
{
|
||||
((GuiLabel)this.labelList.get(k1)).func_146159_a(this.mc, p_73863_1_, p_73863_2_);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawButton(GuiButton button,Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_)
|
||||
{
|
||||
if (button.enabled)
|
||||
{
|
||||
FontRenderer fontrenderer = p_146112_1_.fontRenderer;
|
||||
p_146112_1_.getTextureManager().bindTexture(buttonTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
boolean field_146123_n = p_146112_2_ >= button.xPosition && p_146112_3_ >= button.yPosition && p_146112_2_ < button.xPosition + button.width && p_146112_3_ < button.yPosition + button.height;
|
||||
int k = button.getHoverState(field_146123_n);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
this.drawTexturedModalRect(button.xPosition, button.yPosition, 0, 46 + k * 20, button.width / 2, button.height);
|
||||
this.drawTexturedModalRect(button.xPosition + button.width / 2, button.yPosition, 200 - button.width / 2, 46 + k * 20, button.width / 2, button.height);
|
||||
int l = 14737632;
|
||||
|
||||
if (button.packedFGColour != 0)
|
||||
{
|
||||
l = button.packedFGColour;
|
||||
}
|
||||
else if (!button.enabled)
|
||||
{
|
||||
l = 10526880;
|
||||
}
|
||||
else if (button.getHoverState(true) == 0)
|
||||
{
|
||||
l = 16777120;
|
||||
}
|
||||
|
||||
this.drawCenteredString(fontrenderer, button.displayString, button.xPosition + button.width / 2, button.yPosition + (button.height - 8) / 2, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package DummyCore.Client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import DummyCore.Utils.EnumGuiPosition;
|
||||
import DummyCore.Utils.IMainMenu;
|
||||
|
||||
public class GuiMainMenuVanilla extends GuiMainMenu implements IMainMenu{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package DummyCore.Client;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import DummyCore.Utils.DummyConfig;
|
||||
import DummyCore.Utils.DummyData;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.GuiSlotModList;
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModContainer.Disableable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.resources.IResourcePack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiMenuList extends GuiScreen{
|
||||
|
||||
private GuiScreen mainMenu;
|
||||
private GuiSlotMenuList modList;
|
||||
private int selected = -1;
|
||||
private Class selectedMod;
|
||||
private int listWidth;
|
||||
private ResourceLocation cachedLogo;
|
||||
private Dimension cachedLogoDimensions;
|
||||
|
||||
public GuiMenuList(GuiScreen mainMenu)
|
||||
{
|
||||
this.mainMenu=mainMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
for (DummyData data : MainMenuRegistry.menuInfoLst) {
|
||||
listWidth=Math.max(listWidth,getFontRenderer().getStringWidth(data.fieldName) + 10);
|
||||
listWidth=Math.max(listWidth,getFontRenderer().getStringWidth(data.fieldValue) + 10);
|
||||
}
|
||||
listWidth=Math.min(listWidth, 150);
|
||||
this.buttonList.add(new GuiButton(6, this.width / 2 - 75, this.height - 38, I18n.format("gui.done")));
|
||||
this.modList=new GuiSlotMenuList(this, listWidth);
|
||||
this.modList.registerScrollButtons(this.buttonList, 7, 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button.enabled)
|
||||
{
|
||||
switch (button.id)
|
||||
{
|
||||
case 6:
|
||||
{
|
||||
this.mc.displayGuiScreen(this.mainMenu);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
|
||||
public int drawLine(String line, int offset, int shifty)
|
||||
{
|
||||
this.fontRendererObj.drawString(line, offset, shifty, 0xd7edea);
|
||||
return shifty + 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int p_571_1_, int p_571_2_, float p_571_3_)
|
||||
{
|
||||
this.modList.drawScreen(p_571_1_, p_571_2_, p_571_3_);
|
||||
this.drawCenteredString(this.fontRendererObj, "Menu List", this.width / 2, 16, 0xFFFFFF);
|
||||
int offset = this.listWidth + 20;
|
||||
if (selectedMod != null)
|
||||
{
|
||||
DummyData data = MainMenuRegistry.menuInfoLst.get(selected);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
{
|
||||
offset = ( this.listWidth + this.width ) / 2;
|
||||
this.drawCenteredString(this.fontRendererObj, data.fieldName, offset, 35, 0xFFFFFF);
|
||||
this.drawCenteredString(this.fontRendererObj, data.fieldValue, offset, 45, 0xFFFFFF);
|
||||
}
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
super.drawScreen(p_571_1_, p_571_2_, p_571_3_);
|
||||
}
|
||||
|
||||
Minecraft getMinecraftInstance() {
|
||||
/** Reference to the Minecraft object. */
|
||||
return mc;
|
||||
}
|
||||
|
||||
FontRenderer getFontRenderer() {
|
||||
/** The FontRenderer used by GuiScreen */
|
||||
return fontRendererObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param var1
|
||||
*/
|
||||
public void selectIndex(int var1)
|
||||
{
|
||||
this.selected=var1;
|
||||
if (var1>=0 && var1<=MainMenuRegistry.menuList.size()) {
|
||||
this.selectedMod=MainMenuRegistry.menuList.get(selected);
|
||||
} else {
|
||||
this.selectedMod=null;
|
||||
}
|
||||
DummyConfig.setMainMenu(selected);
|
||||
cachedLogo = null;
|
||||
}
|
||||
|
||||
public boolean indexSelected(int var1)
|
||||
{
|
||||
return var1==selected;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package DummyCore.Client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import DummyCore.Utils.DummyData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import cpw.mods.fml.client.GuiModList;
|
||||
import cpw.mods.fml.client.GuiScrollingList;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.LoaderState.ModState;
|
||||
|
||||
public class GuiSlotMenuList extends GuiScrollingList {
|
||||
|
||||
private GuiMenuList parent;
|
||||
|
||||
public GuiSlotMenuList(GuiMenuList parent, int listWidth)
|
||||
{
|
||||
super(Minecraft.getMinecraft(), listWidth, parent.height, 32, parent.height - 66 + 4, 10, 35);
|
||||
this.parent=parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize()
|
||||
{
|
||||
return MainMenuRegistry.menuList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void elementClicked(int var1, boolean var2)
|
||||
{
|
||||
this.parent.selectIndex(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSelected(int var1)
|
||||
{
|
||||
return this.parent.indexSelected(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground()
|
||||
{
|
||||
this.parent.drawDefaultBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentHeight()
|
||||
{
|
||||
return (this.getSize()) * 35 + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
|
||||
{
|
||||
DummyData data = MainMenuRegistry.menuInfoLst.get(listIndex);
|
||||
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(data.fieldName, listWidth - 10), this.left + 3 , var3 + 2, 0xFFFFFF);
|
||||
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(data.fieldValue, listWidth - 10), this.left + 3 , var3 + 12, 0xCCCCCC);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package DummyCore.Client;
|
||||
|
||||
import DummyCore.Utils.IMainMenu;
|
||||
|
||||
public class MainMenuGUIRenderer {
|
||||
|
||||
public static IMainMenu currentScreenBeingRendered;
|
||||
|
||||
public static void setCurrentGUI(IMainMenu menu)
|
||||
{
|
||||
currentScreenBeingRendered = menu;
|
||||
}
|
||||
|
||||
public static void initGui()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package DummyCore.Client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import DummyCore.Utils.DummyConfig;
|
||||
import DummyCore.Utils.DummyData;
|
||||
import DummyCore.Utils.IMainMenu;
|
||||
import DummyCore.Utils.Notifier;
|
||||
|
||||
public class MainMenuRegistry {
|
||||
|
||||
public static List<Class<? extends GuiScreen>> menuList = new ArrayList();
|
||||
|
||||
public static List<DummyData> menuInfoLst = new ArrayList();
|
||||
|
||||
public static boolean isGuiDisplayed;
|
||||
|
||||
public static GuiScreen currentScreen;
|
||||
|
||||
public static void registerNewGui(Class menu)
|
||||
{
|
||||
if(IMainMenu.class.isAssignableFrom(menu))
|
||||
{
|
||||
menuList.add(menu);
|
||||
menuInfoLst.add(new DummyData(menu.getName(),"No description provided by author ;("));
|
||||
}else
|
||||
{
|
||||
Notifier.notifyCustomMod("DummyCore", "Attempting to register "+menu+" as a main menu, but the registered object does not implements IMainMenu!");
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerNewGui(Class menu, String name, String description)
|
||||
{
|
||||
if(IMainMenu.class.isAssignableFrom(menu))
|
||||
{
|
||||
menuList.add(menu);
|
||||
menuInfoLst.add(new DummyData(name,description));
|
||||
}else
|
||||
{
|
||||
Notifier.notifyCustomMod("DummyCore", "Attempting to register "+menu+" as a main menu, but the registered object does not implements IMainMenu!");
|
||||
}
|
||||
}
|
||||
|
||||
public static void newMainMenu(int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(menuList.size() < index)
|
||||
{
|
||||
index = menuList.size()-1;
|
||||
}
|
||||
DummyConfig.setMainMenu(index);
|
||||
currentScreen = menuList.get(DummyConfig.getMainMenu()).newInstance();
|
||||
Minecraft.getMinecraft().displayGuiScreen(currentScreen);
|
||||
}catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static GuiScreen getGuiDisplayed()
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if(mc.currentScreen != null && mc.currentScreen.getClass() != GuiMainMenu.class && mc.currentScreen instanceof IMainMenu)
|
||||
return mc.currentScreen;
|
||||
if(currentScreen != null)
|
||||
return currentScreen;
|
||||
try
|
||||
{
|
||||
return menuList.get(DummyConfig.getMainMenu()).newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import DummyCore.Utils.IDummyConfig;
|
||||
import DummyCore.Utils.Notifier;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
package DummyCore.CreativeTabs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import DummyCore.Blocks.BlocksRegistry;
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import DummyCore.Utils.DummyConfig;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* @version From DummyCore 1.0
|
||||
@@ -18,10 +26,12 @@ import net.minecraft.item.ItemStack;
|
||||
* Do not change anything here! Used to work with Blocks.
|
||||
*/
|
||||
public final class CreativePageBlocks extends CreativeTabs{
|
||||
private int delayTime = 0;
|
||||
private ItemStack displayStack = new ItemStack(Block.workbench,1,0);
|
||||
public int delayTime = 0;
|
||||
public ItemStack displayStack = new ItemStack(Blocks.crafting_table,1,0);
|
||||
private static Random rand = new Random(543643456);
|
||||
private final String tabLabel;
|
||||
public List<ItemStack> blockList = new ArrayList();
|
||||
public int tries = 0;
|
||||
|
||||
public CreativePageBlocks(String m) {
|
||||
super(m + " Blocks");
|
||||
@@ -30,57 +40,52 @@ public final class CreativePageBlocks extends CreativeTabs{
|
||||
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
this.chooseRandomStack();
|
||||
CoreInitialiser.proxy.choseDisplayStack(this);
|
||||
return this.displayStack;
|
||||
}
|
||||
|
||||
private void chooseRandomStack()
|
||||
{
|
||||
++this.delayTime;
|
||||
if(this.delayTime >= 40)
|
||||
{
|
||||
this.delayTime = 0;
|
||||
Block[] blockList = initialiseBlocksList();
|
||||
if(blockList != null && blockList.length >= 1)
|
||||
{
|
||||
int random = rand.nextInt(blockList.length);
|
||||
if(blockList[random] != null)
|
||||
if(blockList[random].getIcon(0,0) != null)
|
||||
this.displayStack = new ItemStack(blockList[random],1,0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Block[] initialiseBlocksList()
|
||||
public List<ItemStack> initialiseBlocksList()
|
||||
{
|
||||
int i = 0;
|
||||
for(int t = 0; t < Block.blocksList.length; ++t)
|
||||
++tries;
|
||||
if(this.blockList.isEmpty() && tries <= 1)
|
||||
{
|
||||
Block b = Block.blocksList[t];
|
||||
if(b != null)
|
||||
{
|
||||
if(b.getCreativeTabToDisplayOn() != null && b.getCreativeTabToDisplayOn() instanceof CreativePageBlocks && b.getIcon(0,0) != null && (BlocksRegistry.blocksList.get(b) == this.getTabLabel()))
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
Block[] blockList = new Block[i];
|
||||
int r = 0;
|
||||
for(int t = 0; t < Block.blocksList.length; ++t)
|
||||
int i = 0;
|
||||
for(int t = 0; t < Block.blockRegistry.getKeys().size(); ++t)
|
||||
{
|
||||
Block b = Block.getBlockFromName((String) Block.blockRegistry.getKeys().toArray()[t]);
|
||||
if(b != null && b.getCreativeTabToDisplayOn() == this)
|
||||
{
|
||||
Item itm = Item.getItemFromBlock(b);
|
||||
if(itm != null)
|
||||
{
|
||||
List<ItemStack> lst = new ArrayList();
|
||||
itm.getSubItems(itm,this,lst);
|
||||
if(!lst.isEmpty())
|
||||
{
|
||||
for(ItemStack stk : lst)
|
||||
{
|
||||
if(stk != null)
|
||||
{
|
||||
this.blockList.add(stk);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return blockList;
|
||||
}else
|
||||
{
|
||||
Block b = Block.blocksList[t];
|
||||
if(b != null)
|
||||
{
|
||||
if(b.getCreativeTabToDisplayOn() != null && b.getCreativeTabToDisplayOn() instanceof CreativePageBlocks && b.getIcon(0,0) != null && (BlocksRegistry.blocksList.get(b) == this.getTabLabel()))
|
||||
{
|
||||
blockList[r] = b;
|
||||
++r;
|
||||
}
|
||||
}
|
||||
return this.blockList;
|
||||
}
|
||||
|
||||
return blockList;
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
@@ -88,4 +93,9 @@ public final class CreativePageBlocks extends CreativeTabs{
|
||||
{
|
||||
return this.tabLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getTabIconItem() {
|
||||
return displayStack.getItem();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,26 @@
|
||||
package DummyCore.CreativeTabs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import DummyCore.Blocks.BlocksRegistry;
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import DummyCore.Items.ItemRegistry;
|
||||
import DummyCore.Utils.DummyConfig;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* @version From DummyCore 1.0
|
||||
@@ -20,69 +28,62 @@ import net.minecraft.item.ItemStack;
|
||||
* Do not change anything here! Used to work with Items.
|
||||
*/
|
||||
public final class CreativePageItems extends CreativeTabs{
|
||||
private int delayTime = 0;
|
||||
private ItemStack displayStack = new ItemStack(Item.axeIron,1,0);
|
||||
public int delayTime = 0;
|
||||
public ItemStack displayStack = new ItemStack((Item) Items.iron_axe,1,0);
|
||||
private static Random rand = new Random(965448655);
|
||||
private final String tabLabel;
|
||||
public List<ItemStack> itemList = new ArrayList();
|
||||
public int tries = 0;
|
||||
|
||||
|
||||
public CreativePageItems(String m) {
|
||||
super(m + " Items");
|
||||
tabLabel = m + " Items";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
this.chooseRandomStack();
|
||||
CoreInitialiser.proxy.choseDisplayStack(this);
|
||||
return this.displayStack;
|
||||
}
|
||||
|
||||
private void chooseRandomStack()
|
||||
{
|
||||
++this.delayTime;
|
||||
if(this.delayTime >= 40)
|
||||
{
|
||||
this.delayTime = 0;
|
||||
Item[] itemList = initialiseItemsList();
|
||||
if(itemList != null && itemList.length >= 1)
|
||||
{
|
||||
int random = rand.nextInt(itemList.length);
|
||||
if(itemList[random] != null)
|
||||
if(itemList[random].getIconFromDamage(0) != null)
|
||||
this.displayStack = new ItemStack(itemList[random],1,0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Item[] initialiseItemsList()
|
||||
public List<ItemStack> initialiseItemsList()
|
||||
{
|
||||
int i = 0;
|
||||
for(int t = 0; t < Item.itemsList.length; ++t)
|
||||
++tries;
|
||||
if(this.itemList.isEmpty() && tries <= 1)
|
||||
{
|
||||
Item b = Item.itemsList[t];
|
||||
if(b != null)
|
||||
{
|
||||
if(b.getCreativeTab() != null && b.getCreativeTab() instanceof CreativePageItems && b.getIconFromDamage(0) != null && (ItemRegistry.itemsList.get(b) == this.getTabLabel()))
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
Item[] itemsList = new Item[i];
|
||||
int r = 0;
|
||||
for(int t = 0; t < Item.itemsList.length; ++t)
|
||||
int i = 0;
|
||||
for(int t = 0; t < Item.itemRegistry.getKeys().size(); ++t)
|
||||
{
|
||||
Item itm = (Item) Item.itemRegistry.getObject(Item.itemRegistry.getKeys().toArray()[t]);
|
||||
if(itm != null && itm.getCreativeTab() == this)
|
||||
{
|
||||
List<ItemStack> lst = new ArrayList();
|
||||
itm.getSubItems(itm,this,lst);
|
||||
if(!lst.isEmpty())
|
||||
{
|
||||
for(ItemStack stk : lst)
|
||||
{
|
||||
if(stk != null)
|
||||
{
|
||||
this.itemList.add(stk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.itemList;
|
||||
}else
|
||||
{
|
||||
Item b = Item.itemsList[t];
|
||||
if(b != null)
|
||||
{
|
||||
if(b.getCreativeTab() != null && b.getCreativeTab() instanceof CreativePageItems && b.getIconFromDamage(0) != null && (ItemRegistry.itemsList.get(b) == this.getTabLabel()))
|
||||
{
|
||||
itemsList[r] = b;
|
||||
++r;
|
||||
}
|
||||
}
|
||||
return this.itemList;
|
||||
}
|
||||
|
||||
return itemsList;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -91,4 +92,10 @@ public final class CreativePageItems extends CreativeTabs{
|
||||
{
|
||||
return this.tabLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getTabIconItem() {
|
||||
// TODO Auto-generated method stub
|
||||
return (Item) Item.itemRegistry.getObject("minecraft:iron_axe");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package DummyCore.Events;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class DummyEvent_OnClientGUIButtonPress extends Event{
|
||||
|
||||
public int buttonID;
|
||||
public String client_ParentClassPath;
|
||||
public String client_ButtonClassPath;
|
||||
public EntityPlayer presser;
|
||||
public int x, y, z;
|
||||
|
||||
public DummyEvent_OnClientGUIButtonPress(int bID, String s, String s_1, EntityPlayer player,int dx, int dy, int dz)
|
||||
{
|
||||
buttonID = bID;
|
||||
client_ParentClassPath = s;
|
||||
client_ButtonClassPath = s_1;
|
||||
presser = player;
|
||||
x = dx;
|
||||
y = dy;
|
||||
z = dz;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package DummyCore.Events;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class DummyEvent_OnKeyboardKeyPressed_Server extends Event{
|
||||
|
||||
public int keyID;
|
||||
public String keyName;
|
||||
public EntityPlayer presser;
|
||||
public boolean pressed;
|
||||
|
||||
public DummyEvent_OnKeyboardKeyPressed_Server(int keyId, String keyname, EntityPlayer player, boolean bool)
|
||||
{
|
||||
keyID = keyId;
|
||||
keyName = keyname;
|
||||
presser = player;
|
||||
pressed = bool;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package DummyCore.Events;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.7
|
||||
* @Description Now all packets work on Events.
|
||||
*/
|
||||
public class DummyEvent_OnPacketRecieved extends Event{
|
||||
|
||||
public final Side effectiveSide;
|
||||
|
||||
public final String recievedData;
|
||||
|
||||
public final EntityPlayer recievedEntity;
|
||||
|
||||
public DummyEvent_OnPacketRecieved(Side s, String str, EntityPlayer pl)
|
||||
{
|
||||
effectiveSide = s;
|
||||
recievedData = str;
|
||||
recievedEntity = pl;
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,13 @@ import java.util.Hashtable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import DummyCore.Core.Core;
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import DummyCore.Utils.IDummyMultiItem;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -31,52 +33,30 @@ public class ItemRegistry {
|
||||
* @param name - in-game name of the item. Will be written to the corresponding .lang file
|
||||
* @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)
|
||||
{
|
||||
String itemName = name;
|
||||
Configuration conf = Core.getLangFileForMod(modClass);
|
||||
conf.load();
|
||||
itemName = conf.get("Items Names", i.getUnlocalizedName(), name).getString();
|
||||
conf.save();
|
||||
LanguageRegistry.addName(i, itemName);
|
||||
i.setCreativeTab(Core.getItemTabForMod(modClass));
|
||||
itemsList.put(i, Core.getItemTabForMod(modClass).getTabLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to add your item to the MultiItem storage system. This will add your item to the DummyCore creative tab. This does not requires creating new Item variable, and allows you to register lots of items, while not using more ID's
|
||||
* @param unlocalisedName - the name of your item in code. Always remember to check this! This is the way to get your items if you need to!
|
||||
* @param inGameName - in-game name of the item. Will be written to the corresponding .lang file
|
||||
* @param texturePath - path to the texture file, that will be used for this item. Should be modname:texturename
|
||||
* @param multiItemHandler - should be an initialized! object, that implements IDummyMultiItem. Usually it is just an empty .class file. Used to handle different actions, happening with your multiitem. Always remember to check for your item's name! Can be null, then none of actions will be handled.
|
||||
* @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
|
||||
* @version From DummyCore 1.1
|
||||
*/
|
||||
public static void registerMultiItem(String unlocalisedName, String inGameName, String texturePath, IDummyMultiItem multiItemHandler, Class modClass)
|
||||
{
|
||||
String itemName = inGameName;
|
||||
Configuration conf = Core.getLangFileForMod(modClass);
|
||||
conf.load();
|
||||
itemName = conf.get("Items Names", unlocalisedName, inGameName).getString();
|
||||
conf.save();
|
||||
if(multiItemHandler != null)
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
MultiItem.registerMultiItem(unlocalisedName, inGameName, texturePath, multiItemHandler);
|
||||
}else
|
||||
{
|
||||
MultiItem.registerMultiItem(unlocalisedName, inGameName, texturePath);
|
||||
i.setCreativeTab(Core.getItemTabForMod(modClass));
|
||||
itemsList.put(i, Core.getItemTabForMod(modClass).getTabLabel());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to handle the single id for all of the multiitems. Do not change this!
|
||||
* @return the id of all the multiitems
|
||||
* @version From DummyCore 1.1
|
||||
* Use this to register new simple items.
|
||||
* @version From DummyCore 1.0
|
||||
* @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
|
||||
*/
|
||||
public static int getMultiItemID()
|
||||
public static void registerItem(Item i, Class modClass)
|
||||
{
|
||||
return CoreInitialiser.mItem.itemuid;
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
i.setCreativeTab(Core.getItemTabForMod(modClass));
|
||||
itemsList.put(i, Core.getItemTabForMod(modClass).getTabLabel());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import DummyCore.Core.Core;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
/**
|
||||
* @version From DummyCore 1.1
|
||||
* @author Modbder
|
||||
* @Description make your blocks extend this to make the emmit colored lightning. Warning! Colored lightning is still in beta-testing, and for sure contains lots of bugs!
|
||||
*/
|
||||
public class BlockEmmitsColoredLight extends BlockContainer{
|
||||
|
||||
public BlockEmmitsColoredLight(int par1, Material par2Material) {
|
||||
super(par1, par2Material);
|
||||
if(!Core.lightBlocks.contains(this))
|
||||
Core.lightBlocks.add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the color of the light. Look in EnumLightColor to see more of the colors.
|
||||
* @version From DummyCore 1.1
|
||||
* @param world - the world object.
|
||||
* @param x - x coordinate of the block
|
||||
* @param y - y coordinate of the block
|
||||
* @param z- z coordinate of the block
|
||||
* @return the color of the light the block will emit.
|
||||
*/
|
||||
public EnumLightColor getColor(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return EnumLightColor.WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the brightness of the light. By default equivalents to the light amount, the block gives
|
||||
* @version From DummyCore 1.1
|
||||
* @param world - the world object.
|
||||
* @param x - x coordinate of the block
|
||||
* @param y - y coordinate of the block
|
||||
* @param z- z coordinate of the block
|
||||
* @return number from 0 to 15, corresponding to the light value
|
||||
*/
|
||||
public float getLightBrightness(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return this.lightValue[world.getBlockId(x, y, z)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World w, int x, int y, int z, int par5, float par6, float par7, float par8, int par9)
|
||||
{
|
||||
ColoredLightHandler light = new ColoredLightHandler(w, getColor(w,x,y,z).getLightID(), getLightBrightness(w,x,y,z));
|
||||
light.setPosition(x+0.5F, y+0.5F, z+0.5F);
|
||||
if(!w.isRemote)
|
||||
w.spawnEntityInWorld(light);
|
||||
return super.onBlockPlaced(w, x, y, z, par5, par6, par7, par8, par9);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockPosition {
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public Block blk;
|
||||
public int metadata;
|
||||
public TileEntity blockTile;
|
||||
public World wrld;
|
||||
|
||||
public BlockPosition(World w, int posX, int posY, int posZ)
|
||||
{
|
||||
wrld = w;
|
||||
x = posX;
|
||||
y = posY;
|
||||
z = posZ;
|
||||
blk = w.getBlock(posX, posY, posZ);
|
||||
metadata = w.getBlockMetadata(posX, posY, posZ);
|
||||
blockTile = w.getTileEntity(posX, posY, posZ);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
|
||||
public class CommandTransfer extends CommandBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
// TODO Auto-generated method stub
|
||||
return "DummyCore.Transfer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender p_71518_1_) {
|
||||
// TODO Auto-generated method stub
|
||||
return "/DummyCore.Transfer <player> <dimensionID>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
|
||||
// TODO Auto-generated method stub
|
||||
int var3 = parseIntWithMin(p_71515_1_, p_71515_2_[1], Integer.MIN_VALUE);
|
||||
EntityPlayerMP player = p_71515_2_.length == 0 ? getCommandSenderAsPlayer(p_71515_1_) : getPlayer(p_71515_1_, p_71515_2_[0]);
|
||||
player.travelToDimension(var3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,17 @@ public class Coord2D {
|
||||
this(0,0);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "||x:"+x+"||z:"+z;
|
||||
}
|
||||
|
||||
public static Coord2D fromString(String data)
|
||||
{
|
||||
DummyData[] dt = DataStorage.parseData(data);
|
||||
float cX = Float.parseFloat(dt[0].fieldValue);
|
||||
float cZ = Float.parseFloat(dt[1].fieldValue);
|
||||
return new Coord2D(cX,cZ);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,18 @@ public class Coord3D {
|
||||
this(0,0,0);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "||x:"+x+"||y:"+y+"||z:"+z;
|
||||
}
|
||||
|
||||
public static Coord3D fromString(String data)
|
||||
{
|
||||
DummyData[] dt = DataStorage.parseData(data);
|
||||
float cX = Float.parseFloat(dt[0].fieldValue);
|
||||
float cY = Float.parseFloat(dt[1].fieldValue);
|
||||
float cZ = Float.parseFloat(dt[2].fieldValue);
|
||||
return new Coord3D(cX,cY,cZ);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.2
|
||||
* @Description used to store almost any kind of variable in a single String instance.
|
||||
*/
|
||||
public class DataStorage {
|
||||
private static String dataString = "";
|
||||
|
||||
/**
|
||||
* Adds the given DummyData to the data string
|
||||
* @version From DummyCore 1.2
|
||||
* @param data - the data to be added to the string
|
||||
*/
|
||||
public static void addDataToString(DummyData data)
|
||||
{
|
||||
dataString = dataString.concat(data.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data string, with all data written to it. Also resets the string, so this should be used only once, after you have stored all your data.
|
||||
* @version From DummyCore 1.2
|
||||
* @return Correctly formated DataString
|
||||
*/
|
||||
public static String getDataString()
|
||||
{
|
||||
String ret = dataString;
|
||||
dataString = "";
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get your DummyData from the correctly formated string.
|
||||
* @version From DummyCore 1.2
|
||||
* @param s - the string to extract data from
|
||||
* @return - An array of all data from the given string
|
||||
*/
|
||||
public static DummyData[] parseData(String s)
|
||||
{
|
||||
String field = "";
|
||||
Object value = null;
|
||||
List<DummyData> data = new ArrayList();
|
||||
for(int i = 0; i < s.length(); ++i)
|
||||
{
|
||||
if(i+2 < s.length() && s.substring(i, i+2).contains("||"))
|
||||
{
|
||||
int size = 0;
|
||||
ForSize:for(int i1 = i; i1 < s.length();++i1)
|
||||
{
|
||||
if(s.charAt(i1) == ':')
|
||||
break ForSize;
|
||||
++size;
|
||||
}
|
||||
field = s.substring(i+2, i+size);
|
||||
}
|
||||
if(i+1 < s.length() && s.substring(i, i+1).contains(":"))
|
||||
{
|
||||
int size = 0;
|
||||
ForSize:for(int i1 = i; i1 < s.length();++i1)
|
||||
{
|
||||
if(s.charAt(i1) == '|')
|
||||
break ForSize;
|
||||
++size;
|
||||
}
|
||||
value = s.substring(i+1, i+size);
|
||||
}
|
||||
if(field != "" && value != null)
|
||||
{
|
||||
DummyData date = new DummyData(field,value);
|
||||
data.add(date);
|
||||
field = "";
|
||||
value = null;
|
||||
}
|
||||
}
|
||||
DummyData[] ret = new DummyData[data.size()];
|
||||
for(int i = 0; i < ret.length; ++i)
|
||||
{
|
||||
ret[i] = data.get(i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.2
|
||||
* @Description Used to check, if the float is inbetween 2 others.
|
||||
*/
|
||||
public class DummyBounds {
|
||||
private final float min;
|
||||
private final float max;
|
||||
|
||||
public DummyBounds(float m1, float m2)
|
||||
{
|
||||
min = m1;
|
||||
max = m2;
|
||||
}
|
||||
|
||||
public boolean isInRange(float f)
|
||||
{
|
||||
return f > min && f < max;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,35 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
public class DummyConfig implements IDummyConfig{
|
||||
|
||||
public int MultiItemUID;
|
||||
public int MultiBlockUID;
|
||||
private static int mainMenuID;
|
||||
public boolean removeMissingTexturesErrors;
|
||||
public static boolean enableNotifierLogging;
|
||||
public static boolean shouldChangeImage;
|
||||
public static Configuration cfg;
|
||||
public void load(Configuration config)
|
||||
{
|
||||
MultiItemUID = config.getItem("Multi Item Unique ID", 22899).getInt();
|
||||
MultiBlockUID = config.getBlock("Multi Block Unique ID", 2480).getInt();
|
||||
cfg = config;
|
||||
removeMissingTexturesErrors = config.getBoolean("removeMissingTexturesErrors", "GLOBAL", true, "");
|
||||
enableNotifierLogging = config.getBoolean("enableNotifierLogging", "GLOBAL", true, "");
|
||||
shouldChangeImage = config.getBoolean("shouldChangeImageInCreativeTabs", "GLOBAL", true, "");
|
||||
mainMenuID = config.getInt("mainMenuID", "GLOBAL", 0,0,Integer.MAX_VALUE, "");
|
||||
}
|
||||
|
||||
public static void setMainMenu(int i)
|
||||
{
|
||||
cfg.load();
|
||||
cfg.get("GLOBAL", "mainMenuID", 0, "").set(i);
|
||||
mainMenuID = i;
|
||||
cfg.save();
|
||||
}
|
||||
|
||||
public static int getMainMenu()
|
||||
{
|
||||
return mainMenuID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.2
|
||||
* @Description used to store almost any kind of variable using a special Data. When working, remember, that you can store any Object to the corresponding name.
|
||||
*/
|
||||
public class DummyData {
|
||||
public final String fieldName;
|
||||
public final String fieldValue;
|
||||
public DummyData(String field, String value)
|
||||
{
|
||||
fieldName = field;
|
||||
fieldValue = value;
|
||||
}
|
||||
|
||||
public DummyData(String field, Object value)
|
||||
{
|
||||
fieldName = field;
|
||||
fieldValue = value.toString();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String ret = "";
|
||||
ret = ret.concat("||").concat(fieldName).concat(":").concat(fieldValue.toString());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.naming.spi.DirectoryManager;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProviderSurface;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import org.apache.commons.io.DirectoryWalker;
|
||||
import org.apache.commons.io.filefilter.DirectoryFileFilter;
|
||||
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.discovery.DirectoryDiscoverer;
|
||||
import cpw.mods.fml.common.event.FMLLoadEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.4
|
||||
* @Description used to store any String for players/worlds in the world save folder and get it.
|
||||
*/
|
||||
public class DummyDataUtils {
|
||||
private static File mainWorldFile;
|
||||
private static Configuration globalConfig;
|
||||
private static Hashtable<String,File> playerFiles = new Hashtable<String,File>();
|
||||
private static Hashtable<String,Configuration> playerConfigs = new Hashtable<String,Configuration>();
|
||||
private static String getPath;
|
||||
private static boolean isWorking;
|
||||
private static File directory;
|
||||
|
||||
/**
|
||||
* A new version of world loads, better server compathabilities.
|
||||
*/
|
||||
@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)
|
||||
{
|
||||
File f = event.world.getSaveHandler().getWorldDirectory();
|
||||
if(f != null)
|
||||
{
|
||||
String fPath = f.getAbsolutePath();
|
||||
String dDataPath = fPath+"//DummyData//";
|
||||
directory = new File(dDataPath);
|
||||
directory.mkdirs();
|
||||
File globalDataDat = new File(directory+"//GlobalData.ddat");
|
||||
|
||||
File f1 = new File(directory+"//PlayerData//");
|
||||
f1.mkdirs();
|
||||
getPath = dDataPath;
|
||||
mainWorldFile = globalDataDat;
|
||||
globalConfig = new Configuration(globalDataDat);
|
||||
isWorking = true;
|
||||
}
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
Notifier.notifyCustomMod("DummyCore", "Error loading DummyData!");e.printStackTrace();return;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void load(FMLServerAboutToStartEvent event)
|
||||
{
|
||||
String name = event.getServer().getFile(event.getServer().getFolderName()).getAbsolutePath();
|
||||
int length = 0;
|
||||
boolean shouldAddSaves = true;
|
||||
for(int i = 0; i < name.length(); ++i)
|
||||
{
|
||||
if(name.substring(0, i).contains("\\.\\"))
|
||||
{
|
||||
shouldAddSaves = true;
|
||||
--length;
|
||||
--length;
|
||||
break;
|
||||
}
|
||||
++length;
|
||||
}
|
||||
String print = name.substring(0,length);
|
||||
if(shouldAddSaves)
|
||||
{
|
||||
print += "saves\\";
|
||||
print += event.getServer().getFolderName();
|
||||
}
|
||||
print += "\\DummyData\\";
|
||||
File f = new File(print);
|
||||
f.mkdirs();
|
||||
File file = new File(print+"GlobalData.ddat");
|
||||
try {
|
||||
if(!file.exists())
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
File f1 = new File(print+"/PlayerData/");
|
||||
f1.mkdirs();
|
||||
getPath = print;
|
||||
mainWorldFile = file;
|
||||
globalConfig = new Configuration(file);
|
||||
isWorking = true;
|
||||
}
|
||||
|
||||
public static void stop()
|
||||
{
|
||||
mainWorldFile = null;
|
||||
globalConfig = null;
|
||||
playerFiles.clear();
|
||||
playerConfigs.clear();
|
||||
getPath = "no path";
|
||||
isWorking = false;
|
||||
directory = null;
|
||||
MiscUtils.registeredClientData.clear();
|
||||
MiscUtils.registeredClientWorldData.clear();
|
||||
MiscUtils.registeredServerData.clear();
|
||||
MiscUtils.registeredServerWorldData.clear();
|
||||
}
|
||||
|
||||
private static File getDataFileForPlayer(String playerName)
|
||||
{
|
||||
if(!playerFiles.containsKey(playerName))
|
||||
{
|
||||
File ret = new File(getPath+"/PlayerData/"+playerName+".ddat");
|
||||
if(!ret.exists())
|
||||
try {
|
||||
ret.createNewFile();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
playerFiles.put(playerName, ret);
|
||||
return ret;
|
||||
}else
|
||||
{
|
||||
return playerFiles.get(playerName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Configuration getDataConfigForPlayer(String playerName)
|
||||
{
|
||||
if(!canWorkWithData())return null;
|
||||
if(!playerConfigs.containsKey(playerName))
|
||||
{
|
||||
playerConfigs.put(playerName, new Configuration(getDataFileForPlayer(playerName)));
|
||||
}
|
||||
return playerConfigs.get(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the given String to the GlobalData.ddat file with the key of dataName
|
||||
* @version From DummyCore 1.4
|
||||
* @param modid - the id of your mod
|
||||
* @param dataName - key of the data
|
||||
* @param dataString - data to store
|
||||
*/
|
||||
public static void writeCustomDataForMod(String modid, String dataName, String dataString)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
MiscUtils.registeredClientWorldData.put(modid+"|"+dataName, dataString);
|
||||
}else
|
||||
{
|
||||
if(!canWorkWithData())return;
|
||||
globalConfig.load();
|
||||
globalConfig.get(modid, dataName, dataString).set(dataString);
|
||||
MiscUtils.registeredServerWorldData.put(modid+"|"+dataName, dataString);
|
||||
globalConfig.save();
|
||||
syncGlobalDataToClient(modid, dataName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadCustomDataForMod(String modid, String dataName)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
return;
|
||||
}else
|
||||
{
|
||||
if(!canWorkWithData())return;
|
||||
globalConfig.load();
|
||||
MiscUtils.registeredServerWorldData.put(modid+"|"+dataName, globalConfig.get(modid, dataName, "no data").getString());
|
||||
globalConfig.save();
|
||||
syncGlobalDataToClient(modid, dataName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadGlobalDataForMod(String modid)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
return;
|
||||
}else
|
||||
{
|
||||
if(!canWorkWithData())return;
|
||||
globalConfig.load();
|
||||
MiscUtils.registeredServerWorldData.put(modid+"|"+modid, globalConfig.get(modid, modid, "no data").getString());
|
||||
globalConfig.save();
|
||||
syncGlobalDataToClient(modid, modid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the given String to the GlobalData.ddat file with the key of modid
|
||||
* @version From DummyCore 1.4
|
||||
* @param modid - the id of your mod
|
||||
* @param dataString - data to store
|
||||
*/
|
||||
public static void writeGlobalDataForMod(String modid, String dataString)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
MiscUtils.registeredClientWorldData.put(modid+"|"+modid, dataString);
|
||||
}else
|
||||
{
|
||||
if(!canWorkWithData())return;
|
||||
globalConfig.load();
|
||||
globalConfig.get(modid, modid, dataString).set(dataString);
|
||||
MiscUtils.registeredServerWorldData.put(modid+"|"+modid, dataString);
|
||||
globalConfig.save();
|
||||
syncGlobalDataToClient(modid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the String from the GlobalData.ddat file with the key of modid
|
||||
* @version From DummyCore 1.4
|
||||
* @param modid - the id of your mod
|
||||
* @return a string with the data, written to the ddat file. Returns "no data" if none was found
|
||||
*/
|
||||
public static String getGlobalDataForMod(String modid)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
return MiscUtils.registeredClientWorldData.get(modid+"|"+modid);
|
||||
}else
|
||||
{
|
||||
if(!MiscUtils.registeredServerWorldData.containsKey(modid+"|"+modid))
|
||||
loadGlobalDataForMod(modid);
|
||||
return MiscUtils.registeredServerWorldData.get(modid+"|"+modid);
|
||||
}
|
||||
//@Deprecated
|
||||
//if(!canWorkWithData())return null;
|
||||
//globalConfig.load();
|
||||
//String ret = globalConfig.get(modid, modid, "no data").getString();
|
||||
//globalConfig.save();
|
||||
//return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the String from the GlobalData.ddat file with the custom key
|
||||
* @version From DummyCore 1.4
|
||||
* @param modid - the id of your mod
|
||||
* @param dataName - key of the data
|
||||
* @return a string with the data, written to the ddat file. Returns "no data" if none was found
|
||||
*/
|
||||
public static String getCustomDataForMod(String modid, String dataName)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
return MiscUtils.registeredClientWorldData.get(modid+"|"+dataName);
|
||||
}else
|
||||
{
|
||||
if(!MiscUtils.registeredServerWorldData.containsKey(modid+"|"+dataName))
|
||||
loadCustomDataForMod(modid,dataName);
|
||||
return MiscUtils.registeredServerWorldData.get(modid+"|"+dataName);
|
||||
}
|
||||
//@Deprecated
|
||||
//if(!canWorkWithData())return null;
|
||||
//globalConfig.load();
|
||||
//String ret = globalConfig.get(modid, dataName, "no data").getString();
|
||||
//globalConfig.save();
|
||||
//return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given data to the ddat file of the player with given name.
|
||||
* @version From DummyCore 1.4
|
||||
* @param playerName - name of the player
|
||||
* @param modid - id of the mod
|
||||
* @param dataName - key of the data
|
||||
* @param dataValue - the data to store
|
||||
*/
|
||||
public static void setDataForPlayer(String playerName, String modid, String dataName, String dataValue)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
MiscUtils.registeredClientData.put(playerName+"_"+modid+"|"+dataName, dataValue);
|
||||
}else
|
||||
{
|
||||
if(!canWorkWithData())return;
|
||||
Configuration config = getDataConfigForPlayer(playerName);
|
||||
config.load();
|
||||
config.get(modid, dataName, dataValue).set(dataValue);
|
||||
MiscUtils.registeredServerData.put(playerName+"_"+modid+"|"+dataName, dataValue);
|
||||
config.save();
|
||||
syncPlayerDataToClient(playerName, modid, dataName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadPlayerDataForMod(String playerName, String modid, String dataName)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
return;
|
||||
}else
|
||||
{
|
||||
if(!canWorkWithData())return;
|
||||
Configuration config = getDataConfigForPlayer(playerName);
|
||||
config.load();
|
||||
MiscUtils.registeredServerData.put(playerName+"_"+modid+"|"+dataName, config.get(modid, dataName, "no data").getString());
|
||||
config.save();
|
||||
syncPlayerDataToClient(playerName, modid, dataName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the String from the ddat file of the given player with the custom key
|
||||
* @version From DummyCore 1.4
|
||||
* @param playerName - name of the player
|
||||
* @param modid - id of the mod
|
||||
* @param dataName - key of the data
|
||||
* @return a string with the data, written to the ddat file. Returns "no data" if none was found
|
||||
*/
|
||||
public static String getDataForPlayer(String playerName, String modid, String dataName)
|
||||
{
|
||||
Side s = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
return MiscUtils.registeredClientData.get(playerName+"_"+modid+"|"+dataName);
|
||||
}else
|
||||
{
|
||||
if(!MiscUtils.registeredServerData.containsKey(playerName+"_"+modid+"|"+dataName))
|
||||
loadPlayerDataForMod(playerName, modid, dataName);
|
||||
return MiscUtils.registeredServerData.get(playerName+"_"+modid+"|"+dataName);
|
||||
}
|
||||
//@Deprecated
|
||||
//if(!canWorkWithData())return null;
|
||||
//Configuration config = getDataConfigForPlayer(playerName);
|
||||
//config.load();
|
||||
//String ret = config.get(modid, dataName, "no data").getString();
|
||||
//config.save();
|
||||
//return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check, if current world exists(for example, if the player is in the main menu returns false)
|
||||
* @version From DummyCore 1.4
|
||||
* @return True, if there is a running world, false if not.
|
||||
*/
|
||||
public static boolean canWorkWithData()
|
||||
{
|
||||
return isWorking;
|
||||
}
|
||||
|
||||
public static void syncGlobalDataToClient(String modid, String dataName)
|
||||
{
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
public static void syncGlobalDataToClient(String modid)
|
||||
{
|
||||
if(MiscUtils.registeredServerWorldData.containsKey(modid+"|"+modid))
|
||||
{
|
||||
String dataString = "||mod:DummyCore.InfoSync"+"||"+modid+":"+modid+"||ddata:"+MiscUtils.registeredServerWorldData.get(modid+"|"+modid);
|
||||
DummyPacketIMSG simplePacket = new DummyPacketIMSG(dataString);
|
||||
CoreInitialiser.packetHandler.sendToAll(simplePacket);
|
||||
}else
|
||||
{
|
||||
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)
|
||||
{
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.2
|
||||
* @Description Used to store the distance betwenn 2 points.
|
||||
*/
|
||||
public class DummyDistance {
|
||||
private final float distance;
|
||||
|
||||
public DummyDistance()
|
||||
{
|
||||
distance = 0;
|
||||
}
|
||||
|
||||
public DummyDistance(Coord3D first, Coord3D second)
|
||||
{
|
||||
float diffX = MathUtils.getDifference(first.x, second.x);
|
||||
float diffY = MathUtils.getDifference(first.y, second.y);
|
||||
float diffZ = MathUtils.getDifference(first.z, second.z);
|
||||
distance = (float) Math.sqrt(diffX*diffX+diffY*diffY+diffZ*diffZ);
|
||||
}
|
||||
|
||||
public DummyDistance(Coord2D first, Coord2D second)
|
||||
{
|
||||
float diffX = MathUtils.getDifference(first.x, second.x);
|
||||
float diffZ = MathUtils.getDifference(first.z, second.z);
|
||||
distance = (float) Math.sqrt(diffX*diffX+diffZ*diffZ);
|
||||
}
|
||||
|
||||
public DummyDistance(float first, float second)
|
||||
{
|
||||
distance = MathUtils.getDifference(first, second);
|
||||
}
|
||||
|
||||
public float getDistance()
|
||||
{
|
||||
return this.distance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.ai.attributes.IAttribute;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.management.ServerConfigurationManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import DummyCore.Client.GuiButton_ChangeGUI;
|
||||
import DummyCore.Client.GuiMainMenuVanilla;
|
||||
import DummyCore.Client.MainMenuGUIRenderer;
|
||||
import DummyCore.Client.MainMenuRegistry;
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import DummyCore.Events.DummyEvent_OnClientGUIButtonPress;
|
||||
import DummyCore.Events.DummyEvent_OnKeyboardKeyPressed_Server;
|
||||
import DummyCore.Events.DummyEvent_OnPacketRecieved;
|
||||
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.PlayerTickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cpw.mods.fml.server.FMLServerHandler;
|
||||
|
||||
/**
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.7
|
||||
* @Description Used for internal DummyCore features. Do NOT change!
|
||||
*/
|
||||
public class DummyEventHandler {
|
||||
|
||||
public static boolean[] isKeyPressed;
|
||||
|
||||
public void onBlockBeeingBroken(PlayerEvent.BreakSpeed event)
|
||||
{
|
||||
if(MiscUtils.isBlockUnbreakable(event.entityPlayer.worldObj, event.x, event.y, event.z))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onMainMenuGUISetup(InitGuiEvent.Pre event)
|
||||
{
|
||||
if(event.gui.getClass() == GuiMainMenu.class)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
MainMenuRegistry.newMainMenu(DummyConfig.getMainMenu());
|
||||
}
|
||||
if(event.gui instanceof IMainMenu)
|
||||
{
|
||||
if(MainMenuRegistry.menuList.get(DummyConfig.getMainMenu()) != event.gui.getClass())
|
||||
{
|
||||
event.setCanceled(true);
|
||||
MainMenuRegistry.newMainMenu(DummyConfig.getMainMenu());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onClientTick(RenderTickEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(isKeyPressed == null) isKeyPressed = new boolean[Keyboard.getKeyCount()];
|
||||
if(FMLClientHandler.instance().getClientPlayerEntity() != null)
|
||||
for(int i = 0; i < isKeyPressed.length; ++i)
|
||||
{
|
||||
if(Keyboard.isKeyDown(Keyboard.getKeyIndex(Keyboard.getKeyName(i))) && !isKeyPressed[i])
|
||||
{
|
||||
isKeyPressed[i] = true;
|
||||
int id = i;
|
||||
String keyName = Keyboard.getKeyName(i);
|
||||
String username = FMLClientHandler.instance().getClientPlayerEntity().getCommandSenderName();
|
||||
DummyData aaa = new DummyData("id",id);
|
||||
DummyData aab = new DummyData("name",keyName);
|
||||
DummyData aac = new DummyData("username",username);
|
||||
DummyData aad = new DummyData("pressed",true);
|
||||
DataStorage.addDataToString(aaa);
|
||||
DataStorage.addDataToString(aab);
|
||||
DataStorage.addDataToString(aac);
|
||||
DataStorage.addDataToString(aad);
|
||||
String dataString = DataStorage.getDataString();
|
||||
DummyPacketIMSG packet = new DummyPacketIMSG("||mod:DummyCore.ButtonPress"+dataString);
|
||||
CoreInitialiser.packetHandler.sendToServer(packet);
|
||||
}
|
||||
if(!Keyboard.isKeyDown(Keyboard.getKeyIndex(Keyboard.getKeyName(i))) && isKeyPressed[i])
|
||||
{
|
||||
isKeyPressed[i] = false;
|
||||
int id = i;
|
||||
String keyName = Keyboard.getKeyName(i);
|
||||
String username = FMLClientHandler.instance().getClientPlayerEntity().getCommandSenderName();
|
||||
DummyData aaa = new DummyData("id",id);
|
||||
DummyData aab = new DummyData("name",keyName);
|
||||
DummyData aac = new DummyData("username",username);
|
||||
DummyData aad = new DummyData("pressed",false);
|
||||
DataStorage.addDataToString(aaa);
|
||||
DataStorage.addDataToString(aab);
|
||||
DataStorage.addDataToString(aac);
|
||||
DataStorage.addDataToString(aad);
|
||||
String dataString = DataStorage.getDataString();
|
||||
DummyPacketIMSG packet = new DummyPacketIMSG("||mod:DummyCore.ButtonPress"+dataString);
|
||||
CoreInitialiser.packetHandler.sendToServer(packet);
|
||||
}
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
DataStorage.getDataString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onMainMenuGUISetup(InitGuiEvent.Post event)
|
||||
{
|
||||
if(event.gui instanceof IMainMenu)
|
||||
{
|
||||
event.buttonList.add(new GuiButton_ChangeGUI(65535, event.gui.width/2 + 104, event.gui.height/4 + 24 + 72, 100, 20, "Change Main Menu"));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacketRecieved(DummyEvent_OnPacketRecieved event)
|
||||
{
|
||||
DummyData[] packetData = DataStorage.parseData(event.recievedData);
|
||||
if(packetData != null && packetData.length > 0)
|
||||
{
|
||||
try {
|
||||
DummyData modData = packetData[0];
|
||||
if(modData.fieldName.equalsIgnoreCase("mod") && modData.fieldValue.equalsIgnoreCase("dummycore.tilesync"))
|
||||
{
|
||||
int x = Integer.parseInt(packetData[1].fieldValue);
|
||||
int y = Integer.parseInt(packetData[2].fieldValue);
|
||||
int z = Integer.parseInt(packetData[3].fieldValue);
|
||||
TileEntity tile = event.recievedEntity.worldObj.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof ITEHasGameData)
|
||||
{
|
||||
DummyData[] tileShouldRecieve = Arrays.copyOfRange(packetData, 4, packetData.length);
|
||||
((ITEHasGameData)tile).setData(tileShouldRecieve);
|
||||
}
|
||||
}
|
||||
if(modData.fieldName.equalsIgnoreCase("mod") && modData.fieldValue.equalsIgnoreCase("dummycore.particle"))
|
||||
{
|
||||
String type = packetData[1].fieldValue;
|
||||
float x = Float.parseFloat(packetData[2].fieldValue);
|
||||
float y = Float.parseFloat(packetData[3].fieldValue);
|
||||
float z = Float.parseFloat(packetData[4].fieldValue);
|
||||
double r = Double.parseDouble(packetData[5].fieldValue);
|
||||
double g = Double.parseDouble(packetData[6].fieldValue);
|
||||
double b = Double.parseDouble(packetData[7].fieldValue);
|
||||
event.recievedEntity.worldObj.spawnParticle(type, x, y, z, r, g, b);
|
||||
}
|
||||
if(modData.fieldName.equalsIgnoreCase("mod") && modData.fieldValue.equalsIgnoreCase("dummycore.infosync"))
|
||||
{
|
||||
String modName = packetData[1].fieldName;
|
||||
String dataName = packetData[1].fieldValue;
|
||||
String dataItself = event.recievedData.substring(event.recievedData.indexOf("||ddata:")+8);
|
||||
MiscUtils.registeredClientWorldData.put(modName+"|"+dataName, dataItself);
|
||||
}
|
||||
if(modData.fieldName.equalsIgnoreCase("mod") && modData.fieldValue.equalsIgnoreCase("dummycore.playerinfosync"))
|
||||
{
|
||||
String playerName = packetData[1].fieldValue;
|
||||
String modName = packetData[2].fieldName;
|
||||
String dataName = packetData[2].fieldValue;
|
||||
String dataItself = event.recievedData.substring(event.recievedData.indexOf("||ddata:")+8);
|
||||
MiscUtils.registeredClientData.put(playerName+"_"+modName+"|"+dataName, dataItself);
|
||||
}
|
||||
if(modData.fieldName.equalsIgnoreCase("mod") && modData.fieldValue.equalsIgnoreCase("dummycore.biomechange"))
|
||||
{
|
||||
int x = Integer.parseInt(packetData[1].fieldValue);
|
||||
int z = Integer.parseInt(packetData[2].fieldValue);
|
||||
int id = Integer.parseInt(packetData[3].fieldValue);
|
||||
World world = event.recievedEntity.worldObj;
|
||||
Chunk chunk = world.getChunkFromBlockCoords(x,z);
|
||||
byte[] biome = chunk.getBiomeArray();
|
||||
int cbiome = biome[(z & 0xf) << 4 | x & 0xf];
|
||||
cbiome = id & 0xff;
|
||||
biome[(z & 0xf) << 4 | x & 0xf] = (byte) cbiome;
|
||||
chunk.setBiomeArray(biome);
|
||||
world.markBlocksDirtyVertical(x, z, 16, 16);
|
||||
}
|
||||
if(modData.fieldName.equalsIgnoreCase("mod") && modData.fieldValue.equalsIgnoreCase("dummyCore.buttonpress"))
|
||||
{
|
||||
int id = Integer.parseInt(packetData[1].fieldValue);
|
||||
String name = packetData[2].fieldValue;
|
||||
String username = packetData[3].fieldValue;
|
||||
boolean pressed = Boolean.parseBoolean(packetData[4].fieldValue);
|
||||
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_OnKeyboardKeyPressed_Server(id, name, player,pressed));
|
||||
}
|
||||
}
|
||||
if(modData.fieldName.equalsIgnoreCase("mod") && modData.fieldValue.equalsIgnoreCase("dummyCore.guiButton"))
|
||||
{
|
||||
int id = Integer.parseInt(packetData[1].fieldValue);
|
||||
String pClName = packetData[2].fieldValue;
|
||||
String bClName = packetData[3].fieldValue;
|
||||
String username = packetData[4].fieldValue;
|
||||
int x = Integer.parseInt(packetData[5].fieldValue);
|
||||
int y = Integer.parseInt(packetData[6].fieldValue);
|
||||
int z = Integer.parseInt(packetData[7].fieldValue);
|
||||
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));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDescrAdded(ItemTooltipEvent event)
|
||||
{
|
||||
ItemStack stack = event.itemStack;
|
||||
String unlocName = stack.getUnlocalizedName();
|
||||
if(MiscUtils.descriptionTable.containsKey(unlocName))
|
||||
{
|
||||
event.toolTip.add(MiscUtils.descriptionCTable.get(unlocName)+MiscUtils.descriptionTable.get(unlocName));
|
||||
}else
|
||||
{
|
||||
List list = Arrays.asList(stack.getItem().itemRegistry.getNameForObject(stack.getItem()),stack.getItemDamage());
|
||||
if(MiscUtils.descriptionNTable.containsKey(list))
|
||||
{
|
||||
event.toolTip.add(MiscUtils.descriptionNCTable.get(list)+MiscUtils.descriptionNTable.get(list));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerTickEnd(PlayerTickEvent event)
|
||||
{
|
||||
EntityPlayer player = event.player;
|
||||
IInventory inv = player.inventory;
|
||||
for(int k = 0; k < inv.getSizeInventory(); ++k)
|
||||
{
|
||||
ItemStack s = inv.getStackInSlot(k);
|
||||
if(s != null)
|
||||
{
|
||||
if(s.getItem() instanceof IAttributeModifier)
|
||||
{
|
||||
String itype = ((IAttributeModifier)s.getItem()).getType(s, player);
|
||||
if(itype.equals("inventory"))
|
||||
{
|
||||
String last5OfUUID = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player);
|
||||
int operation = ((IAttributeModifier)s.getItem()).getOperation(s, player);
|
||||
double ivalue = ((IAttributeModifier)s.getItem()).getValue(s, player);
|
||||
IAttribute iattrib = ((IAttributeModifier)s.getItem()).getAttribute(s, player);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}else
|
||||
{
|
||||
if(itype.equals("hold") && player.getCurrentEquippedItem() == s)
|
||||
{
|
||||
String last5OfUUID = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player);
|
||||
int operation = ((IAttributeModifier)s.getItem()).getOperation(s, player);
|
||||
double ivalue = ((IAttributeModifier)s.getItem()).getValue(s, player);
|
||||
IAttribute iattrib = ((IAttributeModifier)s.getItem()).getAttribute(s, player);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}else
|
||||
{
|
||||
if(itype.equals("armor") && (player.inventory.armorInventory[0] == s ||player.inventory.armorInventory[1] == s ||player.inventory.armorInventory[2] == s ||player.inventory.armorInventory[3] == s))
|
||||
{
|
||||
String last5OfUUID = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player);
|
||||
int operation = ((IAttributeModifier)s.getItem()).getOperation(s, player);
|
||||
double ivalue = ((IAttributeModifier)s.getItem()).getValue(s, player);
|
||||
IAttribute iattrib = ((IAttributeModifier)s.getItem()).getAttribute(s, player);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else
|
||||
{
|
||||
List l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(s.getItemDamage()));
|
||||
if(MiscUtils.shouldIgnoreDamage.contains(s.getItem()))
|
||||
l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(-1));
|
||||
if(MiscUtils.modifierType.containsKey(l))
|
||||
{
|
||||
String itype = MiscUtils.modifierType.get(l);
|
||||
|
||||
if(itype.equals("inventory"))
|
||||
{
|
||||
String last5OfUUID = MiscUtils.modifierUUID.get(l);
|
||||
int operation = MiscUtils.modifierOperation.get(l);
|
||||
double ivalue = MiscUtils.modifierValue.get(l);
|
||||
IAttribute iattrib = MiscUtils.modifier.get(l);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}else
|
||||
{
|
||||
if(itype.equals("hold") && player.getCurrentEquippedItem() == s)
|
||||
{
|
||||
String last5OfUUID = MiscUtils.modifierUUID.get(l);
|
||||
int operation = MiscUtils.modifierOperation.get(l);
|
||||
double ivalue = MiscUtils.modifierValue.get(l);
|
||||
IAttribute iattrib = MiscUtils.modifier.get(l);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}else
|
||||
{
|
||||
if(itype.equals("armor") && (player.inventory.armorInventory[0] == s ||player.inventory.armorInventory[1] == s ||player.inventory.armorInventory[2] == s ||player.inventory.armorInventory[3] == s))
|
||||
{
|
||||
String last5OfUUID = MiscUtils.modifierUUID.get(l);
|
||||
int operation = MiscUtils.modifierOperation.get(l);
|
||||
double ivalue = MiscUtils.modifierValue.get(l);
|
||||
IAttribute iattrib = MiscUtils.modifier.get(l);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i1 = 0; i1 < player.getAttributeMap().getAllAttributes().size(); ++i1)
|
||||
{
|
||||
IAttributeInstance ainst = (IAttributeInstance) player.getAttributeMap().getAllAttributes().toArray()[i1];
|
||||
Collection coll = ainst.func_111122_c();
|
||||
for(int j = 0; j < coll.size(); ++j)
|
||||
{
|
||||
if(coll.toArray()[j] instanceof AttributeModifier)
|
||||
{
|
||||
AttributeModifier mod = (AttributeModifier) coll.toArray()[j];
|
||||
String name = mod.getName();
|
||||
boolean remove = true;
|
||||
if(name.contains("dam."))
|
||||
{
|
||||
String sub = mod.getID().toString().substring(mod.getID().toString().length()-5, mod.getID().toString().length());
|
||||
if(name.contains("hold"))
|
||||
{
|
||||
ItemStack s = player.getCurrentEquippedItem();
|
||||
if(s != null)
|
||||
{
|
||||
if(s.getItem() instanceof IAttributeModifier)
|
||||
{
|
||||
String uuid = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
List l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(s.getItemDamage()));
|
||||
if(MiscUtils.shouldIgnoreDamage.contains(s.getItem()))
|
||||
l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(-1));
|
||||
if(MiscUtils.modifierUUID.containsKey(l))
|
||||
{
|
||||
String uuid = MiscUtils.modifierUUID.get(l).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(name.contains("inventory"))
|
||||
{
|
||||
IInventory inven = player.inventory;
|
||||
for(int k = 0; k < inven.getSizeInventory(); ++k)
|
||||
{
|
||||
ItemStack s = inven.getStackInSlot(k);
|
||||
if(s != null)
|
||||
{
|
||||
if(s.getItem() instanceof IAttributeModifier)
|
||||
{
|
||||
String uuid = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
List l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(s.getItemDamage()));
|
||||
if(MiscUtils.shouldIgnoreDamage.contains(s.getItem()))
|
||||
l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(-1));
|
||||
if(MiscUtils.modifierUUID.containsKey(l))
|
||||
{
|
||||
|
||||
String uuid = MiscUtils.modifierUUID.get(l).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(name.contains("armor"))
|
||||
{
|
||||
for(int k = 0; k < player.inventory.armorInventory.length; ++k)
|
||||
{
|
||||
ItemStack s = player.inventory.armorInventory[k];
|
||||
|
||||
if(s != null)
|
||||
{
|
||||
if(s.getItem() instanceof IAttributeModifier)
|
||||
{
|
||||
String uuid = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
List l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(s.getItemDamage()));
|
||||
if(MiscUtils.shouldIgnoreDamage.contains(s.getItem()))
|
||||
l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(-1));
|
||||
if(MiscUtils.modifierUUID.containsKey(l))
|
||||
{
|
||||
String uuid = MiscUtils.modifierUUID.get(l).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(remove)
|
||||
MiscUtils.applyPlayerModifier(player, ainst.getAttribute(), sub, 1, true, 0, "remove");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class DummyFakePlayerFactory {
|
||||
|
||||
public static Hashtable<Class, GameProfile> fakeProfiles = new Hashtable();
|
||||
|
||||
public static GameProfile getGameProfile(Class mod)
|
||||
{
|
||||
if(fakeProfiles.get(mod) == null)
|
||||
{
|
||||
fakeProfiles.put(mod, new GameProfile(UUID.randomUUID(), "[DC]["+mod.getSimpleName()+"]"));
|
||||
}
|
||||
return fakeProfiles.get(mod);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
|
||||
@Deprecated
|
||||
public class DummyPacketDispatcher {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import DummyCore.Events.DummyEvent_OnPacketRecieved;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.FMLOutboundHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cpw.mods.fml.server.FMLServerHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.handler.codec.MessageToMessageCodec;
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
public class DummyPacketHandler implements IMessageHandler<DummyPacketIMSG, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(DummyPacketIMSG message, MessageContext ctx)
|
||||
{
|
||||
Side s = ctx.side;
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new DummyEvent_OnPacketRecieved(s, message.dataStr, CoreInitialiser.proxy.getPlayerOnSide(ctx.getClientHandler())));
|
||||
}else
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new DummyEvent_OnPacketRecieved(s, message.dataStr, CoreInitialiser.proxy.getPlayerOnSide(ctx.getServerHandler())));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void sendToAll(DummyPacketIMSG message)
|
||||
{
|
||||
CoreInitialiser.network.sendToAll(message);
|
||||
}
|
||||
|
||||
public static void sendToAllAround(DummyPacketIMSG message, TargetPoint pnt)
|
||||
{
|
||||
CoreInitialiser.network.sendToAllAround(message, pnt);
|
||||
}
|
||||
|
||||
public static void sendToAllAround(DummyPacketIMSG message, int dim)
|
||||
{
|
||||
CoreInitialiser.network.sendToDimension(message, dim);
|
||||
}
|
||||
|
||||
public static void sendToPlayer(DummyPacketIMSG message, EntityPlayerMP player)
|
||||
{
|
||||
CoreInitialiser.network.sendTo(message, (EntityPlayerMP) player);
|
||||
}
|
||||
|
||||
public static void sendToServer(DummyPacketIMSG message)
|
||||
{
|
||||
CoreInitialiser.network.sendToServer(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class DummyPacketIMSG implements IMessage{
|
||||
|
||||
public String dataStr;
|
||||
|
||||
public DummyPacketIMSG()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DummyPacketIMSG(String data)
|
||||
{
|
||||
dataStr = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
dataStr = ByteBufUtils.readUTF8String(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeUTF8String(buf, dataStr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class DummyPacketIMSG_Tile implements IMessage{
|
||||
|
||||
public NBTTagCompound dataTag;
|
||||
|
||||
public DummyPacketIMSG_Tile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DummyPacketIMSG_Tile(NBTTagCompound data, int id)
|
||||
{
|
||||
dataTag = data;
|
||||
dataTag.setInteger("packetID", id);
|
||||
}
|
||||
|
||||
public DummyPacketIMSG_Tile(NBTTagCompound data)
|
||||
{
|
||||
dataTag = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
dataTag = ByteBufUtils.readTag(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeTag(buf, dataTag);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
@Deprecated
|
||||
public class DummyPlayerTickTracker {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import DummyCore.Events.DummyEvent_OnPacketRecieved;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.FMLOutboundHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cpw.mods.fml.server.FMLServerHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.handler.codec.MessageToMessageCodec;
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
public class DummyTilePacketHandler implements IMessageHandler<DummyPacketIMSG_Tile, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(DummyPacketIMSG_Tile message, MessageContext ctx)
|
||||
{
|
||||
Side s = ctx.side;
|
||||
int packetID = -10;
|
||||
if(message.dataTag.hasKey("packetID"))
|
||||
{
|
||||
packetID = message.dataTag.getInteger("packetID");
|
||||
message.dataTag.removeTag("packetID");
|
||||
}
|
||||
S35PacketUpdateTileEntity genPkt = new S35PacketUpdateTileEntity(message.dataTag.getInteger("x"),message.dataTag.getInteger("y"),message.dataTag.getInteger("z"),packetID,message.dataTag);
|
||||
if(s == Side.CLIENT)
|
||||
{
|
||||
ctx.getClientHandler().handleUpdateTileEntity(genPkt);
|
||||
}else
|
||||
{
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void sendToAll(DummyPacketIMSG_Tile message)
|
||||
{
|
||||
CoreInitialiser.network.sendToAll(message);
|
||||
}
|
||||
|
||||
public static void sendToAllAround(DummyPacketIMSG_Tile message, TargetPoint pnt)
|
||||
{
|
||||
CoreInitialiser.network.sendToAllAround(message, pnt);
|
||||
}
|
||||
|
||||
public static void sendToAllAround(DummyPacketIMSG_Tile message, int dim)
|
||||
{
|
||||
CoreInitialiser.network.sendToDimension(message, dim);
|
||||
}
|
||||
|
||||
public static void sendToPlayer(DummyPacketIMSG_Tile message, EntityPlayerMP player)
|
||||
{
|
||||
CoreInitialiser.network.sendTo(message, (EntityPlayerMP) player);
|
||||
}
|
||||
|
||||
public static void sendToServer(DummyPacketIMSG_Tile message)
|
||||
{
|
||||
CoreInitialiser.network.sendToServer(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
@Deprecated
|
||||
public enum EnumGuiPosition {
|
||||
TOPLEFT,
|
||||
TOPRIGHT,
|
||||
BOTLEFT,
|
||||
BOTRIGHT,
|
||||
CENTER;
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
EnumGuiPosition()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
public enum EnumRarityColor {
|
||||
BROKEN("8","Broken"),
|
||||
COMMON("f","Common"),
|
||||
GOOD("a","Good"),
|
||||
UNCOMMON("2","Uncommon"),
|
||||
RARE("9","Rare"),
|
||||
UNIQUE("d","Unique"),
|
||||
EPIC("e","Epic"),
|
||||
LEGENDARY("6","Legendary"),
|
||||
EXCEPTIONAL("b","Exceptional"),
|
||||
PERFECT("3","Perfect"),
|
||||
ULTIMATE("c","Ultimate"),
|
||||
TURQUOISE("4","Turquoise"),
|
||||
;
|
||||
EnumRarityColor(String s, String s1)
|
||||
{
|
||||
value = s;
|
||||
name = s1;
|
||||
}
|
||||
|
||||
private String value;
|
||||
private String name;
|
||||
|
||||
public String getRarityColor()
|
||||
{
|
||||
String ret = new String();
|
||||
ret += "\247";
|
||||
ret+=value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public static EnumRarityColor getColorByHex(String hex)
|
||||
{
|
||||
EnumRarityColor retColor = BROKEN;
|
||||
for(int i = 0; i < values().length;++i)
|
||||
{
|
||||
EnumRarityColor color = values()[i];
|
||||
if(color.value.equalsIgnoreCase(hex))
|
||||
return color;
|
||||
}
|
||||
return retColor;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import DummyCore.Client.GuiCommon;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class GuiContainerLibrary {
|
||||
public static List<String> guis = new ArrayList();
|
||||
public static List<String> containers = new ArrayList();
|
||||
|
||||
/**
|
||||
* Can be used for easier GUI opening, if you do not want to make a Proxy for that. This method should only be used to open simple GUIs(tile entity ones)
|
||||
* @param guiClassPath - the path to GUI class. Gui class should extend GuiCommon!
|
||||
* @param containerClassPath - the path to your Container class.
|
||||
* @return the ID with which you should use to open your GUI on block right-click.
|
||||
*/
|
||||
public static int registerGuiContainer(String guiClassPath, String containerClassPath)
|
||||
{
|
||||
int lstSize = guis.size();
|
||||
try
|
||||
{
|
||||
guis.add(guiClassPath);
|
||||
containers.add(containerClassPath);
|
||||
}catch(Exception e)
|
||||
{
|
||||
Notifier.notifySimple("Unable to register GUI-Container with ID "+lstSize);
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
return lstSize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import net.minecraft.entity.ai.attributes.IAttribute;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IAttributeModifier {
|
||||
|
||||
public abstract String getType(ItemStack stack, EntityPlayer p);
|
||||
|
||||
public abstract double getValue(ItemStack stack, EntityPlayer p);
|
||||
|
||||
public abstract IAttribute getAttribute(ItemStack stack, EntityPlayer p);
|
||||
|
||||
public abstract String last5OfUUID(ItemStack stack, EntityPlayer p);
|
||||
|
||||
public abstract int getOperation(ItemStack stack, EntityPlayer p);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -20,14 +21,16 @@ import net.minecraft.world.World;
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.1
|
||||
* Please remember to check your item's unlocalized name before any actions using MultiBlock.getUnlocalisedNameByMetadata(meta), otherwise every multiblock will function the same!
|
||||
* @warning Will get removed due to 1.7.2 changes
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IDummyMultiBlock {
|
||||
|
||||
public boolean canPlaceItemBlockOnSide(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer, ItemStack par7ItemStack);
|
||||
|
||||
public void onItemBlockUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5);
|
||||
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4);
|
||||
public List addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4);
|
||||
|
||||
public EnumRarity getRarity(ItemStack par1ItemStack);
|
||||
|
||||
@@ -35,9 +38,9 @@ public interface IDummyMultiBlock {
|
||||
|
||||
public float getBlockBrightness(Block b, IBlockAccess par1IBlockAccess, int par2, int par3, int par4);
|
||||
|
||||
public void registerIcons(IconRegister reg);
|
||||
public void registerIcons(IIconRegister reg);
|
||||
|
||||
public Icon getBlockTexture(Block b, IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5);
|
||||
public IIcon getBlockTexture(Block b, IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5);
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(Block b, World par1World, int par2, int par3, int par4);
|
||||
|
||||
@@ -47,11 +50,19 @@ public interface IDummyMultiBlock {
|
||||
|
||||
public void onBlockDestroyedByPlayer(Block b, World par1World, int par2, int par3, int par4, int par5);
|
||||
|
||||
public void onNeighborBlockChange(Block b, World par1World, int par2, int par3, int par4, int par5);
|
||||
public void onNeighborBlockChange(Block b, World par1World, int par2, int par3, int par4, Block par5);
|
||||
|
||||
public void onBlockAdded(Block b, World par1World, int par2, int par3, int par4);
|
||||
|
||||
public boolean onBlockActivated(Block b, World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9);
|
||||
|
||||
public void setBlockBoundsBasedOnState(Block b, IBlockAccess par1IBlockAccess, int par2, int par3, int par4);
|
||||
|
||||
public IIcon getIcon(int par1, int par2);
|
||||
|
||||
public int getRenderColor(int par1);
|
||||
|
||||
public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune);
|
||||
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random);
|
||||
}
|
||||
@@ -28,6 +28,8 @@ public interface IDummyMultiItem {
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5);
|
||||
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4);
|
||||
|
||||
public int getColorFromItemStack(ItemStack par1ItemStack, int par2);
|
||||
|
||||
public EnumRarity getRarity(ItemStack par1ItemStack);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IMainMenu {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
public interface ITEHasGameData {
|
||||
|
||||
public abstract String getData();
|
||||
|
||||
public abstract void setData(DummyData[] data);
|
||||
|
||||
public abstract Coord3D getPosition();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.Color;
|
||||
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Modbder
|
||||
* @version From DummyCore 1.9
|
||||
* @Description used to create a lightning graphical effect between 2 points.
|
||||
*/
|
||||
public class Lightning {
|
||||
|
||||
public Random rnd;
|
||||
public Coord3D[] lightningVecsStart;
|
||||
public Coord3D[] lightningVecsEnd;
|
||||
public Coord3D start;
|
||||
public Coord3D end;
|
||||
public float renderTicksExisted;
|
||||
public float[] getLightningColor = new float[3];
|
||||
|
||||
/**
|
||||
* Creates a lightning
|
||||
* @param rand - the random on which your lightning will be built upon.
|
||||
* @param begin - the beginning point of the lightning. This NEVER should relate to coordinates in the world! Instead, it can be 0,0,0, if you want the lightning to be created from the bottom corner of a block, for example.
|
||||
* @param stop - the end point of the lightning. This NEVER should relate to coordinates in the world! Instead, it can be 0,10,0, if you want the lightning to go 10 blocks higher.
|
||||
* @param curve - the amount of curving in your lightning. Usually somewhat around 0.3F if you want the lightning to look realistic. If you put 0.0F it will be a straight line, and 1.0F can lead to weird stuff.
|
||||
* @param color - the color array, representing the color of the lightning.
|
||||
*/
|
||||
public Lightning(Random rand, Coord3D begin, Coord3D stop,float curve, float... color)
|
||||
{
|
||||
rnd = rand;
|
||||
start = begin;
|
||||
end = stop;
|
||||
getLightningColor = color;
|
||||
curve(curve);
|
||||
}
|
||||
|
||||
private void curve(float factor)
|
||||
{
|
||||
int mainDivisions = rnd.nextInt(3)+2;
|
||||
float distX = end.x-start.x;
|
||||
float distY = end.y-start.y;
|
||||
float distZ = end.z-start.z;
|
||||
float genDistance = (float) Math.sqrt(distX*distX+distY*distY+distZ*distZ);
|
||||
lightningVecsStart = new Coord3D[64];
|
||||
lightningVecsEnd = new Coord3D[64];
|
||||
generateLightningBetween2Points(start, end, 0, 8, factor);
|
||||
generateLightningBetween2Points(lightningVecsStart[3], new Coord3D(end.x*(factor*10),end.y,end.z*(factor*10)), 8, 4, factor*3);
|
||||
int genIndex = 0;
|
||||
for(int i = 0; i < 12; ++i)
|
||||
{
|
||||
int rndSteps = rnd.nextInt(2);
|
||||
genIndex += (1+rndSteps);
|
||||
generateLightningBetween2Points(lightningVecsStart[i], new Coord3D(lightningVecsStart[i].x+MathUtils.randomFloat(rnd)*(genDistance/4), lightningVecsStart[i].y+MathUtils.randomFloat(rnd)*(genDistance/4),lightningVecsStart[i].z+MathUtils.randomFloat(rnd)*(genDistance/4)),12+i,1+rndSteps,factor/2);
|
||||
}
|
||||
for(int i = 12; i < 12+genIndex; ++i)
|
||||
{
|
||||
if(lightningVecsStart[i] != null)
|
||||
generateLightningBetween2Points(lightningVecsStart[i], new Coord3D(lightningVecsStart[i].x+MathUtils.randomFloat(rnd)*(genDistance/8), lightningVecsStart[i].y+MathUtils.randomFloat(rnd)*(genDistance/8),lightningVecsStart[i].z+MathUtils.randomFloat(rnd)*(genDistance/8)),12+genIndex+i,0,factor);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateLightningBetween2Points(Coord3D from, Coord3D to,int beginVecIndex, int steps, float curve)
|
||||
{
|
||||
float distX = to.x-from.x;
|
||||
float distY = to.y-from.y;
|
||||
float distZ = to.z-from.z;
|
||||
for(int i = 0; i < steps; ++i)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
lightningVecsStart[beginVecIndex+i] = from;
|
||||
lightningVecsEnd[beginVecIndex+i] = new Coord3D(lightningVecsStart[beginVecIndex+i].x+distX/steps+MathUtils.randomFloat(rnd)*curve,lightningVecsStart[beginVecIndex+i].y+distY/steps+MathUtils.randomFloat(rnd)*curve,lightningVecsStart[beginVecIndex+i].z+distZ/steps+MathUtils.randomFloat(rnd)*curve);
|
||||
}else
|
||||
{
|
||||
lightningVecsStart[beginVecIndex+i] = lightningVecsEnd[beginVecIndex+i-1];
|
||||
lightningVecsEnd[beginVecIndex+i] = new Coord3D(lightningVecsStart[beginVecIndex+i].x+distX/steps+MathUtils.randomFloat(rnd)*curve,lightningVecsStart[beginVecIndex+i].y+distY/steps+MathUtils.randomFloat(rnd)*curve,lightningVecsStart[beginVecIndex+i].z+distZ/steps+MathUtils.randomFloat(rnd)*curve);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this anywhere in your render code to actually render the lightning.
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param partialTicks
|
||||
*/
|
||||
public void render(double x, double y, double z, float partialTicks)
|
||||
{
|
||||
renderTicksExisted += partialTicks/1F;
|
||||
if(renderTicksExisted >= this.lightningVecsStart.length)
|
||||
renderTicksExisted = this.lightningVecsStart.length;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(2929);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glDisable(3553);
|
||||
GL11.glDisable(2896);
|
||||
GL11.glTranslated(x, y, z);
|
||||
for(int i = 0; i < renderTicksExisted; ++i)
|
||||
{
|
||||
if(this.lightningVecsStart[i] != null)
|
||||
{
|
||||
this.renderBeam(lightningVecsStart[i], lightningVecsEnd[i], 0.8F);
|
||||
this.renderBeam(lightningVecsStart[i], lightningVecsEnd[i], 1F);
|
||||
}
|
||||
}
|
||||
GL11.glEnable(2896);
|
||||
GL11.glEnable(3553);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderBeam(Coord3D begin, Coord3D stop, float type)
|
||||
{
|
||||
if(type != 1F)
|
||||
GL11.glLineWidth(3);
|
||||
else
|
||||
GL11.glLineWidth(1);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glBegin(1);
|
||||
|
||||
if(type != 1)
|
||||
GL11.glColor4f(1,1,1,0.2F);
|
||||
else
|
||||
GL11.glColor4f(this.getLightningColor[0],this.getLightningColor[1],this.getLightningColor[2],0.8F);
|
||||
GL11.glVertex3d(begin.x, begin.y, begin.z);
|
||||
GL11.glVertex3d(stop.x, stop.y, stop.z);
|
||||
GL11.glColor3d(1.0D, 1.0D, 1.0D);
|
||||
|
||||
|
||||
GL11.glEnd();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -20,6 +20,8 @@ public class MathUtils {
|
||||
*/
|
||||
public static int pixelatedTextureSize(int current, int max, int textureSize)
|
||||
{
|
||||
if(current > max)
|
||||
current = max;
|
||||
float m = (float)current/max*100;
|
||||
float n = m/100*textureSize;
|
||||
return (int)n;
|
||||
@@ -85,7 +87,7 @@ public class MathUtils {
|
||||
public static float getDifference(float pos1, float pos2)
|
||||
{
|
||||
float diff = pos1-pos2;
|
||||
return (float)(Math.sqrt(diff*diff));
|
||||
return (float)module(diff);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,6 +97,7 @@ public class MathUtils {
|
||||
* @param b - second int to swap
|
||||
* @return int[2] with this 2 values swapped.
|
||||
*/
|
||||
@Deprecated
|
||||
public static int[] swap(int a, int b)
|
||||
{
|
||||
return new int[]{b,a};
|
||||
@@ -110,4 +113,62 @@ public class MathUtils {
|
||||
{
|
||||
return Integer.parseInt(Integer.toString(a),16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the always positive value of a double.
|
||||
* @version From DummyCore 1.2
|
||||
* @param a - the double to be converted
|
||||
* @return this double, but positive(>0)
|
||||
*/
|
||||
public static double module(double a)
|
||||
{
|
||||
if(a < 0) a = -a;
|
||||
return a;
|
||||
}
|
||||
|
||||
public static boolean arrayContains(Object[] array, Object searched)
|
||||
{
|
||||
for(int i = 0; i < array.length; ++i)
|
||||
{
|
||||
if(array[i].equals(searched))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean arrayContains(int[] array, int searched)
|
||||
{
|
||||
for(int i = 0; i < array.length; ++i)
|
||||
{
|
||||
if(array[i] == searched)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getIntInArray(int[] array, int searched)
|
||||
{
|
||||
for(int i = 0; i < array.length; ++i)
|
||||
{
|
||||
if(array[i] == searched)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static boolean isArrayTheSame(boolean[] array)
|
||||
{
|
||||
boolean previous = array[0];
|
||||
for(int i = 0; i < array.length; ++i)
|
||||
{
|
||||
if(array[i] == previous)
|
||||
{
|
||||
previous = array[i];
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+1281
-9
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,149 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import DummyCore.Client.GuiMainMenuOld;
|
||||
import DummyCore.Client.GuiMainMenuVanilla;
|
||||
import DummyCore.Client.MainMenuRegistry;
|
||||
import DummyCore.Core.CoreInitialiser;
|
||||
import DummyCore.CreativeTabs.CreativePageBlocks;
|
||||
import DummyCore.CreativeTabs.CreativePageItems;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.shader.ShaderGroup;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class NetProxy_Client extends NetProxy_Server{
|
||||
|
||||
public static final Hashtable<String, ShaderGroup> shaders = new Hashtable();
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayerOnSide(INetHandler handler)
|
||||
{
|
||||
if(handler instanceof NetHandlerPlayClient)
|
||||
{
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerInfo()
|
||||
{
|
||||
MainMenuRegistry.registerNewGui(GuiMainMenuVanilla.class,"[DC] Vanilla","Just a simple vanilla MC gui.");
|
||||
MainMenuRegistry.registerNewGui(GuiMainMenuOld.class,"[DC] Old Vanilla","An old MC gui.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerInit()
|
||||
{
|
||||
if(CoreInitialiser.cfg.removeMissingTexturesErrors)
|
||||
{
|
||||
Logger logger = LogManager.getLogger(TextureMap.class);
|
||||
org.apache.logging.log4j.core.Logger log = (org.apache.logging.log4j.core.Logger) logger;
|
||||
log.setLevel(Level.OFF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
|
||||
int x, int y, int z) {
|
||||
try
|
||||
{
|
||||
Class guiClass = Class.forName(GuiContainerLibrary.guis.get(ID));
|
||||
Constructor constrctr_gui = guiClass.getConstructor(Container.class, TileEntity.class);
|
||||
Class containerClass = Class.forName(GuiContainerLibrary.containers.get(ID));
|
||||
Constructor constrctr = containerClass.getConstructor(InventoryPlayer.class, TileEntity.class);
|
||||
Object obj = constrctr.newInstance(player.inventory,world.getTileEntity(x, y, z));
|
||||
return constrctr_gui.newInstance(obj,world.getTileEntity(x, y, z));
|
||||
}catch(Exception e)
|
||||
{
|
||||
Notifier.notifySimple("Unable to open GUI for ID "+ID);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initShaders(ResourceLocation rLoc)
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityRenderer er = mc.entityRenderer;
|
||||
try
|
||||
{
|
||||
if(rLoc == null)
|
||||
{
|
||||
er.deactivateShader();
|
||||
}else
|
||||
{
|
||||
er.theShaderGroup = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), rLoc);
|
||||
er.theShaderGroup.createBindFramebuffers(mc.displayWidth, mc.displayHeight);
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void choseDisplayStack(CreativePageBlocks blocks)
|
||||
{
|
||||
World w = Minecraft.getMinecraft().theWorld;
|
||||
if(w.isRemote && w.getWorldTime() % 20 == 0)
|
||||
{
|
||||
blocks.delayTime = 0;
|
||||
blocks.blockList = blocks.initialiseBlocksList();
|
||||
if(blocks.blockList != null && !blocks.blockList.isEmpty())
|
||||
{
|
||||
Random rand;
|
||||
if(DummyConfig.shouldChangeImage)
|
||||
rand = new Random(w.getWorldTime());
|
||||
else
|
||||
rand = new Random(0);
|
||||
int random = rand.nextInt(blocks.blockList.size());
|
||||
ItemStack itm = blocks.blockList.get(random);
|
||||
if(itm != null && itm.getItem() != null)
|
||||
blocks.displayStack = itm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void choseDisplayStack(CreativePageItems items)
|
||||
{
|
||||
World w = Minecraft.getMinecraft().theWorld;
|
||||
if(w.isRemote && w.getWorldTime() % 20 == 0)
|
||||
{
|
||||
items.delayTime = 0;
|
||||
items.itemList = items.initialiseItemsList();
|
||||
if(items.itemList != null && !items.itemList.isEmpty())
|
||||
{
|
||||
Random rand;
|
||||
if(DummyConfig.shouldChangeImage)
|
||||
rand = new Random(w.getWorldTime());
|
||||
else
|
||||
rand = new Random(0);
|
||||
int random = rand.nextInt(items.itemList.size());
|
||||
ItemStack itm = items.itemList.get(random);
|
||||
if(itm != null && itm.getItem() != null)
|
||||
items.displayStack = itm;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import DummyCore.CreativeTabs.CreativePageBlocks;
|
||||
import DummyCore.CreativeTabs.CreativePageItems;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class NetProxy_Server implements IGuiHandler{
|
||||
|
||||
public EntityPlayer getPlayerOnSide(INetHandler handler)
|
||||
{
|
||||
if(handler instanceof NetHandlerPlayServer)
|
||||
{
|
||||
return ((NetHandlerPlayServer)handler).playerEntity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world,int x, int y, int z) {
|
||||
try
|
||||
{
|
||||
Class containerClass = Class.forName(GuiContainerLibrary.containers.get(ID));
|
||||
Constructor constrctr = containerClass.getConstructor(InventoryPlayer.class, TileEntity.class);
|
||||
return constrctr.newInstance(player.inventory,world.getTileEntity(x, y, z));
|
||||
}catch(Exception e)
|
||||
{
|
||||
Notifier.notifySimple("Unable to open Container for ID "+ID);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
|
||||
int x, int y, int z) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void initShaders(ResourceLocation rLoc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void choseDisplayStack(CreativePageBlocks blocks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void choseDisplayStack(CreativePageItems items)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,11 +2,11 @@ package DummyCore.Utils;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import ViSuCraft.ViSuProject.Mod.ViSuMod;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class Notifier {
|
||||
@@ -25,6 +25,8 @@ public class Notifier {
|
||||
private static String mod = "[DummyCore]";
|
||||
|
||||
private static StringBuilder builder = new StringBuilder();
|
||||
|
||||
public static final Logger logger = LogManager.getLogger();
|
||||
|
||||
public static void notify(String... s)
|
||||
{
|
||||
@@ -83,7 +85,10 @@ public class Notifier {
|
||||
|
||||
public static void publish(String s)
|
||||
{
|
||||
System.out.println(s);
|
||||
org.apache.logging.log4j.core.Logger log = (org.apache.logging.log4j.core.Logger) logger;
|
||||
log.setLevel(Level.INFO);
|
||||
if(DummyConfig.enableNotifierLogging)
|
||||
logger.log(Level.INFO, s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,612 +0,0 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import DummyCore.Core.Core;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAnvil;
|
||||
import net.minecraft.block.BlockHopper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ChestItemRenderHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.projectile.EntityPotion;
|
||||
import net.minecraft.item.ItemPotion;
|
||||
import net.minecraft.potion.PotionHelper;
|
||||
import net.minecraft.src.FMLRenderAccessLibrary;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class RendererColoredLight extends Render{
|
||||
|
||||
private RenderBlocks blockRenderer = new RenderBlocks();
|
||||
@Override
|
||||
public void doRender(Entity entity, double d0, double d1, double d2,
|
||||
float f, float f1) {
|
||||
if(entity instanceof ColoredLightHandler)
|
||||
{
|
||||
entity = (ColoredLightHandler)entity;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glPushMatrix();
|
||||
blockRenderer.blockAccess = entity.worldObj;
|
||||
EnumLightColor lightColor = EnumLightColor.WHITE;
|
||||
float lightSize = 1.0F;
|
||||
Coord3D ePos = new Coord3D(entity.posX,entity.posY,entity.posZ);
|
||||
Block b = MiscUtils.getBlock(entity.worldObj, (int)entity.posX, (int)entity.posY-1, (int)entity.posZ);
|
||||
Block b1 = MiscUtils.getBlock(entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ);
|
||||
if(b != null && Core.lightBlocks.contains(b) && b instanceof BlockEmmitsColoredLight)
|
||||
{
|
||||
lightColor = ((BlockEmmitsColoredLight)b).getColor(entity.worldObj, (int)entity.posX, (int)entity.posY-1, (int)entity.posZ);
|
||||
lightSize = ((BlockEmmitsColoredLight)b).getLightBrightness(entity.worldObj, (int)entity.posX, (int)entity.posY-1, (int)entity.posZ);
|
||||
}
|
||||
if(b1 != null && Core.lightBlocks.contains(b1) && b1 instanceof BlockEmmitsColoredLight)
|
||||
{
|
||||
lightColor = ((BlockEmmitsColoredLight)b1).getColor(entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ);
|
||||
lightSize = ((BlockEmmitsColoredLight)b1).getLightBrightness(entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ);
|
||||
}
|
||||
for(int x = -8; x < 8; ++x)
|
||||
{
|
||||
for(int y = -8; y < 8; ++y)
|
||||
{
|
||||
for(int z = -8; z < 8; ++z)
|
||||
{
|
||||
Coord3D bPos = new Coord3D(entity.posX+x,entity.posY+y,entity.posZ+z);
|
||||
float posX = (bPos.x - ePos.x);
|
||||
float posY = (bPos.y - ePos.y);
|
||||
float posZ = (bPos.z - ePos.z);
|
||||
posX = (float) Math.sqrt(posX*posX);
|
||||
posY = (float) Math.sqrt(posY*posY);
|
||||
posZ = (float) Math.sqrt(posZ*posZ);
|
||||
float distance = (posX+posY+posZ)/3;
|
||||
distance = (float) Math.sqrt(distance*distance);
|
||||
float brightness = (lightSize/16) - (distance/4);
|
||||
if(brightness<0)brightness=0;
|
||||
//if(brightness > 0.6F) System.out.println(distance);
|
||||
Block b11 = MiscUtils.getBlock(entity.worldObj, (int)entity.posX+x, (int)entity.posY+y-1, (int)entity.posZ+z);
|
||||
if(b11 != null)
|
||||
renderCorrectLight(d0+x+0.5D,d1+y-0.5D,d2+z+0.5D,brightness,entity.worldObj,b11,lightColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation func_110775_a(Entity entity) {
|
||||
// TODO Auto-generated method stub
|
||||
return new ResourceLocation("dummycore","textures/misc/lightmap.png");
|
||||
}
|
||||
|
||||
protected void renderCorrectLight(double par2, double par4, double par6, float brightness,IBlockAccess w,Block block, EnumLightColor color)
|
||||
{
|
||||
Tessellator var3 = Tessellator.instance;
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
float var4 = 1;
|
||||
float var5 = 0.0F;
|
||||
float stability = 1;
|
||||
int mru = 20000;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(par2-0.5D, par4, par6-0.5D);
|
||||
GL11.glScalef(1.0015F, 1.0015F, 1.0015F);
|
||||
//blockRenderer.renderBlockAllFaces(Block.glass, (int)par2, (int)par4, (int)par6);
|
||||
blockRenderer.useInventoryTint = true;
|
||||
if(brightness > 0)
|
||||
this.renderBlockAsItem(block, 0, brightness,color);
|
||||
GL11.glPopMatrix();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
|
||||
public void renderBlockAsItem(Block par1Block, int par2, float par3, EnumLightColor color)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
boolean flag = false;
|
||||
|
||||
if (par1Block == Block.dispenser || par1Block == Block.dropper || par1Block == Block.furnaceIdle)
|
||||
{
|
||||
par2 = 3;
|
||||
}
|
||||
|
||||
int j;
|
||||
float f1 = color.getColor().getRed();
|
||||
float f2 = color.getColor().getGreen();
|
||||
float f3 = color.getColor().getBlue();
|
||||
|
||||
if (blockRenderer.useInventoryTint)
|
||||
{
|
||||
f1 = f1 / 255.0F;
|
||||
f2 = f2 / 255.0F;
|
||||
f3 = f3 / 255.0F;
|
||||
GL11.glColor4f(f1 * par3, f2 * par3, f3 * par3, par3);
|
||||
}
|
||||
|
||||
j = par1Block.getRenderType();
|
||||
blockRenderer.setRenderBoundsFromBlock(par1Block);
|
||||
int k;
|
||||
|
||||
if (j != 0 && j != 31 && j != 39 && j != 16 && j != 26)
|
||||
{
|
||||
if (j == 1)
|
||||
{
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.drawCrossedSquares(par1Block, par2, -0.5D, -0.5D, -0.5D, 1.0F);
|
||||
tessellator.draw();
|
||||
}
|
||||
else if (j == 19)
|
||||
{
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
par1Block.setBlockBoundsForItemRender();
|
||||
blockRenderer.renderBlockStemSmall(par1Block, par2, blockRenderer.renderMaxY, -0.5D, -0.5D, -0.5D);
|
||||
tessellator.draw();
|
||||
}
|
||||
else if (j == 23)
|
||||
{
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
par1Block.setBlockBoundsForItemRender();
|
||||
tessellator.draw();
|
||||
}
|
||||
else if (j == 13)
|
||||
{
|
||||
par1Block.setBlockBoundsForItemRender();
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
f1 = 0.0625F;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 0));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 1));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
tessellator.addTranslation(0.0F, 0.0F, f1);
|
||||
blockRenderer.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 2));
|
||||
tessellator.addTranslation(0.0F, 0.0F, -f1);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
tessellator.addTranslation(0.0F, 0.0F, -f1);
|
||||
blockRenderer.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 3));
|
||||
tessellator.addTranslation(0.0F, 0.0F, f1);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
tessellator.addTranslation(f1, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 4));
|
||||
tessellator.addTranslation(-f1, 0.0F, 0.0F);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
tessellator.addTranslation(-f1, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 5));
|
||||
tessellator.addTranslation(f1, 0.0F, 0.0F);
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
else if (j == 22)
|
||||
{
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
ChestItemRenderHelper.instance.renderChest(par1Block, par2, par3);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
else if (j == 6)
|
||||
{
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderBlockCropsImpl(par1Block, par2, -0.5D, -0.5D, -0.5D);
|
||||
tessellator.draw();
|
||||
}
|
||||
else if (j == 2)
|
||||
{
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderTorchAtAngle(par1Block, -0.5D, -0.5D, -0.5D, 0.0D, 0.0D, 0);
|
||||
tessellator.draw();
|
||||
}
|
||||
else if (j == 10)
|
||||
{
|
||||
for (k = 0; k < 2; ++k)
|
||||
{
|
||||
if (k == 0)
|
||||
{
|
||||
blockRenderer.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.5D);
|
||||
}
|
||||
|
||||
if (k == 1)
|
||||
{
|
||||
blockRenderer.setRenderBounds(0.0D, 0.0D, 0.5D, 1.0D, 0.5D, 1.0D);
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 0));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 1));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
blockRenderer.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
blockRenderer.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 3));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 4));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 5));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
else if (j == 27)
|
||||
{
|
||||
k = 0;
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
{
|
||||
byte b0 = 0;
|
||||
byte b1 = 1;
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
if (l == 1)
|
||||
{
|
||||
b0 = 3;
|
||||
}
|
||||
|
||||
if (l == 2)
|
||||
{
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
if (l == 3)
|
||||
{
|
||||
b0 = 5;
|
||||
b1 = 2;
|
||||
}
|
||||
|
||||
if (l == 4)
|
||||
{
|
||||
b0 = 6;
|
||||
b1 = 3;
|
||||
}
|
||||
|
||||
if (l == 5)
|
||||
{
|
||||
b0 = 7;
|
||||
b1 = 5;
|
||||
}
|
||||
|
||||
if (l == 6)
|
||||
{
|
||||
b0 = 6;
|
||||
b1 = 2;
|
||||
}
|
||||
|
||||
if (l == 7)
|
||||
{
|
||||
b0 = 3;
|
||||
}
|
||||
|
||||
float f4 = (float)b0 / 16.0F;
|
||||
float f5 = 1.0F - (float)k / 16.0F;
|
||||
float f6 = 1.0F - (float)(k + b1) / 16.0F;
|
||||
k += b1;
|
||||
blockRenderer.setRenderBounds((double)(0.5F - f4), (double)f6, (double)(0.5F - f4), (double)(0.5F + f4), (double)f5, (double)(0.5F + f4));
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 0));
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 1));
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
blockRenderer.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 2));
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
blockRenderer.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 3));
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 4));
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 5));
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
blockRenderer.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
}
|
||||
else if (j == 11)
|
||||
{
|
||||
for (k = 0; k < 4; ++k)
|
||||
{
|
||||
f2 = 0.125F;
|
||||
|
||||
if (k == 0)
|
||||
{
|
||||
blockRenderer.setRenderBounds((double)(0.5F - f2), 0.0D, 0.0D, (double)(0.5F + f2), 1.0D, (double)(f2 * 2.0F));
|
||||
}
|
||||
|
||||
if (k == 1)
|
||||
{
|
||||
blockRenderer.setRenderBounds((double)(0.5F - f2), 0.0D, (double)(1.0F - f2 * 2.0F), (double)(0.5F + f2), 1.0D, 1.0D);
|
||||
}
|
||||
|
||||
f2 = 0.0625F;
|
||||
|
||||
if (k == 2)
|
||||
{
|
||||
blockRenderer.setRenderBounds((double)(0.5F - f2), (double)(1.0F - f2 * 3.0F), (double)(-f2 * 2.0F), (double)(0.5F + f2), (double)(1.0F - f2), (double)(1.0F + f2 * 2.0F));
|
||||
}
|
||||
|
||||
if (k == 3)
|
||||
{
|
||||
blockRenderer.setRenderBounds((double)(0.5F - f2), (double)(0.5F - f2 * 3.0F), (double)(-f2 * 2.0F), (double)(0.5F + f2), (double)(0.5F - f2), (double)(1.0F + f2 * 2.0F));
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 0));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 1));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
blockRenderer.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
blockRenderer.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 3));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 4));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 5));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
blockRenderer.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
}
|
||||
else if (j == 21)
|
||||
{
|
||||
for (k = 0; k < 3; ++k)
|
||||
{
|
||||
f2 = 0.0625F;
|
||||
|
||||
if (k == 0)
|
||||
{
|
||||
blockRenderer.setRenderBounds((double)(0.5F - f2), 0.30000001192092896D, 0.0D, (double)(0.5F + f2), 1.0D, (double)(f2 * 2.0F));
|
||||
}
|
||||
|
||||
if (k == 1)
|
||||
{
|
||||
blockRenderer.setRenderBounds((double)(0.5F - f2), 0.30000001192092896D, (double)(1.0F - f2 * 2.0F), (double)(0.5F + f2), 1.0D, 1.0D);
|
||||
}
|
||||
|
||||
f2 = 0.0625F;
|
||||
|
||||
if (k == 2)
|
||||
{
|
||||
blockRenderer.setRenderBounds((double)(0.5F - f2), 0.5D, 0.0D, (double)(0.5F + f2), (double)(1.0F - f2), 1.0D);
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 0));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 1));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
blockRenderer.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
blockRenderer.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 3));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 4));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSide(par1Block, 5));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
else if (j == 32)
|
||||
{
|
||||
for (k = 0; k < 2; ++k)
|
||||
{
|
||||
if (k == 0)
|
||||
{
|
||||
blockRenderer.setRenderBounds(0.0D, 0.0D, 0.3125D, 1.0D, 0.8125D, 0.6875D);
|
||||
}
|
||||
|
||||
if (k == 1)
|
||||
{
|
||||
blockRenderer.setRenderBounds(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D);
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 0, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 1, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
blockRenderer.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 2, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
blockRenderer.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 3, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 4, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 5, par2));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
blockRenderer.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
}
|
||||
else if (j == 35)
|
||||
{
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
blockRenderer.renderBlockAnvilOrient((BlockAnvil)par1Block, 0, 0, 0, par2 << 2, true);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
else if (j == 34)
|
||||
{
|
||||
for (k = 0; k < 3; ++k)
|
||||
{
|
||||
if (k == 0)
|
||||
{
|
||||
blockRenderer.setRenderBounds(0.125D, 0.0D, 0.125D, 0.875D, 0.1875D, 0.875D);
|
||||
blockRenderer.setOverrideBlockTexture(blockRenderer.getBlockIcon(Block.obsidian));
|
||||
}
|
||||
else if (k == 1)
|
||||
{
|
||||
blockRenderer.setRenderBounds(0.1875D, 0.1875D, 0.1875D, 0.8125D, 0.875D, 0.8125D);
|
||||
blockRenderer.setOverrideBlockTexture(blockRenderer.getBlockIcon(Block.beacon));
|
||||
}
|
||||
else if (k == 2)
|
||||
{
|
||||
blockRenderer.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
blockRenderer.setOverrideBlockTexture(blockRenderer.getBlockIcon(Block.glass));
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 0, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 1, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
blockRenderer.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 2, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
blockRenderer.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 3, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 4, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 5, par2));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
blockRenderer.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
blockRenderer.clearOverrideBlockTexture();
|
||||
}
|
||||
else if (j == 38)
|
||||
{
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
blockRenderer.renderBlockHopperMetadata((BlockHopper)par1Block, 0, 0, 0, 0, true);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLRenderAccessLibrary.renderInventoryBlock(blockRenderer, par1Block, par2, j);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (j == 16)
|
||||
{
|
||||
par2 = 1;
|
||||
}
|
||||
GL11.glColor4f(f1*par3, f2*par3, f3*par3,par3);
|
||||
par1Block.setBlockBoundsForItemRender();
|
||||
blockRenderer.setRenderBoundsFromBlock(par1Block);
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 0, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
blockRenderer.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 1, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
blockRenderer.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 2, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
blockRenderer.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 3, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 4, par2));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
blockRenderer.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, blockRenderer.getBlockIconFromSideAndMetadata(par1Block, 5, par2));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Modbder
|
||||
*
|
||||
* @Description Used in code where you want to reference either ItemStack or it's OreDictionary replacement.
|
||||
*/
|
||||
public class UnformedItemStack {
|
||||
|
||||
public List<ItemStack> possibleStacks = new ArrayList<ItemStack>();
|
||||
|
||||
public UnformedItemStack(ItemStack is)
|
||||
{
|
||||
possibleStacks.add(is);
|
||||
sort();
|
||||
}
|
||||
|
||||
public UnformedItemStack(String oreDictName)
|
||||
{
|
||||
possibleStacks.addAll(OreDictionary.getOres(oreDictName));
|
||||
sort();
|
||||
}
|
||||
|
||||
public UnformedItemStack(List<ItemStack> lst)
|
||||
{
|
||||
possibleStacks.addAll(lst);
|
||||
sort();
|
||||
}
|
||||
|
||||
public UnformedItemStack(ItemStack[] stk)
|
||||
{
|
||||
possibleStacks.addAll(Arrays.asList(stk));
|
||||
sort();
|
||||
}
|
||||
|
||||
public UnformedItemStack(Block b)
|
||||
{
|
||||
possibleStacks.add(new ItemStack(b,1,OreDictionary.WILDCARD_VALUE));
|
||||
sort();
|
||||
}
|
||||
|
||||
public UnformedItemStack(Item i)
|
||||
{
|
||||
possibleStacks.add(new ItemStack(i,1,OreDictionary.WILDCARD_VALUE));
|
||||
sort();
|
||||
}
|
||||
|
||||
public UnformedItemStack(Object obj)
|
||||
{
|
||||
if(obj instanceof ItemStack)
|
||||
possibleStacks.add((ItemStack)obj);
|
||||
if(obj instanceof String)
|
||||
possibleStacks.addAll(OreDictionary.getOres((String)obj));
|
||||
if(obj instanceof List<?>)
|
||||
possibleStacks.addAll((List<ItemStack>)obj);
|
||||
if(obj instanceof ItemStack[])
|
||||
possibleStacks.addAll(Arrays.asList((ItemStack[])obj));
|
||||
if(obj instanceof Block)
|
||||
possibleStacks.add(new ItemStack((Block)obj,1,OreDictionary.WILDCARD_VALUE));
|
||||
if(obj instanceof Item)
|
||||
possibleStacks.add(new ItemStack((Item)obj,1,OreDictionary.WILDCARD_VALUE));
|
||||
sort();
|
||||
}
|
||||
|
||||
public boolean itemStackMatches(ItemStack is)
|
||||
{
|
||||
if(is == null)
|
||||
return false;
|
||||
for(ItemStack s : possibleStacks)
|
||||
{
|
||||
if(is.isItemEqual(s) || (is.getItem().equals(s.getItem()) && s.getItemDamage() == OreDictionary.WILDCARD_VALUE))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String str = "";
|
||||
for(ItemStack s : possibleStacks)str += s;
|
||||
return str;
|
||||
}
|
||||
|
||||
public UnformedItemStack copy()
|
||||
{
|
||||
return new UnformedItemStack(this.possibleStacks);
|
||||
}
|
||||
|
||||
public void nullify()
|
||||
{
|
||||
for(ItemStack s : possibleStacks)s.stackSize = 0;
|
||||
}
|
||||
|
||||
public void sort()
|
||||
{
|
||||
List<ItemStack> possibleStacksCopy = new ArrayList();
|
||||
possibleStacksCopy.addAll(possibleStacks);
|
||||
possibleStacks.clear();
|
||||
for(int i = 0; i < possibleStacksCopy.size();++i)
|
||||
{
|
||||
ItemStack is = possibleStacksCopy.get(i);
|
||||
if(is != null)possibleStacks.add(is);
|
||||
}
|
||||
possibleStacksCopy.clear();possibleStacksCopy = null;
|
||||
}
|
||||
|
||||
public ItemStack getISToDraw(long time)
|
||||
{
|
||||
int size = this.possibleStacks.size();
|
||||
if(size <= 0)return null;
|
||||
return this.possibleStacks.get((int)(((int)(time/30))%size));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user