[ci skip] spotlessApply with the new settings

This commit is contained in:
Jason Mitchell committed 2023-01-29 12:54:15 -08:00
1 parent a711c0495e
commit 21f9083d10
83 files changed
+1855 -2448

No files matched your search

+11 -16
View File
@@ -5,7 +5,6 @@ import static mantle.lib.CoreRepo.modId;
import static mantle.lib.CoreRepo.modName;
import static mantle.lib.CoreRepo.modVersion;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import mantle.books.BookData;
import mantle.books.BookDataStore;
import mantle.common.IDDumps;
@@ -14,6 +13,7 @@ import mantle.items.Manual;
import mantle.lib.CoreConfig;
import mantle.lib.CoreRepo;
import mantle.lib.environment.EnvironmentChecks;
import mantle.utils.CraftingHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
@@ -21,11 +21,9 @@ import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import mantle.utils.CraftingHandler;
import java.io.File;
/**
* Mantle
@@ -35,8 +33,8 @@ import java.io.File;
* @author Sunstrike <[email protected]>
*/
@Mod(modid = modId, name = modName, version = modVersion, dependencies = "required-after:Forge@[10.13,)")
public class Mantle
{
public class Mantle {
/* Instance of this mod, used for grabbing prototype fields */
@Instance("Mantle")
public static Mantle instance;
@@ -45,13 +43,13 @@ public class Mantle
public static MProxyCommon proxy;
public static Manual mantleBook;
/**
* Constructor
*
* EnvChecks invoked here so they run as soon as possible to enhance crash reports that may happen in preinit.
*/
public Mantle()
{
public Mantle() {
EnvironmentChecks.verifyEnvironmentSanity();
}
@@ -63,8 +61,7 @@ public class Mantle
* @param evt The FMLPreInitializationEvent from FML
*/
@EventHandler
public void preInit (FMLPreInitializationEvent evt)
{
public void preInit(FMLPreInitializationEvent evt) {
logger.info("Mantle (" + modVersion + ") -- Preparing for launch.");
logger.info("Entering preinitialization phase.");
CoreConfig.loadConfiguration(evt.getModConfigurationDirectory());
@@ -84,8 +81,7 @@ public class Mantle
* @param evt The FMLInitializationEvent from FML
*/
@EventHandler
public void Init (FMLInitializationEvent evt)
{
public void Init(FMLInitializationEvent evt) {
logger.info("Entering initialization phase.");
proxy.registerRenderer();
}
@@ -98,8 +94,7 @@ public class Mantle
* @param evt The FMLPostInitializationEvent from FML
*/
@EventHandler
public void postInit (FMLPostInitializationEvent evt)
{
public void postInit(FMLPostInitializationEvent evt) {
logger.info("Entering postinitialization phase.");
proxy.readManuals();
BookData data = new BookData();
@@ -111,9 +106,9 @@ public class Mantle
CoreConfig.loadBookLocations();
IDDumps.dump();
}
@EventHandler
public void serverStart(FMLServerStartedEvent evt)
{
public void serverStart(FMLServerStartedEvent evt) {
CraftingHandler.logConflicts();
}
+7 -10
View File
@@ -3,28 +3,25 @@ package mantle.blocks;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.registry.GameData;
public class BlockUtils
{
public static Block getBlockFromItem (Item item)
{
public class BlockUtils {
public static Block getBlockFromItem(Item item) {
return Block.getBlockFromItem(item);
}
@SuppressWarnings("unused")
public static Block getBlockFromItemStack (ItemStack itemStack)
{
public static Block getBlockFromItemStack(ItemStack itemStack) {
return getBlockFromItem(itemStack.getItem());
}
public static String getUniqueName (Block block)
{
public static String getUniqueName(Block block) {
return GameData.getBlockRegistry().getNameForObject(block);
}
public static Block getBlockFromUniqueName (String uniqueName)
{
public static Block getBlockFromUniqueName(String uniqueName) {
return GameData.getBlockRegistry().getObject(uniqueName);
}
+8 -11
View File
@@ -3,13 +3,14 @@ package mantle.blocks;
import mantle.debug.DebugHelper;
import mantle.debug.IDebuggable;
import mantle.items.iface.IDebugItem;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
@@ -18,24 +19,20 @@ import cpw.mods.fml.relauncher.Side;
*
* @author Sunstrike <[email protected]>
*/
public abstract class MantleBlock extends Block
{
public abstract class MantleBlock extends Block {
public MantleBlock(Material material)
{
public MantleBlock(Material material) {
super(material);
}
// IDebuggable support - Uses a stick for debug purposes.
@Override
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player)
{
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null
&& (player.getHeldItem().getItem() == Items.stick || player.getHeldItem().getItem() instanceof IDebugItem))
{
&& (player.getHeldItem().getItem() == Items.stick
|| player.getHeldItem().getItem() instanceof IDebugItem)) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof IDebuggable)
DebugHelper.handleDebugData(((IDebuggable) te).getDebugInfo(player));
if (te instanceof IDebuggable) DebugHelper.handleDebugData(((IDebuggable) te).getDebugInfo(player));
}
super.onBlockClicked(world, x, y, z, player);
}
@@ -3,25 +3,22 @@ package mantle.blocks.abstracts;
import java.util.Random;
import mantle.blocks.iface.IFacingLogic;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.FMLCommonHandler;
public abstract class AdaptiveInventoryLogic extends InventoryLogic implements IFacingLogic
{
public abstract class AdaptiveInventoryLogic extends InventoryLogic implements IFacingLogic {
Random random = new Random();
protected int inventorySize;
public AdaptiveInventoryLogic()
{
public AdaptiveInventoryLogic() {
super(0);
}
protected void adjustInventory (int size, boolean forceAdjust)
{
if (size != inventorySize || forceAdjust)
{
protected void adjustInventory(int size, boolean forceAdjust) {
if (size != inventorySize || forceAdjust) {
inventorySize = size;
ItemStack[] tempInv = inventory;
@@ -29,13 +26,10 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I
int invLength = tempInv.length > inventory.length ? inventory.length : tempInv.length;
System.arraycopy(tempInv, 0, inventory, 0, invLength);
if (tempInv.length > inventory.length)
{
for (int i = inventory.length; i < tempInv.length; i++)
{
if (tempInv.length > inventory.length) {
for (int i = inventory.length; i < tempInv.length; i++) {
ItemStack stack = tempInv[i];
if (stack != null)
{
if (stack != null) {
float jumpX = random.nextFloat() * 0.8F + 0.1F;
float jumpY = random.nextFloat() * 0.8F + 0.1F;
float jumpZ = random.nextFloat() * 0.8F + 0.1F;
@@ -43,44 +37,45 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I
int offsetX = 0;
int offsetY = 0;
int offsetZ = 0;
switch (getTossDirection())
{
case 0: // -y
offsetY--;
break;
case 1: // +y
offsetY++;
break;
case 2: // +z
offsetZ--;
break;
case 3: // -z
offsetZ++;
break;
case 4: // +x
offsetX--;
break;
case 5: // -x
offsetX++;
break;
switch (getTossDirection()) {
case 0: // -y
offsetY--;
break;
case 1: // +y
offsetY++;
break;
case 2: // +z
offsetZ--;
break;
case 3: // -z
offsetZ++;
break;
case 4: // +x
offsetX--;
break;
case 5: // -x
offsetX++;
break;
}
while (stack.stackSize > 0)
{
while (stack.stackSize > 0) {
int itemSize = random.nextInt(21) + 10;
if (itemSize > stack.stackSize)
{
if (itemSize > stack.stackSize) {
itemSize = stack.stackSize;
}
stack.stackSize -= itemSize;
EntityItem entityitem = new EntityItem(worldObj, (double) ((float) xCoord + jumpX + offsetX), (double) ((float) yCoord + jumpY),
(double) ((float) zCoord + jumpZ + offsetZ), new ItemStack(stack.getItem(), itemSize, stack.getItemDamage()));
EntityItem entityitem = new EntityItem(
worldObj,
(double) ((float) xCoord + jumpX + offsetX),
(double) ((float) yCoord + jumpY),
(double) ((float) zCoord + jumpZ + offsetZ),
new ItemStack(stack.getItem(), itemSize, stack.getItemDamage()));
if (stack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
if (stack.hasTagCompound()) {
entityitem.getEntityItem()
.setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
}
float offset = 0.05F;
@@ -95,8 +90,7 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I
}
}
public int getTossDirection ()
{
public int getTossDirection() {
return getRenderDirection();
}
}
}
@@ -1,17 +1,16 @@
package mantle.blocks.abstracts;
import java.util.*;
import net.minecraft.entity.player.*;
import net.minecraft.inventory.*;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.*;
import net.minecraft.world.World;
public abstract class ExpandableInventoryLogic extends InventoryLogic implements IInventory
{
public abstract class ExpandableInventoryLogic extends InventoryLogic implements IInventory {
public ExpandableInventoryLogic()
{
public ExpandableInventoryLogic() {
super(0);
}
@@ -19,133 +18,103 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements
protected String invName;
@Override
public ItemStack getStackInSlot (int slot)
{
public ItemStack getStackInSlot(int slot) {
return slot < inventory.size() ? inventory.get(slot) : null;
}
public boolean isStackInSlot (int slot)
{
public boolean isStackInSlot(int slot) {
return slot < inventory.size() && inventory.get(slot) != null;
}
@Override
public int getSizeInventory ()
{
public int getSizeInventory() {
return inventory.size();
}
public int getMaxSize ()
{
public int getMaxSize() {
return 64;
}
@Override
public int getInventoryStackLimit ()
{
public int getInventoryStackLimit() {
return 64;
}
public boolean canDropInventorySlot (int slot)
{
public boolean canDropInventorySlot(int slot) {
return true;
}
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
if (slot < inventory.size())
{
public void setInventorySlotContents(int slot, ItemStack itemstack) {
if (slot < inventory.size()) {
inventory.set(slot, itemstack);
}
else if (slot == inventory.size())
{
} else if (slot == inventory.size()) {
inventory.add(itemstack);
}
else if (slot < getMaxSize())
{
} else if (slot < getMaxSize()) {
inventory.ensureCapacity(slot);
inventory.set(slot, itemstack);
}
else
{
} else {
return;
}
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
{
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
itemstack.stackSize = getInventoryStackLimit();
}
}
@Override
public ItemStack decrStackSize (int slot, int quantity)
{
if (slot < inventory.size() && inventory.get(slot) != null)
{
if (inventory.get(slot).stackSize <= quantity)
{
public ItemStack decrStackSize(int slot, int quantity) {
if (slot < inventory.size() && inventory.get(slot) != null) {
if (inventory.get(slot).stackSize <= quantity) {
ItemStack stack = inventory.get(slot);
inventory.set(slot, null);
return stack;
}
ItemStack split = inventory.get(slot).splitStack(quantity);
if (inventory.get(slot).stackSize == 0)
{
if (inventory.get(slot).stackSize == 0) {
inventory.set(slot, null);
}
return split;
}
else
{
} else {
return null;
}
}
/* Supporting methods */
@Override
public boolean isUseableByPlayer (EntityPlayer entityplayer)
{
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
return false;
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) return false;
else
return entityplayer.getDistance((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D;
else return entityplayer.getDistance((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D)
<= 64D;
}
public abstract Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z);
public abstract Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z);
/* NBT */
@Override
public void readFromNBT (NBTTagCompound tags)
{
public void readFromNBT(NBTTagCompound tags) {
super.readFromNBT(tags);
this.invName = tags.getString("InvName");
NBTTagList nbttaglist = tags.getTagList("Items", 9);
inventory = new ArrayList<ItemStack>();
inventory.ensureCapacity(nbttaglist.tagCount() > getMaxSize() ? getMaxSize() : nbttaglist.tagCount());
for (int iter = 0; iter < nbttaglist.tagCount(); iter++)
{
for (int iter = 0; iter < nbttaglist.tagCount(); iter++) {
NBTTagCompound tagList = nbttaglist.getCompoundTagAt(iter);
byte slotID = tagList.getByte("Slot");
if (slotID >= 0 && slotID < inventory.size())
{
if (slotID >= 0 && slotID < inventory.size()) {
inventory.set(slotID, ItemStack.loadItemStackFromNBT(tagList));
}
}
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
public void writeToNBT(NBTTagCompound tags) {
super.writeToNBT(tags);
if (invName != null)
tags.setString("InvName", invName);
if (invName != null) tags.setString("InvName", invName);
NBTTagList nbttaglist = new NBTTagList();
for (int iter = 0; iter < inventory.size(); iter++)
{
if (inventory.get(iter) != null)
{
for (int iter = 0; iter < inventory.size(); iter++) {
if (inventory.get(iter) != null) {
NBTTagCompound tagList = new NBTTagCompound();
tagList.setByte("Slot", (byte) iter);
inventory.get(iter).writeToNBT(tagList);
@@ -157,61 +126,47 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements
}
/* Default implementations of hardly used methods */
public ItemStack getStackInSlotOnClosing (int slot)
{
public ItemStack getStackInSlotOnClosing(int slot) {
return null;
}
public void openChest ()
{
}
public void openChest() {}
public void closeChest ()
{
}
public void closeChest() {}
protected abstract String getDefaultName ();
protected abstract String getDefaultName();
public void setInvName (String name)
{
public void setInvName(String name) {
this.invName = name;
}
public String getInvName ()
{
public String getInvName() {
return this.isInvNameLocalized() ? this.invName : getDefaultName();
}
public boolean isInvNameLocalized ()
{
public boolean isInvNameLocalized() {
return this.invName != null && this.invName.length() > 0;
}
public void cleanInventory ()
{
public void cleanInventory() {
Iterator<ItemStack> i1 = inventory.iterator();
while (i1.hasNext())
{
if (i1.next() == null)
{
while (i1.hasNext()) {
if (i1.next() == null) {
i1.remove();
}
}
}
@Override
public boolean isItemValidForSlot (int slot, ItemStack itemstack)
{
if (slot < getSizeInventory())
{
if (inventory.get(slot) == null || itemstack.stackSize + inventory.get(slot).stackSize <= getInventoryStackLimit())
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
if (slot < getSizeInventory()) {
if (inventory.get(slot) == null
|| itemstack.stackSize + inventory.get(slot).stackSize <= getInventoryStackLimit())
return true;
}
else
{
} else {
return slot < getMaxSize();
}
return false;
}
}
}
@@ -2,12 +2,11 @@ package mantle.blocks.abstracts;
import java.util.Random;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import mantle.blocks.iface.IActiveLogic;
import mantle.blocks.iface.IFacingLogic;
import mantle.debug.DebugHelper;
import mantle.debug.IDebuggable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -16,91 +15,81 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public abstract class InventoryBlock extends BlockContainer
{
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
public abstract class InventoryBlock extends BlockContainer {
protected Random rand = new Random();
protected InventoryBlock(Material material)
{
protected InventoryBlock(Material material) {
super(material);
}
/* Logic backend */
public TileEntity createNewTileEntity (World var1)
{
public TileEntity createNewTileEntity(World var1) {
return null;
}
public abstract TileEntity createNewTileEntity (World world, int metadata);
public abstract TileEntity createNewTileEntity(World world, int metadata);
public abstract Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer);
public abstract Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer);
public abstract Object getModInstance ();
public abstract Object getModInstance();
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
{
if (player.isSneaking())
return false;
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float clickX,
float clickY, float clickZ) {
if (player.isSneaking()) return false;
Integer integer = getGui(world, x, y, z, player);
if (integer == null || integer == -1)
{
if (integer == null || integer == -1) {
return false;
}
else
{
if (!world.isRemote)
player.openGui(getModInstance(), integer, world, x, y, z);
} else {
if (!world.isRemote) player.openGui(getModInstance(), integer, world, x, y, z);
return true;
}
}
/* Inventory */
@Override
public void breakBlock (World par1World, int x, int y, int z, Block blockID, int meta)
{
public void breakBlock(World par1World, int x, int y, int z, Block blockID, int meta) {
TileEntity te = par1World.getTileEntity(x, y, z);
if (te != null && te instanceof InventoryLogic)
{
if (te != null && te instanceof InventoryLogic) {
InventoryLogic logic = (InventoryLogic) te;
logic.removeBlock();
for (int iter = 0; iter < logic.getSizeInventory(); ++iter)
{
for (int iter = 0; iter < logic.getSizeInventory(); ++iter) {
ItemStack stack = logic.getStackInSlot(iter);
if (stack != null && logic.canDropInventorySlot(iter))
{
if (stack != null && logic.canDropInventorySlot(iter)) {
float jumpX = rand.nextFloat() * 0.8F + 0.1F;
float jumpY = rand.nextFloat() * 0.8F + 0.1F;
float jumpZ = rand.nextFloat() * 0.8F + 0.1F;
while (stack.stackSize > 0)
{
while (stack.stackSize > 0) {
int itemSize = rand.nextInt(21) + 10;
if (itemSize > stack.stackSize)
{
if (itemSize > stack.stackSize) {
itemSize = stack.stackSize;
}
stack.stackSize -= itemSize;
EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ), new ItemStack(stack.getItem(),
itemSize, stack.getItemDamage()));
EntityItem entityitem = new EntityItem(
par1World,
(double) ((float) x + jumpX),
(double) ((float) y + jumpY),
(double) ((float) z + jumpZ),
new ItemStack(stack.getItem(), itemSize, stack.getItemDamage()));
if (stack.hasTagCompound())
{
if (stack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
}
@@ -121,97 +110,82 @@ public abstract class InventoryBlock extends BlockContainer
int side = -1;
//This class does not have an actual block placed in the world
// This class does not have an actual block placed in the world
@Override
public int onBlockPlaced (World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta)
{
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) {
this.side = side;
return meta;
}
@Override
@SuppressWarnings("deprecation") // TODO: Remove this when setDirection calls updated.
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
{
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) {
TileEntity logic = world.getTileEntity(x, y, z);
if (logic instanceof IFacingLogic)
{
if (logic instanceof IFacingLogic) {
IFacingLogic direction = (IFacingLogic) logic;
// TODO: Convert all setDirection calls to modern invokation, when that's ready.
if (side != -1)
{
if (side != -1) {
direction.setDirection(side);
side = -1;
}
if (entityliving == null)
{
if (entityliving == null) {
direction.setDirection(0F, 0F, null);
}
else
{
} else {
direction.setDirection(entityliving.rotationYaw * 4F, entityliving.rotationPitch, entityliving);
}
}
if (logic instanceof InventoryLogic)
{
if (logic instanceof InventoryLogic) {
InventoryLogic inv = (InventoryLogic) logic;
inv.placeBlock(entityliving, stack);
if (stack.hasDisplayName())
{
if (stack.hasDisplayName()) {
inv.setInvName(stack.getDisplayName());
}
}
}
@SuppressWarnings("unused")
public static boolean isActive (IBlockAccess world, int x, int y, int z)
{
public static boolean isActive(IBlockAccess world, int x, int y, int z) {
TileEntity logic = world.getTileEntity(x, y, z);
if (logic instanceof IActiveLogic)
{
if (logic instanceof IActiveLogic) {
return ((IActiveLogic) logic).getActive();
}
return false;
}
public int damageDropped (int meta)
{
public int damageDropped(int meta) {
return meta;
}
/* Textures */
public IIcon[] icons;
public abstract String[] getTextureNames ();
public abstract String[] getTextureNames();
public abstract String getTextureDomain (int textureNameIndex);
public abstract String getTextureDomain(int textureNameIndex);
@Override
public void registerBlockIcons (IIconRegister iconRegister)
{
public void registerBlockIcons(IIconRegister iconRegister) {
String[] textureNames = getTextureNames();
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
for (int i = 0; i < this.icons.length; ++i) {
this.icons[i] = iconRegister.registerIcon(getTextureDomain(i) + ":" + textureNames[i]);
}
}
/* IDebuggable */
@Override
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player)
{
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null && player.getHeldItem().getItem() != null && player.getHeldItem().getItem() == Items.stick)
{
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null
&& player.getHeldItem().getItem() != null
&& player.getHeldItem().getItem() == Items.stick) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof IDebuggable)
{
if (te instanceof IDebuggable) {
DebugHelper.handleDebugData(((IDebuggable) te).getDebugInfo(player));
}
}
super.onBlockClicked(world, x, y, z, player);
}
}
}
@@ -2,6 +2,7 @@ package mantle.blocks.abstracts;
import mantle.debug.DebugData;
import mantle.debug.IDebuggable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -14,23 +15,20 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/*
* A simple logic class for storing items
* Abstract to avoid instantiation
* A simple logic class for storing items Abstract to avoid instantiation
*/
public abstract class InventoryLogic extends TileEntity implements IInventory, IDebuggable
{
public abstract class InventoryLogic extends TileEntity implements IInventory, IDebuggable {
protected ItemStack[] inventory;
protected String invName;
protected int stackSizeLimit;
public InventoryLogic(int invSize)
{
public InventoryLogic(int invSize) {
this(invSize, 64);
}
public InventoryLogic(int invSize, int maxStackSize)
{
public InventoryLogic(int invSize, int maxStackSize) {
inventory = new ItemStack[invSize];
stackSizeLimit = maxStackSize;
}
@@ -38,145 +36,121 @@ public abstract class InventoryLogic extends TileEntity implements IInventory, I
/* Inventory management */
@Override
public ItemStack getStackInSlot (int slot)
{
public ItemStack getStackInSlot(int slot) {
return slot < inventory.length ? inventory[slot] : null;
}
public boolean isStackInSlot (int slot)
{
public boolean isStackInSlot(int slot) {
return slot < inventory.length && inventory[slot] != null;
}
@Override
public int getSizeInventory ()
{
public int getSizeInventory() {
return inventory.length;
}
@Override
public int getInventoryStackLimit ()
{
public int getInventoryStackLimit() {
return stackSizeLimit;
}
public boolean canDropInventorySlot (int slot)
{
public boolean canDropInventorySlot(int slot) {
return true;
}
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
public void setInventorySlotContents(int slot, ItemStack itemstack) {
inventory[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
{
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
itemstack.stackSize = getInventoryStackLimit();
}
}
@Override
public ItemStack decrStackSize (int slot, int quantity)
{
if (inventory[slot] != null)
{
if (inventory[slot].stackSize <= quantity)
{
public ItemStack decrStackSize(int slot, int quantity) {
if (inventory[slot] != null) {
if (inventory[slot].stackSize <= quantity) {
ItemStack stack = inventory[slot];
inventory[slot] = null;
return stack;
}
ItemStack split = inventory[slot].splitStack(quantity);
if (inventory[slot].stackSize == 0)
{
if (inventory[slot].stackSize == 0) {
inventory[slot] = null;
}
return split;
}
else
{
} else {
return null;
}
}
/* Supporting methods */
@Override
public boolean isUseableByPlayer (EntityPlayer entityplayer)
{
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
return false;
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) return false;
else
return entityplayer.getDistance((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D;
else return entityplayer.getDistance((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D)
<= 64D;
}
public abstract Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z);
public abstract Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z);
/* NBT */
@Override
public void readFromNBT (NBTTagCompound tags)
{
public void readFromNBT(NBTTagCompound tags) {
super.readFromNBT(tags);
readInventoryFromNBT(tags);
}
public void readInventoryFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
public void readInventoryFromNBT(NBTTagCompound tags) {
super.readFromNBT(tags);
NBTTagList nbttaglist = tags.getTagList("Items", 10);
this.inventory = new ItemStack[this.getSizeInventory()];
if (tags.hasKey("CustomName", 8))
{
if (tags.hasKey("CustomName", 8)) {
this.invName = tags.getString("CustomName");
}
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound1.getByte("Slot") & 255;
if (j >= 0 && j < this.inventory.length)
{
if (j >= 0 && j < this.inventory.length) {
this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
//Not removed in case of things going terribly wrong
// super.readFromNBT(tags);
// this.invName = tags.getString("InvName");
// NBTTagList nbttaglist = tags.getTagList("Items", 9);
// inventory = new ItemStack[getSizeInventory()];
// for (int iter = 0; iter < nbttaglist.tagCount(); iter++)
// {
// NBTTagCompound tagList = (NBTTagCompound) nbttaglist.getCompoundTagAt(iter);
// byte slotID = tagList.getByte("Slot");
// if (slotID >= 0 && slotID < inventory.length)
// {
// inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList);
// }
// }
// Not removed in case of things going terribly wrong
// super.readFromNBT(tags);
// this.invName = tags.getString("InvName");
// NBTTagList nbttaglist = tags.getTagList("Items", 9);
// inventory = new ItemStack[getSizeInventory()];
// for (int iter = 0; iter < nbttaglist.tagCount(); iter++)
// {
// NBTTagCompound tagList = (NBTTagCompound) nbttaglist.getCompoundTagAt(iter);
// byte slotID = tagList.getByte("Slot");
// if (slotID >= 0 && slotID < inventory.length)
// {
// inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList);
// }
// }
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
public void writeToNBT(NBTTagCompound tags) {
super.writeToNBT(tags);
writeInventoryToNBT(tags);
}
public void writeInventoryToNBT (NBTTagCompound tags)
{
public void writeInventoryToNBT(NBTTagCompound tags) {
super.writeToNBT(tags);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.inventory.length; ++i)
{
if (this.inventory[i] != null)
{
for (int i = 0; i < this.inventory.length; ++i) {
if (this.inventory[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
nbttagcompound1.setByte("Slot", (byte) i);
this.inventory[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
@@ -184,103 +158,87 @@ public abstract class InventoryLogic extends TileEntity implements IInventory, I
tags.setTag("Items", nbttaglist);
if (this.isInvNameLocalized())
{
if (this.isInvNameLocalized()) {
tags.setString("CustomName", this.invName);
}
//Not removed in case of things going terribly wrong
// if (invName != null)
// tags.setString("InvName", invName);
// NBTTagList nbttaglist = new NBTTagList();
// for (int iter = 0; iter < inventory.length; iter++)
// {
// if (inventory[iter] != null)
// {
// NBTTagCompound tagList = new NBTTagCompound();
// tagList.setByte("Slot", (byte) iter);
// inventory[iter].writeToNBT(tagList);
// nbttaglist.appendTag(tagList);
// }
// }
//
// tags.setTag("Items", nbttaglist);
// Not removed in case of things going terribly wrong
// if (invName != null)
// tags.setString("InvName", invName);
// NBTTagList nbttaglist = new NBTTagList();
// for (int iter = 0; iter < inventory.length; iter++)
// {
// if (inventory[iter] != null)
// {
// NBTTagCompound tagList = new NBTTagCompound();
// tagList.setByte("Slot", (byte) iter);
// inventory[iter].writeToNBT(tagList);
// nbttaglist.appendTag(tagList);
// }
// }
//
// tags.setTag("Items", nbttaglist);
}
/* Cause of the heisenbug. Do not uncomment! */
/*public void superReadFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
}
public void superWriteToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
}*/
/*
* public void superReadFromNBT (NBTTagCompound tags) { super.readFromNBT(tags); } public void superWriteToNBT
* (NBTTagCompound tags) { super.writeToNBT(tags); }
*/
/* Default implementations of hardly used methods */
public ItemStack getStackInSlotOnClosing (int slot)
{
public ItemStack getStackInSlotOnClosing(int slot) {
return null;
}
public void openChest ()
{
}
public void openChest() {}
public void closeChest ()
{
}
public void closeChest() {}
protected abstract String getDefaultName ();
protected abstract String getDefaultName();
public void setInvName (String name)
{
public void setInvName(String name) {
this.invName = name;
}
public String getInvName ()
{
public String getInvName() {
return this.isInvNameLocalized() ? this.invName : getDefaultName();
}
public boolean hasCustomInventoryName()
{
public boolean hasCustomInventoryName() {
return isInvNameLocalized();
}
public boolean isInvNameLocalized ()
{
public boolean isInvNameLocalized() {
return this.invName != null && this.invName.length() > 0;
}
@Override
public boolean isItemValidForSlot (int slot, ItemStack itemstack)
{
if (slot < getSizeInventory())
{
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
if (slot < getSizeInventory()) {
if (inventory[slot] == null || itemstack.stackSize + inventory[slot].stackSize <= getInventoryStackLimit())
return true;
}
return false;
}
public void placeBlock (EntityLivingBase entity, ItemStack stack)
{
public void placeBlock(EntityLivingBase entity, ItemStack stack) {
}
public void removeBlock ()
{
public void removeBlock() {
}
/* IDebuggable */
@Override
public DebugData getDebugInfo (EntityPlayer player)
{
public DebugData getDebugInfo(EntityPlayer player) {
String[] strs = new String[1];
strs[0] = "invName: " + invName + ", inventory.length: " + inventory.length + ", stackSizeLimit: " + stackSizeLimit;
strs[0] = "invName: " + invName
+ ", inventory.length: "
+ inventory.length
+ ", stackSizeLimit: "
+ stackSizeLimit;
return new DebugData(player, getClass(), strs);
}
}
}
@@ -13,78 +13,67 @@ import net.minecraft.world.World;
*
* @author mDiyo
*/
public abstract class InventorySlab extends InventoryBlock
{
public InventorySlab(Material material)
{
public abstract class InventorySlab extends InventoryBlock {
public InventorySlab(Material material) {
super(material);
}
/* Rendering */
@Override
//TODO: renderAsNormalBlock()
public boolean renderAsNormalBlock ()
{
// TODO: renderAsNormalBlock()
public boolean renderAsNormalBlock() {
return false;
}
//TODO: isOpaqueCube()
// TODO: isOpaqueCube()
@Override
public boolean isOpaqueCube ()
{
public boolean isOpaqueCube() {
return false;
}
//TODO shouldSideBeRendered
// TODO shouldSideBeRendered
@Override
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
{
if (side > 1)
return super.shouldSideBeRendered(world, x, y, z, side);
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
if (side > 1) return super.shouldSideBeRendered(world, x, y, z, side);
int meta = world.getBlockMetadata(x, y, z);
boolean top = (meta | 8) == 1;
if ((top && side == 0) || (!top && side == 1))
return true;
if ((top && side == 0) || (!top && side == 1)) return true;
return super.shouldSideBeRendered(world, x, y, z, side);
}
//TODO: addCollisionBoxesToList()
// TODO: addCollisionBoxesToList()
@Override
@SuppressWarnings("rawtypes")
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity)
{
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist,
Entity entity) {
setBlockBoundsBasedOnState(world, x, y, z);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
}
public void setBlockBoundsForItemRender ()
{
//TODO: setBlockBounds
public void setBlockBoundsForItemRender() {
// TODO: setBlockBounds
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
{
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z) / 8;
float minY = meta == 1 ? 0.5F : 0.0F;
float maxY = meta == 1 ? 1.0F : 0.5F;
setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F);
}
public int onBlockPlaced (World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, float clickZ, int metadata)
{
if (side == 1)
return metadata;
if (side == 0 || clickY >= 0.5F)
return metadata | 8;
public int onBlockPlaced(World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY,
float clickZ, int metadata) {
if (side == 1) return metadata;
if (side == 0 || clickY >= 0.5F) return metadata | 8;
return metadata;
}
public int damageDropped (int meta)
{
public int damageDropped(int meta) {
return meta % 8;
}
}
}
@@ -1,6 +1,7 @@
package mantle.blocks.abstracts;
import static mantle.lib.CoreRepo.logger;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
@@ -8,60 +9,52 @@ import net.minecraft.util.MathHelper;
/**
*
* @author progwml6
* base class for itemBlocks with different unlocalized names based on metadata
* @author progwml6 base class for itemBlocks with different unlocalized names based on metadata
*/
public class MultiItemBlock extends ItemBlock
{
public class MultiItemBlock extends ItemBlock {
private String blockType[];
private String unlocalizedName;
private String append;
private int specialIndex[] = { -1, -1 };
public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String[] blockTypes)
{
public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String[] blockTypes) {
super(b);
if (itemBlockUnlocalizedName.isEmpty())
this.unlocalizedName = super.getUnlocalizedName();
else
this.unlocalizedName = itemBlockUnlocalizedName;
if (itemBlockUnlocalizedName.isEmpty()) this.unlocalizedName = super.getUnlocalizedName();
else this.unlocalizedName = itemBlockUnlocalizedName;
this.blockType = blockTypes;
this.append = "";
}
public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String appendToEnd, String[] blockTypes)
{
public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String appendToEnd, String[] blockTypes) {
super(b);
this.unlocalizedName = itemBlockUnlocalizedName;
this.blockType = blockTypes;
this.append = "." + appendToEnd;
}
public void setSpecialIndex (int clampIndex, int stringBuilderIndex)
{
public void setSpecialIndex(int clampIndex, int stringBuilderIndex) {
specialIndex[0] = clampIndex;
specialIndex[1] = stringBuilderIndex;
}
public int getMetadata (int meta)
{
public int getMetadata(int meta) {
return meta;
}
public String getUnlocalizedName (ItemStack itemstack)
{
public String getUnlocalizedName(ItemStack itemstack) {
int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, (specialIndex[0] > -1) ? specialIndex[0] : (blockType.length - 1));
int pos = MathHelper.clamp_int(
itemstack.getItemDamage(),
0,
(specialIndex[0] > -1) ? specialIndex[0] : (blockType.length - 1));
int sbIndex = (specialIndex[1] > -1) ? pos : (specialIndex[1] - pos);
if (sbIndex < 0)
sbIndex = -1 * sbIndex;
try
{
return (new StringBuilder()).append(unlocalizedName).append(".").append(blockType[sbIndex - 1]).append(append).toString();
}
catch (ArrayIndexOutOfBoundsException ex)
{
if (sbIndex < 0) sbIndex = -1 * sbIndex;
try {
return (new StringBuilder()).append(unlocalizedName).append(".").append(blockType[sbIndex - 1])
.append(append).toString();
} catch (ArrayIndexOutOfBoundsException ex) {
logger.warn("[MultiItemBlock] Caught array index error in getUnlocalizedName: " + ex.getMessage());
logger.warn("[MultiItemBlock] Returning unlocalized name: " + getUnlocalizedName());
return getUnlocalizedName();
@@ -6,6 +6,7 @@ import mantle.blocks.iface.IServantLogic;
import mantle.debug.DebugData;
import mantle.debug.IDebuggable;
import mantle.world.CoordTuple;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@@ -14,56 +15,48 @@ import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.GameRegistry;
public class MultiServantLogic extends TileEntity implements IServantLogic, IDebuggable
{
public class MultiServantLogic extends TileEntity implements IServantLogic, IDebuggable {
boolean hasMaster;
CoordTuple master;
Block masterBlock;
byte masterMeat; //Typo, it stays!
byte masterMeat; // Typo, it stays!
public boolean canUpdate ()
{
public boolean canUpdate() {
return false;
}
public boolean getHasMaster ()
{
public boolean getHasMaster() {
return hasMaster;
}
public boolean hasValidMaster ()
{
if (!hasMaster)
return false;
public boolean hasValidMaster() {
if (!hasMaster) return false;
if (worldObj.getBlock(master.x, master.y, master.z) == masterBlock && worldObj.getBlockMetadata(master.x, master.y, master.z) == masterMeat)
if (worldObj.getBlock(master.x, master.y, master.z) == masterBlock
&& worldObj.getBlockMetadata(master.x, master.y, master.z) == masterMeat)
return true;
else
{
else {
hasMaster = false;
master = null;
return false;
}
}
public CoordTuple getMasterPosition ()
{
public CoordTuple getMasterPosition() {
return master;
}
public void overrideMaster (int x, int y, int z)
{
public void overrideMaster(int x, int y, int z) {
hasMaster = true;
master = new CoordTuple(x, y, z);
masterBlock = worldObj.getBlock(x, y, z);
masterMeat = (byte) worldObj.getBlockMetadata(x, y, z);
}
public void removeMaster ()
{
public void removeMaster() {
hasMaster = false;
master = null;
masterBlock = null;
@@ -71,55 +64,44 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb
}
@Override
public boolean setPotentialMaster (IMasterLogic master, World w, int x, int y, int z)
{
public boolean setPotentialMaster(IMasterLogic master, World w, int x, int y, int z) {
return !hasMaster;
}
@Deprecated
public boolean verifyMaster (IMasterLogic logic, int x, int y, int z)
{
if (master.equalCoords(x, y, z) && worldObj.getBlock(x, y, z) == masterBlock && worldObj.getBlockMetadata(x, y, z) == masterMeat)
public boolean verifyMaster(IMasterLogic logic, int x, int y, int z) {
if (master.equalCoords(x, y, z) && worldObj.getBlock(x, y, z) == masterBlock
&& worldObj.getBlockMetadata(x, y, z) == masterMeat)
return true;
else
return false;
else return false;
}
@Override
public boolean verifyMaster (IMasterLogic logic, World world, int x, int y, int z)
{
if (hasMaster)
{
public boolean verifyMaster(IMasterLogic logic, World world, int x, int y, int z) {
if (hasMaster) {
return hasValidMaster();
}
else
{
} else {
overrideMaster(x, y, z);
return true;
}
}
@Override
public void invalidateMaster (IMasterLogic master, World w, int x, int y, int z)
{
public void invalidateMaster(IMasterLogic master, World w, int x, int y, int z) {
hasMaster = false;
master = null;
}
public void notifyMasterOfChange ()
{
if (hasValidMaster())
{
public void notifyMasterOfChange() {
if (hasValidMaster()) {
IMasterLogic logic = (IMasterLogic) worldObj.getTileEntity(master.x, master.y, master.z);
logic.notifyChange(this, xCoord, yCoord, zCoord);
}
}
public void readCustomNBT (NBTTagCompound tags)
{
public void readCustomNBT(NBTTagCompound tags) {
hasMaster = tags.getBoolean("TiedToMaster");
if (hasMaster)
{
if (hasMaster) {
int xCenter = tags.getInteger("xCenter");
int yCenter = tags.getInteger("yCenter");
int zCenter = tags.getInteger("zCenter");
@@ -129,11 +111,9 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb
}
}
public void writeCustomNBT (NBTTagCompound tags)
{
public void writeCustomNBT(NBTTagCompound tags) {
tags.setBoolean("TiedToMaster", hasMaster);
if (hasMaster)
{
if (hasMaster) {
tags.setInteger("xCenter", master.x);
tags.setInteger("yCenter", master.y);
tags.setInteger("zCenter", master.z);
@@ -143,31 +123,27 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb
}
@Override
public void readFromNBT (NBTTagCompound tags)
{
public void readFromNBT(NBTTagCompound tags) {
super.readFromNBT(tags);
readCustomNBT(tags);
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
public void writeToNBT(NBTTagCompound tags) {
super.writeToNBT(tags);
writeCustomNBT(tags);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeCustomNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
{
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readCustomNBT(packet.func_148857_g());
worldObj.func_147479_m(xCoord, yCoord, zCoord);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
@@ -175,36 +151,28 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb
/* IDebuggable */
@Override
public DebugData getDebugInfo (EntityPlayer player)
{
public DebugData getDebugInfo(EntityPlayer player) {
String[] strs = new String[2];
strs[0] = "Location: x" + xCoord + ", y" + yCoord + ", z" + zCoord;
if (hasMaster)
{
if (hasMaster) {
strs[1] = "masterBlock: " + masterBlock.toString() + ", masterMeat: " + masterMeat;
}
else
{
} else {
strs[1] = "No active master.";
}
return new DebugData(player, getClass(), strs);
}
public World getWorld ()
{
public World getWorld() {
return super.getWorldObj();
}
@Deprecated
public boolean setMaster (int x, int y, int z)
{
if (!hasMaster || worldObj.getBlock(master.x, master.y, master.z) != masterBlock || (worldObj.getBlockMetadata(master.x, master.y, master.z) != masterMeat))
{
public boolean setMaster(int x, int y, int z) {
if (!hasMaster || worldObj.getBlock(master.x, master.y, master.z) != masterBlock
|| (worldObj.getBlockMetadata(master.x, master.y, master.z) != masterMeat)) {
overrideMaster(x, y, z);
return true;
}
else
{
} else {
return false;
}
}
@@ -5,9 +5,9 @@ package mantle.blocks.iface;
*
* @author mDiyo
*/
public interface IActiveLogic
{
public boolean getActive ();
public interface IActiveLogic {
public void setActive (boolean flag);
public boolean getActive();
public void setActive(boolean flag);
}
@@ -8,20 +8,21 @@ import net.minecraftforge.common.util.ForgeDirection;
*
* @author mDiyo
*/
public interface IFacingLogic
{
public interface IFacingLogic {
public byte getRenderDirection ();
public byte getRenderDirection();
public ForgeDirection getForgeDirection ();
public ForgeDirection getForgeDirection();
@Deprecated
public void setDirection (int side);
public void setDirection(int side);
@Deprecated
public void setDirection (float yaw, float pitch, EntityLivingBase player);
public void setDirection(float yaw, float pitch, EntityLivingBase player);
/** This will be added next version
* public void setDirection(int side, float yaw, float pitch, EntityLivingBase player); */
/**
* This will be added next version public void setDirection(int side, float yaw, float pitch, EntityLivingBase
* player);
*/
}
@@ -1,12 +1,13 @@
package mantle.blocks.iface;
public interface IMasterLogic
{
/** Called when servants change their state
public interface IMasterLogic {
/**
* Called when servants change their state
*
* @param x Servant X
* @param y Servant Y
* @param z Servant Z
*/
public void notifyChange (IServantLogic servant, int x, int y, int z);
public void notifyChange(IServantLogic servant, int x, int y, int z);
}
@@ -1,8 +1,8 @@
package mantle.blocks.iface;
public interface IMasterNode extends IMasterLogic, IServantLogic
{
public boolean isCurrentlyMaster ();
public interface IMasterNode extends IMasterLogic, IServantLogic {
public boolean isEquivalentMaster (IMasterLogic master);
public boolean isCurrentlyMaster();
public boolean isEquivalentMaster(IMasterLogic master);
}
@@ -1,47 +1,51 @@
package mantle.blocks.iface;
import mantle.world.CoordTuple;
import net.minecraft.world.World;
public interface IServantLogic
{
public CoordTuple getMasterPosition ();
public interface IServantLogic {
public CoordTuple getMasterPosition();
/** The block should already have a valid master */
public void notifyMasterOfChange ();
public void notifyMasterOfChange();
/** Checks if this block can be tied to this master
/**
* Checks if this block can be tied to this master
*
* @param master
* @param world the world of master
* @param x xCoord of master
* @param y yCoord of master
* @param z zCoord of master
* @param world the world of master
* @param x xCoord of master
* @param y yCoord of master
* @param z zCoord of master
* @return whether the servant can be tied to this master
*/
public boolean setPotentialMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster);
public boolean setPotentialMaster(IMasterLogic master, World world, int xMaster, int yMaster, int zMaster);
/** Used to set and verify that this is the block's master
/**
* Used to set and verify that this is the block's master
*
* @param master
* @param world
* @param x xCoord of master
* @param y yCoord of master
* @param z zCoord of master
* @param world
* @param x xCoord of master
* @param y yCoord of master
* @param z zCoord of master
* @return Is this block tied to this master?
*/
public boolean verifyMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster);
public boolean verifyMaster(IMasterLogic master, World world, int xMaster, int yMaster, int zMaster);
/** Exactly what it says on the tin
/**
* Exactly what it says on the tin
*
* @param master
* @param world
* @param x xCoord of master
* @param y yCoord of master
* @param z zCoord of master
* @param world
* @param x xCoord of master
* @param y yCoord of master
* @param z zCoord of master
*/
public void invalidateMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster);
public void invalidateMaster(IMasterLogic master, World world, int xMaster, int yMaster, int zMaster);
}
+6 -7
View File
@@ -1,12 +1,13 @@
package mantle.books;
import mantle.client.SmallFontRenderer;
import net.minecraft.util.ResourceLocation;
import org.w3c.dom.Document;
public class BookData
{
public class BookData {
public String unlocalizedName = new String();
public String toolTip = new String();
public String modID = new String();
@@ -14,18 +15,16 @@ public class BookData
public ResourceLocation rightImage = new ResourceLocation("mantle", "textures/gui/bookright.png");
public ResourceLocation itemImage = new ResourceLocation("mantle", "textures/items/mantlebook_blue.png");
public Document doc = ManualReader.readManual("/assets/mantle/manuals/test.xml");
//font can be left null if so, the default from mantle will be used
// font can be left null if so, the default from mantle will be used
public SmallFontRenderer font;
public Boolean isTranslatable = false;
public boolean isFromZip = false;
public Document getDoc ()
{
public Document getDoc() {
return this.doc;
}
public String getFullUnlocalizedName ()
{
public String getFullUnlocalizedName() {
return this.modID + ":" + this.unlocalizedName;
}
+14 -20
View File
@@ -5,47 +5,41 @@ import java.util.List;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Lists;
public class BookDataStore
{
public class BookDataStore {
private static HashBiMap<String, BookData> data = HashBiMap.create();
private static HashBiMap<Integer, String> intMap = HashBiMap.create();
private static List<String> zipBooks= Lists.newArrayList();
public static void addBook (BookData bd)
{
private static List<String> zipBooks = Lists.newArrayList();
public static void addBook(BookData bd) {
int insertOrder = data.size();
data.put(bd.getFullUnlocalizedName(), bd);
intMap.put(insertOrder, bd.getFullUnlocalizedName());
if(bd.isFromZip)
zipBooks.add(bd.getFullUnlocalizedName());
if (bd.isFromZip) zipBooks.add(bd.getFullUnlocalizedName());
}
public static BookData getBookfromName (String ModID, String unlocalizedName)
{
public static BookData getBookfromName(String ModID, String unlocalizedName) {
return getBookFromName(ModID + ":" + unlocalizedName);
}
public static BookData getBookFromName (String fullBookName)
{
public static BookData getBookFromName(String fullBookName) {
return data.get(fullBookName);
}
public static BookData getBookfromID (int bookIDNum)
{
public static BookData getBookfromID(int bookIDNum) {
return data.get(intMap.get(bookIDNum));
}
public static int getIDFromName (String FullUnlocalizedName)
{
public static int getIDFromName(String FullUnlocalizedName) {
return intMap.inverse().get(FullUnlocalizedName);
}
public static int getIDFromBook (BookData b)
{
public static int getIDFromBook(BookData b) {
return getIDFromName(data.inverse().get(b));
}
public static List<String> getZipBooks(){
public static List<String> getZipBooks() {
return zipBooks;
}
}
+9 -16
View File
@@ -11,37 +11,30 @@ import mantle.Mantle;
import org.w3c.dom.Document;
public class ManualReader
{
public static Document readManual (String location)
{
public class ManualReader {
public static Document readManual(String location) {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
try
{
try {
logger.info("Loading Manual XML from: " + location);
InputStream stream = Mantle.class.getResourceAsStream(location);
return readManual(stream, location);
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static Document readManual (InputStream is, String filenameOrLocation)
{
public static Document readManual(InputStream is, String filenameOrLocation) {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
try
{
try {
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(is);
doc.getDocumentElement().normalize();
return doc;
}
catch (Exception e)
{
} catch (Exception e) {
logger.error("Failed to Load Manual XML from: " + filenameOrLocation);
e.printStackTrace();
return null;
@@ -4,6 +4,7 @@ import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.ResourceLocation;
public class BookImage {
public int height, width;
public DynamicTexture texture;
public ResourceLocation resource;
+5 -6
View File
@@ -1,11 +1,11 @@
package mantle.books.external;
public class BookIS
{
//users chosen nickname for this specific itemstack
public class BookIS {
// users chosen nickname for this specific itemstack
public String cname;
//fully qualified name from the game registry for the item/block in question
// fully qualified name from the game registry for the item/block in question
public String fullISName;
public int metadata;
@@ -14,8 +14,7 @@ public class BookIS
public int stackSize;
public int getStackSize ()
{
public int getStackSize() {
return stackSize >= 0 ? stackSize : 1;
}
+12 -13
View File
@@ -2,19 +2,18 @@ package mantle.books.external;
import com.google.gson.JsonObject;
public class BookLoad
{
public String unlocalizedName;
public String tooltip;
public boolean translatable;
public String BookIcon;
public String LeftImage;
public String rightImage;
public BookIS[] registerItemStacks;
public JsonObject[] smallRecipes;
public JsonObject[] largeRecipes;
public JsonObject[] furnaceRecipes;
public JsonObject[] manualIcons;
public class BookLoad {
public String unlocalizedName;
public String tooltip;
public boolean translatable;
public String BookIcon;
public String LeftImage;
public String rightImage;
public BookIS[] registerItemStacks;
public JsonObject[] smallRecipes;
public JsonObject[] largeRecipes;
public JsonObject[] furnaceRecipes;
public JsonObject[] manualIcons;
}
+78 -108
View File
@@ -1,5 +1,7 @@
package mantle.books.external;
import static mantle.lib.CoreRepo.logger;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Enumeration;
@@ -9,12 +11,12 @@ import java.util.zip.ZipFile;
import javax.imageio.ImageIO;
import static mantle.lib.CoreRepo.logger;
import mantle.books.BookData;
import mantle.books.BookDataStore;
import mantle.books.ManualReader;
import mantle.books.client.BookImage;
import mantle.lib.client.MantleClientRegistry;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture;
@@ -36,12 +38,11 @@ import com.google.gson.JsonObject;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
public class ZipLoader
{
public class ZipLoader {
public static Map<String, ItemStack> loadedIS = Maps.newHashMap();
public static BookData loadZip (File f)
{
public static BookData loadZip(File f) {
BookLoad bl;
String flName = new String();
String flExt = new String();
@@ -53,130 +54,104 @@ public class ZipLoader
Boolean translatable = false;
BookData b = new BookData();
boolean isClient = FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT;
if (f.exists())
{
if (FilenameUtils.getExtension(f.getPath()).equalsIgnoreCase("zip"))
{
try
{
if (f.exists()) {
if (FilenameUtils.getExtension(f.getPath()).equalsIgnoreCase("zip")) {
try {
logger.info("Loading book zip " + f.getName());
ZipFile zipfile = new ZipFile(f);
Enumeration<? extends ZipEntry> e = zipfile.entries();
while (e.hasMoreElements())
{
while (e.hasMoreElements()) {
ZipEntry entry = e.nextElement();
flName = entry.getName();
flExt = FilenameUtils.getExtension(flName);
if (!entry.isDirectory())
{
if (isClient && isImage(flExt))
{
if (!entry.isDirectory()) {
if (isClient && isImage(flExt)) {
String id = FilenameUtils.getBaseName(flName);
BufferedImage img = ImageIO.read(zipfile.getInputStream(entry));
DynamicTexture dynTexture = new DynamicTexture(img);
ResourceLocation rsLoc = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation(id, dynTexture);
ResourceLocation rsLoc = Minecraft.getMinecraft().getTextureManager()
.getDynamicTextureLocation(id, dynTexture);
BookImage bI = new BookImage(img.getWidth(), img.getHeight(), dynTexture, rsLoc);
MantleClientRegistry.imageCache.put(id, bI);
}
if (flExt.equalsIgnoreCase("xml"))
{
if (flExt.equalsIgnoreCase("xml")) {
b.doc = ManualReader.readManual(zipfile.getInputStream(entry), flName);
}
if (flExt.equalsIgnoreCase("lang"))
{
//TODO 1.7 put this data into the vanilla lang stuffs
if (flExt.equalsIgnoreCase("lang")) {
// TODO 1.7 put this data into the vanilla lang stuffs
}
if (flExt.equalsIgnoreCase("json"))
{
if (flExt.equalsIgnoreCase("json")) {
Gson g = new Gson();
bl = g.fromJson(IOUtils.toString(zipfile.getInputStream(entry), Charsets.UTF_8), BookLoad.class);
for (BookIS bis : bl.registerItemStacks)
{
try
{
bl = g.fromJson(
IOUtils.toString(zipfile.getInputStream(entry), Charsets.UTF_8),
BookLoad.class);
for (BookIS bis : bl.registerItemStacks) {
try {
ItemStack is = loadedIS.get(bis.cname);
if (is == null)
{
if (is == null) {
Block blok = (Block) Block.blockRegistry.getObject(bis.cname);
Item it = (Item) Item.itemRegistry.getObject(bis.cname);
if (it != null)
{
if (it != null) {
is = new ItemStack(it, bis.getStackSize(), bis.metadata);
}
else if (bl != null)
{
else if (bl != null) {
is = new ItemStack(blok, bis.getStackSize(), bis.metadata);
}
if (is != null)
{
if (bis.tags != null && !bis.tags.isEmpty())
{
try
{
is.stackTagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(bis.tags);
}
catch (Exception e1)
{
}
if (is != null) {
if (bis.tags != null && !bis.tags.isEmpty()) {
try {
is.stackTagCompound = (NBTTagCompound) JsonToNBT
.func_150315_a(bis.tags);
} catch (Exception e1) {}
}
loadedIS.put(bis.cname, is);
}
}
}
catch (Exception e1)
{
}
} catch (Exception e1) {}
}
if (isClient)
{
for (JsonObject jso : bl.smallRecipes)
{
if (jso != null)
{
if (isClient) {
for (JsonObject jso : bl.smallRecipes) {
if (jso != null) {
ItemStack out = loadedIS.get(jso.get("out").getAsString());
ItemStack in[] = getISArray(jso.getAsJsonArray("in"));
String name = jso.get("name").getAsString();
if (out != null && in != null && in.length <= 4 && name != null && !name.isEmpty())
{
if (out != null && in != null
&& in.length <= 4
&& name != null
&& !name.isEmpty()) {
MantleClientRegistry.registerManualSmallRecipe(name, out, in);
}
}
}
for (JsonObject jso : bl.largeRecipes)
{
if (jso != null)
{
for (JsonObject jso : bl.largeRecipes) {
if (jso != null) {
ItemStack out = loadedIS.get(jso.get("out").getAsString());
ItemStack in[] = getISArray(jso.getAsJsonArray("in"));
String name = jso.get("name").getAsString();
if (out != null && in != null && in.length <= 9 && name != null && !name.isEmpty())
{
if (out != null && in != null
&& in.length <= 9
&& name != null
&& !name.isEmpty()) {
MantleClientRegistry.registerManualLargeRecipe(name, out, in);
}
}
}
for (JsonObject jso : bl.furnaceRecipes)
{
if (jso != null)
{
for (JsonObject jso : bl.furnaceRecipes) {
if (jso != null) {
ItemStack out = loadedIS.get(jso.get("out").getAsString());
ItemStack in = loadedIS.get(jso.get("in").getAsString());
String name = jso.get("name").getAsString();
if (out != null && in != null && name != null && !name.isEmpty())
{
if (out != null && in != null && name != null && !name.isEmpty()) {
MantleClientRegistry.registerManualFurnaceRecipe(name, out, in);
}
}
}
for (JsonObject jso : bl.manualIcons)
{
if (jso != null)
{
for (JsonObject jso : bl.manualIcons) {
if (jso != null) {
ItemStack in = loadedIS.get(jso.get("stack").getAsString());
String name = jso.get("name").getAsString();
if (in != null && name != null && !name.isEmpty())
{
if (in != null && name != null && !name.isEmpty()) {
MantleClientRegistry.registerManualIcon(name, in);
}
}
@@ -185,10 +160,14 @@ public class ZipLoader
b.unlocalizedName = bl.unlocalizedName;
b.toolTip = bl.tooltip;
b.isTranslatable = bl.translatable;
b.leftImage = bl.LeftImage == null ? new ResourceLocation("mantle", "textures/gui/bookleft.png") : MantleClientRegistry.getBookImageFromCache(bl.LeftImage).resource;
b.rightImage = bl.rightImage == null ? new ResourceLocation("mantle", "textures/gui/bookright.png")
b.leftImage = bl.LeftImage == null
? new ResourceLocation("mantle", "textures/gui/bookleft.png")
: MantleClientRegistry.getBookImageFromCache(bl.LeftImage).resource;
b.rightImage = bl.rightImage == null
? new ResourceLocation("mantle", "textures/gui/bookright.png")
: MantleClientRegistry.getBookImageFromCache(bl.rightImage).resource;
b.itemImage = bl.BookIcon == null ? new ResourceLocation("mantle", "textures/items/mantlebook_blue.png")
b.itemImage = bl.BookIcon == null
? new ResourceLocation("mantle", "textures/items/mantlebook_blue.png")
: MantleClientRegistry.getBookImageFromCache(bl.BookIcon).resource;
b.isFromZip = true;
BookDataStore.addBook(b);
@@ -200,54 +179,45 @@ public class ZipLoader
b.unlocalizedName = unlocName;
b.toolTip = toolTip;
b.isTranslatable = translatable;
b.leftImage = lImg == null ? new ResourceLocation("mantle", "textures/gui/bookleft.png") : MantleClientRegistry.getBookImageFromCache(lImg).resource;
b.rightImage = rImg == null ? new ResourceLocation("mantle", "textures/gui/bookright.png") : MantleClientRegistry.getBookImageFromCache(rImg).resource;
b.itemImage = bIcon == null ? new ResourceLocation("mantle", "textures/items/mantlebook_blue.png") : MantleClientRegistry.getBookImageFromCache(bIcon).resource;
b.leftImage = lImg == null ? new ResourceLocation("mantle", "textures/gui/bookleft.png")
: MantleClientRegistry.getBookImageFromCache(lImg).resource;
b.rightImage = rImg == null ? new ResourceLocation("mantle", "textures/gui/bookright.png")
: MantleClientRegistry.getBookImageFromCache(rImg).resource;
b.itemImage = bIcon == null ? new ResourceLocation("mantle", "textures/items/mantlebook_blue.png")
: MantleClientRegistry.getBookImageFromCache(bIcon).resource;
b.isFromZip = true;
BookDataStore.addBook(b);
}
catch (Exception e)
{
} catch (Exception e) {
logger.info(" Error Loading book zip " + f.getName());
}
return null;
} else {
logger.error(
"Attempted to load non-zip file for mantle book. File " + f.getName() + " will be skipped");
}
else
{
logger.error("Attempted to load non-zip file for mantle book. File " + f.getName() + " will be skipped");
}
}
else
{
} else {
logger.error("Attempted to load non-existant file for mantle book. File will be skipped");
}
return null;
}
public static boolean isImage (String ext)
{
if (ext.equalsIgnoreCase("png"))
return true;
public static boolean isImage(String ext) {
if (ext.equalsIgnoreCase("png")) return true;
return false;
}
public static ItemStack[] getISArray (JsonArray a)
{
public static ItemStack[] getISArray(JsonArray a) {
ItemStack[] is = new ItemStack[a.size()];
ItemStack loadedStack;
for (int i = 0; i < a.size(); i++)
{
if (a.get(i).getAsString() != null && !a.get(i).getAsString().isEmpty() && a.get(i).getAsString().equals("none"))
{
for (int i = 0; i < a.size(); i++) {
if (a.get(i).getAsString() != null && !a.get(i).getAsString().isEmpty()
&& a.get(i).getAsString().equals("none")) {
is[i] = null;
}
else
{
} else {
loadedStack = loadedIS.get(a.get(i).getAsString());
if (loadedStack == null)
{
if (loadedStack == null) {
is = null;
return is;
}
+20 -29
View File
@@ -19,49 +19,46 @@ import mantle.client.pages.SidebarPage;
import mantle.client.pages.TextPage;
import mantle.client.pages.TitlePage;
import mantle.common.MProxyCommon;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class MProxyClient extends MProxyCommon
{
public class MProxyClient extends MProxyCommon {
public static final String MINECRAFT_ASCII_PATH = "minecraft:textures/font/ascii.png";
public static SmallFontRenderer smallFontRenderer;
/* Registers any rendering code. */
public void registerRenderer ()
{
public void registerRenderer() {
Minecraft mc = Minecraft.getMinecraft();
if (mc.getTextureManager() == null)
logger.error("Vanilla texture manager is null!");
if (mc.renderEngine == null)
logger.error("Vanilla render engine is null!");
smallFontRenderer = new SmallFontRenderer(mc.gameSettings, new ResourceLocation(MINECRAFT_ASCII_PATH), mc.renderEngine, false);
if (mc.getTextureManager() == null) logger.error("Vanilla texture manager is null!");
if (mc.renderEngine == null) logger.error("Vanilla render engine is null!");
smallFontRenderer = new SmallFontRenderer(
mc.gameSettings,
new ResourceLocation(MINECRAFT_ASCII_PATH),
mc.renderEngine,
false);
}
public static Map<String, Class<? extends BookPage>> pageClasses = new HashMap<String, Class<? extends BookPage>>();
public static void registerManualPage (String type, Class<? extends BookPage> clazz)
{
public static void registerManualPage(String type, Class<? extends BookPage> clazz) {
pageClasses.put(type, clazz);
}
public static Class<? extends BookPage> getPageClass (String type)
{
public static Class<? extends BookPage> getPageClass(String type) {
return pageClasses.get(type);
}
public void readManuals ()
{
public void readManuals() {
initManualPages();
}
void initManualPages ()
{
void initManualPages() {
MProxyClient.registerManualPage("crafting", CraftingPage.class);
MProxyClient.registerManualPage("picture", PicturePage.class);
MProxyClient.registerManualPage("text", TextPage.class);
@@ -75,27 +72,21 @@ public class MProxyClient extends MProxyCommon
}
@Override
public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
if (ID == manualGuiID)
{
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == manualGuiID) {
ItemStack stack = player.getCurrentEquippedItem();
if (stack == null)
logger.error("Null stack in book.");
if (stack != null && stack.getItem() == null)
logger.error("Null item in book.");
if (stack == null) logger.error("Null stack in book.");
if (stack != null && stack.getItem() == null) logger.error("Null item in book.");
if (stack != null && stack.getItem() != null && stack.getItem().getUnlocalizedName() == null)
logger.error("Null unlocalized name in book.");
else
{
else {
return new GuiManual(stack, MProxyClient.getBookDataFromStack(stack));
}
}
return null;
}
private static BookData getBookDataFromStack (ItemStack stack)
{
private static BookData getBookDataFromStack(ItemStack stack) {
return BookDataStore.getBookFromName(stack.getItem().getUnlocalizedName(stack));
}
}
+294 -289
View File
@@ -27,9 +27,10 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderItemCopy extends Render
{
private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
public class RenderItemCopy extends Render {
private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation(
"textures/misc/enchanted_item_glint.png");
private RenderBlocks itemRenderBlocks = new RenderBlocks();
/** The RNG used in RenderItem (for bobbing itemstacks on the ground) */
@@ -40,8 +41,7 @@ public class RenderItemCopy extends Render
public float zLevel;
public static boolean renderInFrame;
public RenderItemCopy()
{
public RenderItemCopy() {
this.shadowSize = 0.15F;
this.shadowOpaque = 0.75F;
}
@@ -49,17 +49,19 @@ public class RenderItemCopy extends Render
/**
* Renders the item
*/
public void doRenderItem (EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9)
{
public void doRenderItem(EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9) {
this.bindEntityTexture(par1EntityItem);
this.random.setSeed(187L);
ItemStack itemstack = par1EntityItem.getEntityItem();
if (itemstack.getItem() != null)
{
if (itemstack.getItem() != null) {
GL11.glPushMatrix();
float f2 = shouldBob() ? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F;
float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI);
float f2 = shouldBob()
? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F
+ 0.1F
: 0F;
float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart)
* (180F / (float) Math.PI);
byte b0 = getMiniBlockCount(itemstack);
GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6);
@@ -73,142 +75,136 @@ public class RenderItemCopy extends Render
block = Block.getBlockFromItem(itemstack.getItem());
if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, new RenderBlocks(), 000)) // TODO what goes here not 000
if (ForgeHooksClient.renderEntityItem(
par1EntityItem,
itemstack,
f2,
f3,
random,
renderManager.renderEngine,
new RenderBlocks(),
000)) // TODO what goes here not 000
{
;
}
else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(block.getRenderType()))
{
GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F);
} else if (itemstack.getItemSpriteNumber() == 0 && block != null
&& RenderBlocks.renderItemIn3d(block.getRenderType())) {
GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F);
if (renderInFrame)
{
GL11.glScalef(1.25F, 1.25F, 1.25F);
GL11.glTranslatef(0.0F, 0.05F, 0.0F);
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
}
float f7 = 0.25F;
int j = block.getRenderType();
if (j == 1 || j == 19 || j == 12 || j == 2)
{
f7 = 0.5F;
}
GL11.glScalef(f7, f7, f7);
for (i = 0; i < b0; ++i)
{
GL11.glPushMatrix();
if (i > 0)
{
f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
GL11.glTranslatef(f5, f4, f6);
}
f5 = 1.0F;
//TODO renderBlockAsItem
this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5);
GL11.glPopMatrix();
}
}
else
{
float f8;
if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses())
{
if (renderInFrame)
{
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
}
else
{
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k)
{
this.random.setSeed(187L);
IIcon icon = itemstack.getItem().getIcon(itemstack, k);
f8 = 1.0F;
if (this.renderWithColor)
{
i = itemstack.getItem().getColorFromItemStack(itemstack, k);
f5 = (float) (i >> 16 & 255) / 255.0F;
f4 = (float) (i >> 8 & 255) / 255.0F;
f6 = (float) (i & 255) / 255.0F;
GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F);
this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k);
if (renderInFrame) {
GL11.glScalef(1.25F, 1.25F, 1.25F);
GL11.glTranslatef(0.0F, 0.05F, 0.0F);
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
}
else
{
this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F, k);
float f7 = 0.25F;
int j = block.getRenderType();
if (j == 1 || j == 19 || j == 12 || j == 2) {
f7 = 0.5F;
}
GL11.glScalef(f7, f7, f7);
for (i = 0; i < b0; ++i) {
GL11.glPushMatrix();
if (i > 0) {
f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
GL11.glTranslatef(f5, f4, f6);
}
f5 = 1.0F;
// TODO renderBlockAsItem
this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5);
GL11.glPopMatrix();
}
} else {
float f8;
if (itemstack.getItemSpriteNumber() == 1
&& itemstack.getItem().requiresMultipleRenderPasses()) {
if (renderInFrame) {
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
} else {
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) {
this.random.setSeed(187L);
IIcon icon = itemstack.getItem().getIcon(itemstack, k);
f8 = 1.0F;
if (this.renderWithColor) {
i = itemstack.getItem().getColorFromItemStack(itemstack, k);
f5 = (float) (i >> 16 & 255) / 255.0F;
f4 = (float) (i >> 8 & 255) / 255.0F;
f6 = (float) (i & 255) / 255.0F;
GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F);
this.renderDroppedItem(
par1EntityItem,
icon,
b0,
par9,
f5 * f8,
f4 * f8,
f6 * f8,
k);
} else {
this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F, k);
}
}
} else {
if (renderInFrame) {
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
} else {
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
IIcon icon1 = itemstack.getIconIndex();
if (this.renderWithColor) {
int l = itemstack.getItem().getColorFromItemStack(itemstack, 0);
f8 = (float) (l >> 16 & 255) / 255.0F;
float f9 = (float) (l >> 8 & 255) / 255.0F;
f5 = (float) (l & 255) / 255.0F;
f4 = 1.0F;
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4);
} else {
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, 1.0F, 1.0F, 1.0F);
}
}
}
}
else
{
if (renderInFrame)
{
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
}
else
{
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
IIcon icon1 = itemstack.getIconIndex();
if (this.renderWithColor)
{
int l = itemstack.getItem().getColorFromItemStack(itemstack, 0);
f8 = (float) (l >> 16 & 255) / 255.0F;
float f9 = (float) (l >> 8 & 255) / 255.0F;
f5 = (float) (l & 255) / 255.0F;
f4 = 1.0F;
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4);
}
else
{
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, 1.0F, 1.0F, 1.0F);
}
}
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
protected ResourceLocation func_110796_a (EntityItem par1EntityItem)
{
return this.renderManager.renderEngine.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber());
protected ResourceLocation func_110796_a(EntityItem par1EntityItem) {
return this.renderManager.renderEngine
.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber());
}
/**
* Renders a dropped item
*/
private void renderDroppedItem (EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7)
{
private void renderDroppedItem(EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5,
float par6, float par7) {
renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0);
}
private void renderDroppedItem (EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass)
{
private void renderDroppedItem(EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5,
float par6, float par7, int pass) {
Tessellator tessellator = Tessellator.instance;
if (par2Icon == null)
{
if (par2Icon == null) {
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ResourceLocation resourcelocation = texturemanager.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber());
ResourceLocation resourcelocation = texturemanager
.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber());
par2Icon = ((TextureMap) texturemanager.getTexture(resourcelocation)).getAtlasSprite("missingno");
}
@@ -221,17 +217,18 @@ public class RenderItemCopy extends Render
float f10 = 0.25F;
float f11;
if (this.renderManager.options.fancyGraphics)
{
if (this.renderManager.options.fancyGraphics) {
GL11.glPushMatrix();
if (renderInFrame)
{
if (renderInFrame) {
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
}
else
{
GL11.glRotatef((((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
} else {
GL11.glRotatef(
(((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart)
* (180F / (float) Math.PI),
0.0F,
1.0F,
0.0F);
}
float f12 = 0.0625F;
@@ -242,35 +239,35 @@ public class RenderItemCopy extends Render
GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F));
for (int k = 0; k < b0; ++k)
{
for (int k = 0; k < b0; ++k) {
// Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug...
if (k > 0 && shouldSpreadItems())
{
if (k > 0 && shouldSpreadItems()) {
float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
GL11.glTranslatef(x, y, f12 + f11);
}
else
{
} else {
GL11.glTranslatef(0f, 0f, f12 + f11);
}
if (itemstack.getItemSpriteNumber() == 0)
{
if (itemstack.getItemSpriteNumber() == 0) {
this.bindTexture(TextureMap.locationBlocksTexture);
}
else
{
} else {
this.bindTexture(TextureMap.locationItemsTexture);
}
GL11.glColor4f(par5, par6, par7, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(), par2Icon.getIconHeight(), f12);
ItemRenderer.renderItemIn2D(
tessellator,
f5,
f6,
f4,
f7,
par2Icon.getIconWidth(),
par2Icon.getIconHeight(),
f12);
if (itemstack.hasEffect(pass))
{
if (itemstack.hasEffect(pass)) {
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
this.renderManager.renderEngine.bindTexture(RES_ITEM_GLINT);
@@ -302,33 +299,30 @@ public class RenderItemCopy extends Render
}
GL11.glPopMatrix();
}
else
{
for (int l = 0; l < par3; ++l)
{
} else {
for (int l = 0; l < par3; ++l) {
GL11.glPushMatrix();
if (l > 0)
{
if (l > 0) {
f11 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
GL11.glTranslatef(f11, f16, f17);
}
if (!renderInFrame)
{
if (!renderInFrame) {
GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
}
GL11.glColor4f(par5, par6, par7, 1.0F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV((double) (0.0F - f9), (double) (0.0F - f10), 0.0D, (double) f4, (double) f7);
tessellator
.addVertexWithUV((double) (0.0F - f9), (double) (0.0F - f10), 0.0D, (double) f4, (double) f7);
tessellator.addVertexWithUV((double) (f8 - f9), (double) (0.0F - f10), 0.0D, (double) f5, (double) f7);
tessellator.addVertexWithUV((double) (f8 - f9), (double) (1.0F - f10), 0.0D, (double) f5, (double) f6);
tessellator.addVertexWithUV((double) (0.0F - f9), (double) (1.0F - f10), 0.0D, (double) f4, (double) f6);
tessellator
.addVertexWithUV((double) (0.0F - f9), (double) (1.0F - f10), 0.0D, (double) f4, (double) f6);
tessellator.draw();
GL11.glPopMatrix();
}
@@ -338,22 +332,19 @@ public class RenderItemCopy extends Render
/**
* Renders the item's icon or block into the UI at the specified position.
*/
public void renderItemIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
public void renderItemIntoGUI(SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager,
ItemStack par3ItemStack, int par4, int par5) {
renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false);
}
public void renderItemIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect)
{
public void renderItemIntoGUI(SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager,
ItemStack par3ItemStack, int par4, int par5, boolean renderEffect) {
Item k = par3ItemStack.getItem();
int l;
if(k == null)
{
if (k == null) {
k = Items.iron_pickaxe;
l = 0;
}
else
{
} else {
l = par3ItemStack.getItemDamage();
}
Object object = par3ItemStack.getItem() == null ? null : par3ItemStack.getIconIndex();
@@ -363,9 +354,9 @@ public class RenderItemCopy extends Render
float f2;
Block block = Block.getBlockFromItem(k);
//TODO renderItemIn3d
if (block != null && par3ItemStack.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(block.getRenderType()))
{
// TODO renderItemIn3d
if (block != null && par3ItemStack.getItemSpriteNumber() == 0
&& RenderBlocks.renderItemIn3d(block.getRenderType())) {
par2TextureManager.bindTexture(TextureMap.locationBlocksTexture);
GL11.glPushMatrix();
GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel);
@@ -379,56 +370,51 @@ public class RenderItemCopy extends Render
f1 = (float) (i1 >> 8 & 255) / 255.0F;
f2 = (float) (i1 & 255) / 255.0F;
if (this.renderWithColor)
{
if (this.renderWithColor) {
GL11.glColor4f(f, f1, f2, 1.0F);
}
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
//TODO FIX THESE
//this.itemRenderBlocks.useInventoryTint = this.renderWithColor;
// TODO FIX THESE
// this.itemRenderBlocks.useInventoryTint = this.renderWithColor;
this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F);
//TODO FIX THESE
//this.itemRenderBlocks.useInventoryTint = true;
// TODO FIX THESE
// this.itemRenderBlocks.useInventoryTint = true;
GL11.glPopMatrix();
}
else if (k != null && k.requiresMultipleRenderPasses())
{
} else if (k != null && k.requiresMultipleRenderPasses()) {
GL11.glDisable(GL11.GL_LIGHTING);
for (int j1 = 0; j1 < k.getRenderPasses(l); ++j1)
{
par2TextureManager.bindTexture(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
for (int j1 = 0; j1 < k.getRenderPasses(l); ++j1) {
par2TextureManager.bindTexture(
par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture
: TextureMap.locationItemsTexture);
IIcon icon = k.getIcon(par3ItemStack, j1);
int k1 = k.getColorFromItemStack(par3ItemStack, j1);
f1 = (float) (k1 >> 16 & 255) / 255.0F;
f2 = (float) (k1 >> 8 & 255) / 255.0F;
float f3 = (float) (k1 & 255) / 255.0F;
if (this.renderWithColor)
{
if (this.renderWithColor) {
GL11.glColor4f(f1, f2, f3, 1.0F);
}
this.renderIcon(par4, par5, icon, 16, 16);
if (par3ItemStack.hasEffect(j1))
{
if (par3ItemStack.hasEffect(j1)) {
renderEffect(par2TextureManager, par4, par5);
}
}
GL11.glEnable(GL11.GL_LIGHTING);
}
else
{
} else {
GL11.glDisable(GL11.GL_LIGHTING);
ResourceLocation resourcelocation = par2TextureManager.getResourceLocation(par3ItemStack.getItemSpriteNumber());
ResourceLocation resourcelocation = par2TextureManager
.getResourceLocation(par3ItemStack.getItemSpriteNumber());
par2TextureManager.bindTexture(resourcelocation);
if (object == null)
{
object = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno");
if (object == null) {
object = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation))
.getAtlasSprite("missingno");
}
i1 = k.getColorFromItemStack(par3ItemStack, 0);
@@ -436,16 +422,14 @@ public class RenderItemCopy extends Render
f1 = (float) (i1 >> 8 & 255) / 255.0F;
f2 = (float) (i1 & 255) / 255.0F;
if (this.renderWithColor)
{
if (this.renderWithColor) {
GL11.glColor4f(f, f1, f2, 1.0F);
}
this.renderIcon(par4, par5, (IIcon) object, 16, 16);
GL11.glEnable(GL11.GL_LIGHTING);
if (par3ItemStack.hasEffect(0))
{
if (par3ItemStack.hasEffect(0)) {
renderEffect(par2TextureManager, par4, par5);
}
}
@@ -453,8 +437,7 @@ public class RenderItemCopy extends Render
GL11.glEnable(GL11.GL_CULL_FACE);
}
private void renderEffect (TextureManager manager, int x, int y)
{
private void renderEffect(TextureManager manager, int x, int y) {
GL11.glDepthFunc(GL11.GL_GREATER);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
@@ -474,69 +457,79 @@ public class RenderItemCopy extends Render
/**
* Render the item's icon or block into the GUI, including the glint effect.
*/
public void renderItemAndEffectIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
if (par3ItemStack != null)
{
if (!ForgeHooksClient.renderInventoryItem(new RenderBlocks(), par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5))
{
public void renderItemAndEffectIntoGUI(SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager,
ItemStack par3ItemStack, int par4, int par5) {
if (par3ItemStack != null) {
if (!ForgeHooksClient.renderInventoryItem(
new RenderBlocks(),
par2TextureManager,
par3ItemStack,
renderWithColor,
zLevel,
(float) par4,
(float) par5)) {
this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true);
}
/* Modders must handle this themselves if they use custom renderers!
if (par3ItemStack.hasEffect())
{
GL11.glDepthFunc(GL11.GL_GREATER);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
par2TextureManager.bindTexture(RES_ITEM_GLINT);
this.zLevel -= 50.0F;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
this.zLevel += 50.0F;
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
*/
/*
* Modders must handle this themselves if they use custom renderers! if (par3ItemStack.hasEffect()) {
* GL11.glDepthFunc(GL11.GL_GREATER); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false);
* par2TextureManager.bindTexture(RES_ITEM_GLINT); this.zLevel -= 50.0F; GL11.glEnable(GL11.GL_BLEND);
* GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
* this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
* GL11.glDisable(GL11.GL_BLEND); GL11.glDepthMask(true); this.zLevel += 50.0F;
* GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); }
*/
}
}
private void renderGlint (int par1, int par2, int par3, int par4, int par5)
{
for (int j1 = 0; j1 < 2; ++j1)
{
if (j1 == 0)
{
private void renderGlint(int par1, int par2, int par3, int par4, int par5) {
for (int j1 = 0; j1 < 2; ++j1) {
if (j1 == 0) {
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
}
if (j1 == 1)
{
if (j1 == 1) {
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
}
float f = 0.00390625F;
float f1 = 0.00390625F;
float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F;
float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873))
* 256.0F;
float f3 = 0.0F;
Tessellator tessellator = Tessellator.instance;
float f4 = 4.0F;
if (j1 == 1)
{
if (j1 == 1) {
f4 = -1.0F;
}
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1));
tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f),
tessellator.addVertexWithUV(
(double) (par2 + 0),
(double) (par3 + par5),
(double) this.zLevel,
(double) ((f2 + (float) par5 * f4) * f),
(double) ((f3 + (float) par5) * f1));
tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1));
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1));
tessellator.addVertexWithUV(
(double) (par2 + par4),
(double) (par3 + par5),
(double) this.zLevel,
(double) ((f2 + (float) par4 + (float) par5 * f4) * f),
(double) ((f3 + (float) par5) * f1));
tessellator.addVertexWithUV(
(double) (par2 + par4),
(double) (par3 + 0),
(double) this.zLevel,
(double) ((f2 + (float) par4) * f),
(double) ((f3 + 0.0F) * f1));
tessellator.addVertexWithUV(
(double) (par2 + 0),
(double) (par3 + 0),
(double) this.zLevel,
(double) ((f2 + 0.0F) * f),
(double) ((f3 + 0.0F) * f1));
tessellator.draw();
}
}
@@ -545,29 +538,34 @@ public class RenderItemCopy extends Render
* Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the
* specified position.
*/
public void renderItemOverlayIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
public void renderItemOverlayIntoGUI(SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager,
ItemStack par3ItemStack, int par4, int par5) {
this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String) null);
}
public void renderItemOverlayIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str)
{
if (par3ItemStack != null)
{
if (par3ItemStack.stackSize > 1 || par6Str != null)
{
public void renderItemOverlayIntoGUI(SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager,
ItemStack par3ItemStack, int par4, int par5, String par6Str) {
if (par3ItemStack != null) {
if (par3ItemStack.stackSize > 1 || par6Str != null) {
String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215);
par1FontRenderer.drawStringWithShadow(
s1,
par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1),
par5 + 6 + 3,
16777215);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
if (par3ItemStack.isItemDamaged())
{
int k = (int) Math.round(13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage());
int l = (int) Math.round(255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage());
if (par3ItemStack.isItemDamaged()) {
int k = (int) Math.round(
13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D
/ (double) par3ItemStack.getMaxDamage());
int l = (int) Math.round(
255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D
/ (double) par3ItemStack.getMaxDamage());
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
@@ -586,11 +584,10 @@ public class RenderItemCopy extends Render
}
/**
* Adds a quad to the tesselator at the specified position with the set width and height and color. Args:
* Adds a quad to the tesselator at the specified position with the set width and height and color. Args:
* tessellator, x, y, width, height, color
*/
private void renderQuad (Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6)
{
private void renderQuad(Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6) {
par1Tessellator.startDrawingQuads();
par1Tessellator.setColorOpaque_I(par6);
par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + 0), 0.0D);
@@ -600,19 +597,37 @@ public class RenderItemCopy extends Render
par1Tessellator.draw();
}
public void renderIcon (int par1, int par2, IIcon par3Icon, int par4, int par5)
{
public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV());
tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV());
tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV());
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV());
tessellator.addVertexWithUV(
(double) (par1 + 0),
(double) (par2 + par5),
(double) this.zLevel,
(double) par3Icon.getMinU(),
(double) par3Icon.getMaxV());
tessellator.addVertexWithUV(
(double) (par1 + par4),
(double) (par2 + par5),
(double) this.zLevel,
(double) par3Icon.getMaxU(),
(double) par3Icon.getMaxV());
tessellator.addVertexWithUV(
(double) (par1 + par4),
(double) (par2 + 0),
(double) this.zLevel,
(double) par3Icon.getMaxU(),
(double) par3Icon.getMinV());
tessellator.addVertexWithUV(
(double) (par1 + 0),
(double) (par2 + 0),
(double) this.zLevel,
(double) par3Icon.getMinU(),
(double) par3Icon.getMinV());
tessellator.draw();
}
protected ResourceLocation getEntityTexture (Entity par1Entity)
{
protected ResourceLocation getEntityTexture(Entity par1Entity) {
return this.func_110796_a((EntityItem) par1Entity);
}
@@ -622,58 +637,48 @@ public class RenderItemCopy extends Render
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender (Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
this.doRenderItem((EntityItem) par1Entity, par2, par4, par6, par8, par9);
}
/**
* Items should spread out when rendered in 3d?
*
* @return
*/
public boolean shouldSpreadItems ()
{
public boolean shouldSpreadItems() {
return true;
}
/**
* Items should have a bob effect
*
* @return
*/
public boolean shouldBob ()
{
public boolean shouldBob() {
return true;
}
public byte getMiniBlockCount (ItemStack stack)
{
public byte getMiniBlockCount(ItemStack stack) {
byte ret = 1;
if (stack.stackSize > 1)
ret = 2;
if (stack.stackSize > 5)
ret = 3;
if (stack.stackSize > 20)
ret = 4;
if (stack.stackSize > 40)
ret = 5;
if (stack.stackSize > 1) ret = 2;
if (stack.stackSize > 5) ret = 3;
if (stack.stackSize > 20) ret = 4;
if (stack.stackSize > 40) ret = 5;
return ret;
}
/**
* Allows for a subclass to override how many rendered items appear in a
* "mini item 3d stack"
* Allows for a subclass to override how many rendered items appear in a "mini item 3d stack"
*
* @param stack
* @return
*/
public byte getMiniItemCount (ItemStack stack)
{
public byte getMiniItemCount(ItemStack stack) {
byte ret = 1;
if (stack.stackSize > 1)
ret = 2;
if (stack.stackSize > 15)
ret = 3;
if (stack.stackSize > 31)
ret = 4;
if (stack.stackSize > 1) ret = 2;
if (stack.stackSize > 15) ret = 3;
if (stack.stackSize > 31) ret = 4;
return ret;
}
}
File diff suppressed because it is too large. Load diff
+54 -91
View File
@@ -5,6 +5,7 @@ import mantle.client.MProxyClient;
import mantle.client.RenderItemCopy;
import mantle.client.SmallFontRenderer;
import mantle.client.pages.BookPage;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
@@ -21,8 +22,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiManual extends GuiScreen
{
public class GuiManual extends GuiScreen {
ItemStack itemstackBook;
Document manual;
public RenderItemCopy renderitem = new RenderItemCopy();
@@ -43,128 +44,90 @@ public class GuiManual extends GuiScreen
public SmallFontRenderer fonts = MProxyClient.smallFontRenderer;
public GuiManual(ItemStack stack, BookData data)
{
public GuiManual(ItemStack stack, BookData data) {
this.mc = Minecraft.getMinecraft();
this.itemstackBook = stack;
currentPage = 0; //Stack page
currentPage = 0; // Stack page
manual = data.getDoc();
if (data.font != null)
this.fonts = data.font;
if (data.font != null) this.fonts = data.font;
bookLeft = data.leftImage;
bookRight = data.rightImage;
this.bData = data;
//renderitem.renderInFrame = true;
// renderitem.renderInFrame = true;
}
/*@Override
public void setWorldAndResolution (Minecraft minecraft, int w, int h)
{
this.guiParticles = new GuiParticle(minecraft);
this.mc = minecraft;
this.width = w;
this.height = h;
this.buttonList.clear();
this.initGui();
}*/
/*
* @Override public void setWorldAndResolution (Minecraft minecraft, int w, int h) { this.guiParticles = new
* GuiParticle(minecraft); this.mc = minecraft; this.width = w; this.height = h; this.buttonList.clear();
* this.initGui(); }
*/
@SuppressWarnings("unchecked")
public void initGui ()
{
public void initGui() {
maxPages = manual.getElementsByTagName("page").getLength();
updateText();
int xPos = (this.width) / 2; //TODO Width?
//TODO buttonList
int xPos = (this.width) / 2; // TODO Width?
// TODO buttonList
this.buttonList.add(this.buttonNextPage = new TurnPageButton(1, xPos + bookImageWidth - 50, 180, true, bData));
this.buttonList.add(this.buttonPreviousPage = new TurnPageButton(2, xPos - bookImageWidth + 24, 180, false, bData));
this.buttonList
.add(this.buttonPreviousPage = new TurnPageButton(2, xPos - bookImageWidth + 24, 180, false, bData));
}
protected void actionPerformed (GuiButton button)
{
if (button.enabled)
{
if (button.id == 1)
currentPage += 2;
if (button.id == 2)
currentPage -= 2;
protected void actionPerformed(GuiButton button) {
if (button.enabled) {
if (button.id == 1) currentPage += 2;
if (button.id == 2) currentPage -= 2;
updateText();
}
}
void updateText ()
{
if (maxPages % 2 == 1)
{
if (currentPage > maxPages)
currentPage = maxPages;
void updateText() {
if (maxPages % 2 == 1) {
if (currentPage > maxPages) currentPage = maxPages;
} else {
if (currentPage >= maxPages) currentPage = maxPages - 2;
}
else
{
if (currentPage >= maxPages)
currentPage = maxPages - 2;
}
if (currentPage % 2 == 1)
currentPage--;
if (currentPage < 0)
currentPage = 0;
if (currentPage % 2 == 1) currentPage--;
if (currentPage < 0) currentPage = 0;
NodeList nList = manual.getElementsByTagName("page");
Node node = nList.item(currentPage);
if (node.getNodeType() == Node.ELEMENT_NODE)
{
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
Class<? extends BookPage> clazz = MProxyClient.getPageClass(element.getAttribute("type"));
if (clazz != null)
{
try
{
if (clazz != null) {
try {
pageLeft = clazz.newInstance();
pageLeft.init(this, 0);
pageLeft.readPageFromXML(element);
}
catch (Exception e)
{
}
}
else
{
} catch (Exception e) {}
} else {
pageLeft = null;
}
}
node = nList.item(currentPage + 1);
if (node != null && node.getNodeType() == Node.ELEMENT_NODE)
{
if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
Class<? extends BookPage> clazz = MProxyClient.getPageClass(element.getAttribute("type"));
if (clazz != null)
{
try
{
if (clazz != null) {
try {
pageRight = clazz.newInstance();
pageRight.init(this, 1);
pageRight.readPageFromXML(element);
}
catch (Exception e)
{
}
}
else
{
} catch (Exception e) {}
} else {
pageLeft = null;
}
}
else
{
} else {
pageRight = null;
}
}
public void drawScreen (int par1, int par2, float par3)
{
public void drawScreen(int par1, int par2, float par3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(bookRight);
int localWidth = (this.width / 2);
@@ -174,28 +137,28 @@ public class GuiManual extends GuiScreen
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(bookLeft);
localWidth = localWidth - this.bookImageWidth;
this.drawTexturedModalRect(localWidth, localHeight, 256 - this.bookImageWidth, 0, this.bookImageWidth, this.bookImageHeight);
this.drawTexturedModalRect(
localWidth,
localHeight,
256 - this.bookImageWidth,
0,
this.bookImageWidth,
this.bookImageHeight);
super.drawScreen(par1, par2, par3); //16, 12, 220, 12
super.drawScreen(par1, par2, par3); // 16, 12, 220, 12
if (pageLeft != null)
pageLeft.renderBackgroundLayer(localWidth + 16, localHeight + 12);
if (pageRight != null)
pageRight.renderBackgroundLayer(localWidth + 220, localHeight + 12);
if (pageLeft != null)
pageLeft.renderContentLayer(localWidth + 16, localHeight + 12, bData.isTranslatable);
if (pageRight != null)
pageRight.renderContentLayer(localWidth + 220, localHeight + 12, bData.isTranslatable);
if (pageLeft != null) pageLeft.renderBackgroundLayer(localWidth + 16, localHeight + 12);
if (pageRight != null) pageRight.renderBackgroundLayer(localWidth + 220, localHeight + 12);
if (pageLeft != null) pageLeft.renderContentLayer(localWidth + 16, localHeight + 12, bData.isTranslatable);
if (pageRight != null) pageRight.renderContentLayer(localWidth + 220, localHeight + 12, bData.isTranslatable);
}
public Minecraft getMC ()
{
public Minecraft getMC() {
return mc;
}
public boolean doesGuiPauseGame ()
{
public boolean doesGuiPauseGame() {
return false;
}
}
@@ -1,7 +1,7 @@
package mantle.client.gui;
import static mantle.lib.CoreRepo.logger;
import mantle.books.BookData;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
@@ -12,16 +12,15 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class TurnPageButton extends GuiButton
{
public class TurnPageButton extends GuiButton {
/**
* True for pointing right (next page), false for pointing left (previous page).
*/
private final boolean nextPage;
private static ResourceLocation background;// = new ResourceLocation("tinker", "textures/gui/bookleft.png");
public TurnPageButton(int par1, int par2, int par3, boolean par4, BookData data)
{
public TurnPageButton(int par1, int par2, int par3, boolean par4, BookData data) {
super(par1, par2, par3, 23, 13, "");
this.nextPage = par4;
background = data.leftImage;
@@ -30,23 +29,21 @@ public class TurnPageButton extends GuiButton
/**
* Draws this button to the screen.
*/
public void drawButton (Minecraft par1Minecraft, int par2, int par3)
{
if (this.visible)
{
boolean var4 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
if (this.visible) {
boolean var4 = par2 >= this.xPosition && par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
par1Minecraft.getTextureManager().bindTexture(background);
int var5 = 0;
int var6 = 192;
if (var4)
{
if (var4) {
var5 += 23;
}
if (!this.nextPage)
{
if (!this.nextPage) {
var6 += 13;
}
@@ -2,17 +2,12 @@ package mantle.client.pages;
import org.w3c.dom.Element;
public class BlankPage extends BookPage
{
public class BlankPage extends BookPage {
@Override
public void readPageFromXML (Element element)
{
}
public void readPageFromXML(Element element) {}
@Override
public void renderContentLayer (int localwidth, int localheight, boolean isTranslatable)
{
}
public void renderContentLayer(int localwidth, int localheight, boolean isTranslatable) {}
}
@@ -4,22 +4,19 @@ import mantle.client.gui.GuiManual;
import org.w3c.dom.Element;
public abstract class BookPage
{
public abstract class BookPage {
protected GuiManual manual;
protected int side;
public void init (GuiManual manual, int side)
{
public void init(GuiManual manual, int side) {
this.manual = manual;
this.side = side;
}
public abstract void readPageFromXML (Element element);
public abstract void readPageFromXML(Element element);
public void renderBackgroundLayer (int localwidth, int localheight)
{
}
public void renderBackgroundLayer(int localwidth, int localheight) {}
public abstract void renderContentLayer (int localwidth, int localheight, boolean isTranslatable);
public abstract void renderContentLayer(int localwidth, int localheight, boolean isTranslatable);
}
@@ -1,6 +1,7 @@
package mantle.client.pages;
import mantle.lib.client.MantleClientRegistry;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
@@ -10,24 +11,21 @@ import org.lwjgl.opengl.GL12;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class ContentsTablePage extends BookPage
{
public class ContentsTablePage extends BookPage {
String text;
String[] iconText;
ItemStack[] icons;
@Override
public void readPageFromXML (Element element)
{
public void readPageFromXML(Element element) {
NodeList nodes = element.getElementsByTagName("text");
if (nodes != null)
text = nodes.item(0).getTextContent();
if (nodes != null) text = nodes.item(0).getTextContent();
nodes = element.getElementsByTagName("link");
iconText = new String[nodes.getLength()];
icons = new ItemStack[nodes.getLength()];
for (int i = 0; i < nodes.getLength(); i++)
{
for (int i = 0; i < nodes.getLength(); i++) {
NodeList children = nodes.item(i).getChildNodes();
iconText[i] = children.item(1).getTextContent();
icons[i] = MantleClientRegistry.getManualIcon(children.item(3).getTextContent());
@@ -35,26 +33,29 @@ public class ContentsTablePage extends BookPage
}
@Override
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
{
if (text != null)
{
if (isTranslatable)
text = StatCollector.translateToLocal(text);
manual.fonts.drawString("\u00a7n" + text, localWidth + 25 + manual.fonts.getStringWidth(text) / 2, localHeight + 4, 0);
public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) {
if (text != null) {
if (isTranslatable) text = StatCollector.translateToLocal(text);
manual.fonts.drawString(
"\u00a7n" + text,
localWidth + 25 + manual.fonts.getStringWidth(text) / 2,
localHeight + 4,
0);
}
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
manual.renderitem.zLevel = 100;
for (int i = 0; i < icons.length; i++)
{
manual.renderitem.renderItemIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 16, localHeight + 18 * i + 18);
for (int i = 0; i < icons.length; i++) {
manual.renderitem.renderItemIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[i],
localWidth + 16,
localHeight + 18 * i + 18);
int yOffset = 18;
if (isTranslatable)
iconText[i] = StatCollector.translateToLocal(iconText[i]);
if (isTranslatable) iconText[i] = StatCollector.translateToLocal(iconText[i]);
if (iconText[i].length() > 40)
yOffset = 13;
if (iconText[i].length() > 40) yOffset = 13;
manual.fonts.drawString(iconText[i], localWidth + 38, localHeight + 18 * i + yOffset, 0);
}
manual.renderitem.zLevel = 0;
@@ -1,6 +1,7 @@
package mantle.client.pages;
import mantle.lib.client.MantleClientRegistry;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@@ -11,70 +12,84 @@ import org.lwjgl.opengl.GL12;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class CraftingPage extends BookPage
{
public class CraftingPage extends BookPage {
String text;
String size;
ItemStack[] icons;
@Override
public void readPageFromXML (Element element)
{
public void readPageFromXML(Element element) {
NodeList nodes = element.getElementsByTagName("text");
if (nodes != null)
text = nodes.item(0).getTextContent();
if (nodes != null) text = nodes.item(0).getTextContent();
nodes = element.getElementsByTagName("name");
if (nodes != null)
icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent());
if (nodes != null) icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent());
nodes = element.getElementsByTagName("size");
if (nodes != null)
size = nodes.item(0).getTextContent();
if (nodes != null) size = nodes.item(0).getTextContent();
}
@Override
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
{
if (isTranslatable)
text = StatCollector.translateToLocal(text);
if (size.equals("two"))
drawCraftingPage(text, icons, 2, localWidth, localHeight + 12);
if (size.equals("three"))
drawCraftingPage(text, icons, 3, localWidth + (side != 1 ? 6 : 0), localHeight + 12);
public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) {
if (isTranslatable) text = StatCollector.translateToLocal(text);
if (size.equals("two")) drawCraftingPage(text, icons, 2, localWidth, localHeight + 12);
if (size.equals("three")) drawCraftingPage(text, icons, 3, localWidth + (side != 1 ? 6 : 0), localHeight + 12);
}
public void drawCraftingPage (String info, ItemStack[] icons, int recipeSize, int localWidth, int localHeight)
{
if (info != null)
manual.fonts.drawString("\u00a7n" + info, localWidth + 50, localHeight + 4, 0);
public void drawCraftingPage(String info, ItemStack[] icons, int recipeSize, int localWidth, int localHeight) {
if (info != null) manual.fonts.drawString("\u00a7n" + info, localWidth + 50, localHeight + 4, 0);
GL11.glScalef(2f, 2f, 2f);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
manual.renderitem.zLevel = 100;
if (recipeSize == 2)
{
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2);
if (icons[0].stackSize > 1)
manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize));
for (int i = 0; i < icons.length - 1; i++)
{
if (icons[i + 1] != null)
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i + 1], (localWidth + 14 + 36 * (i % 2)) / 2, (localHeight + 36 * (i / 2) + 52) / 2);
if (recipeSize == 2) {
manual.renderitem.renderItemAndEffectIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[0],
(localWidth + 126) / 2,
(localHeight + 68) / 2);
if (icons[0].stackSize > 1) manual.renderitem.renderItemOverlayIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[0],
(localWidth + 126) / 2,
(localHeight + 68) / 2,
String.valueOf(icons[0].stackSize));
for (int i = 0; i < icons.length - 1; i++) {
if (icons[i + 1] != null) manual.renderitem.renderItemAndEffectIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[i + 1],
(localWidth + 14 + 36 * (i % 2)) / 2,
(localHeight + 36 * (i / 2) + 52) / 2);
}
}
if (recipeSize == 3)
{
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 138) / 2, (localHeight + 70) / 2);
if (icons[0].stackSize > 1)
manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize));
for (int i = 0; i < icons.length - 1; i++)
{
if (icons[i + 1] != null)
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i + 1], (localWidth - 2 + 36 * (i % 3)) / 2, (localHeight + 36 * (i / 3) + 34) / 2);
if (recipeSize == 3) {
manual.renderitem.renderItemAndEffectIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[0],
(localWidth + 138) / 2,
(localHeight + 70) / 2);
if (icons[0].stackSize > 1) manual.renderitem.renderItemOverlayIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[0],
(localWidth + 126) / 2,
(localHeight + 68) / 2,
String.valueOf(icons[0].stackSize));
for (int i = 0; i < icons.length - 1; i++) {
if (icons[i + 1] != null) manual.renderitem.renderItemAndEffectIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[i + 1],
(localWidth - 2 + 36 * (i % 3)) / 2,
(localHeight + 36 * (i / 3) + 34) / 2);
}
}
@@ -84,24 +99,18 @@ public class CraftingPage extends BookPage
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
public void renderBackgroundLayer (int localwidth, int localheight)
{
if (size.equals("two"))
drawBackground(2, localwidth, localheight + 12);
public void renderBackgroundLayer(int localwidth, int localheight) {
if (size.equals("two")) drawBackground(2, localwidth, localheight + 12);
if (size.equals("three"))
drawBackground(3, localwidth + (side != 1 ? 6 : 0), localheight + 12);
if (size.equals("three")) drawBackground(3, localwidth + (side != 1 ? 6 : 0), localheight + 12);
}
private static final ResourceLocation background = new ResourceLocation("mantle", "textures/gui/bookcrafting.png");
public void drawBackground (int size, int localWidth, int localHeight)
{
public void drawBackground(int size, int localWidth, int localHeight) {
manual.getMC().getTextureManager().bindTexture(background);
if (size == 2)
manual.drawTexturedModalRect(localWidth + 8, localHeight + 46, 0, 116, 154, 78);
if (size == 3)
manual.drawTexturedModalRect(localWidth - 8, localHeight + 28, 0, 0, 183, 114);
if (size == 2) manual.drawTexturedModalRect(localWidth + 8, localHeight + 46, 0, 116, 154, 78);
if (size == 3) manual.drawTexturedModalRect(localWidth - 8, localHeight + 28, 0, 0, 183, 114);
}
}
@@ -1,6 +1,7 @@
package mantle.client.pages;
import mantle.lib.client.MantleClientRegistry;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@@ -11,30 +12,24 @@ import org.lwjgl.opengl.GL12;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class FurnacePage extends BookPage
{
public class FurnacePage extends BookPage {
String text;
ItemStack[] icons;
@Override
public void readPageFromXML (Element element)
{
public void readPageFromXML(Element element) {
NodeList nodes = element.getElementsByTagName("text");
if (nodes != null)
text = nodes.item(0).getTextContent();
if (nodes != null) text = nodes.item(0).getTextContent();
nodes = element.getElementsByTagName("recipe");
if (nodes != null)
icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent());
if (nodes != null) icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent());
}
@Override
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
{
if (text != null)
{
if (isTranslatable)
text = StatCollector.translateToLocal(text);
public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) {
if (text != null) {
if (isTranslatable) text = StatCollector.translateToLocal(text);
manual.fonts.drawString("\u00a7n" + text, localWidth + 50, localHeight + 4, 0);
}
GL11.glScalef(2f, 2f, 2f);
@@ -42,12 +37,32 @@ public class FurnacePage extends BookPage
RenderHelper.enableGUIStandardItemLighting();
manual.renderitem.zLevel = 100;
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, MantleClientRegistry.getManualIcon("coal"), (localWidth + 38) / 2, (localHeight + 110) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[1], (localWidth + 38) / 2, (localHeight + 38) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
MantleClientRegistry.getManualIcon("coal"),
(localWidth + 38) / 2,
(localHeight + 110) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[0],
(localWidth + 106) / 2,
(localHeight + 74) / 2);
manual.renderitem.renderItemAndEffectIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[1],
(localWidth + 38) / 2,
(localHeight + 38) / 2);
if (icons[0].stackSize > 1)
manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(icons[0].stackSize));
if (icons[0].stackSize > 1) manual.renderitem.renderItemOverlayIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[0],
(localWidth + 106) / 2,
(localHeight + 74) / 2,
String.valueOf(icons[0].stackSize));
manual.renderitem.zLevel = 0;
GL11.glScalef(0.5F, 0.5F, 0.5F);
@@ -57,8 +72,7 @@ public class FurnacePage extends BookPage
private static final ResourceLocation background = new ResourceLocation("mantle", "textures/gui/bookfurnace.png");
public void renderBackgroundLayer (int localWidth, int localHeight)
{
public void renderBackgroundLayer(int localWidth, int localHeight) {
manual.getMC().getTextureManager().bindTexture(background);
manual.drawTexturedModalRect(localWidth + 32, localHeight + 32, 0, 0, 111, 114);
}
@@ -1,63 +1,53 @@
package mantle.client.pages;
import mantle.lib.client.MantleClientRegistry;
import static mantle.lib.CoreRepo.logger;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import static mantle.lib.CoreRepo.logger;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class PicturePage extends BookPage
{
public class PicturePage extends BookPage {
String text;
String location;
ResourceLocation background;
@Override
public void readPageFromXML (Element element)
{
public void readPageFromXML(Element element) {
NodeList nodes = element.getElementsByTagName("text");
if (nodes != null)
text = nodes.item(0).getTextContent();
if (nodes != null) text = nodes.item(0).getTextContent();
nodes = element.getElementsByTagName("location");
if (nodes != null)
{
if (nodes != null) {
location = nodes.item(0).getTextContent();
background = new ResourceLocation(location);
if(background == null)
{
if (background == null) {
logger.warn(nodes.item(0).getTextContent() + " could not be found in the image cache(location)!");
}
}
//this borked stuffs somehow unless someone is interested in using it this stays disabled for now
/* nodes = element.getElementsByTagName("bookImage");
if (nodes != null)
{
//TODO 1.7 null check all of this
background = MantleClientRegistry.imageCache.get(nodes.item(0).getTextContent()).resource;
if(background == null){
logger.warn(nodes.item(0).getTextContent() + " could not be found in the image cache(bookimage)!");
}
}*/
// this borked stuffs somehow unless someone is interested in using it this stays disabled for now
/*
* nodes = element.getElementsByTagName("bookImage"); if (nodes != null) { //TODO 1.7 null check all of this
* background = MantleClientRegistry.imageCache.get(nodes.item(0).getTextContent()).resource; if(background ==
* null){ logger.warn(nodes.item(0).getTextContent() + " could not be found in the image cache(bookimage)!"); }
* }
*/
}
@Override
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
{
if (isTranslatable)
text = StatCollector.translateToLocal(text);
public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) {
if (isTranslatable) text = StatCollector.translateToLocal(text);
manual.fonts.drawSplitString(text, localWidth + 8, localHeight, 178, 0);
}
public void renderBackgroundLayer (int localWidth, int localHeight)
{
if (background != null)
{
public void renderBackgroundLayer(int localWidth, int localHeight) {
if (background != null) {
manual.getMC().getTextureManager().bindTexture(background);
}
//manual.getMC().renderEngine.bindTexture(location);
// manual.getMC().renderEngine.bindTexture(location);
manual.drawTexturedModalRect(localWidth, localHeight + 12, 0, 0, 170, 144);
}
}
@@ -5,28 +5,23 @@ import net.minecraft.util.StatCollector;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class SectionPage extends BookPage
{
public class SectionPage extends BookPage {
String title;
String body;
@Override
public void readPageFromXML (Element element)
{
public void readPageFromXML(Element element) {
NodeList nodes = element.getElementsByTagName("title");
if (nodes != null)
title = nodes.item(0).getTextContent();
if (nodes != null) title = nodes.item(0).getTextContent();
nodes = element.getElementsByTagName("text");
if (nodes != null)
body = nodes.item(0).getTextContent();
if (nodes != null) body = nodes.item(0).getTextContent();
}
@Override
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
{
if (isTranslatable)
{
public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) {
if (isTranslatable) {
title = StatCollector.translateToLocal(title);
body = StatCollector.translateToLocal(body);
}
@@ -1,6 +1,7 @@
package mantle.client.pages;
import mantle.lib.client.MantleClientRegistry;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
@@ -10,24 +11,21 @@ import org.lwjgl.opengl.GL12;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class SidebarPage extends BookPage
{
public class SidebarPage extends BookPage {
String text;
String[] iconText;
ItemStack[] icons;
@Override
public void readPageFromXML (Element element)
{
public void readPageFromXML(Element element) {
NodeList nodes = element.getElementsByTagName("text");
if (nodes != null)
text = nodes.item(0).getTextContent();
if (nodes != null) text = nodes.item(0).getTextContent();
nodes = element.getElementsByTagName("item");
iconText = new String[nodes.getLength()];
icons = new ItemStack[nodes.getLength()];
for (int i = 0; i < nodes.getLength(); i++)
{
for (int i = 0; i < nodes.getLength(); i++) {
NodeList children = nodes.item(i).getChildNodes();
iconText[i] = children.item(1).getTextContent();
icons[i] = MantleClientRegistry.getManualIcon(children.item(3).getTextContent());
@@ -35,10 +33,8 @@ public class SidebarPage extends BookPage
}
@Override
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
{
if (isTranslatable)
{
public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) {
if (isTranslatable) {
text = StatCollector.translateToLocal(text);
}
manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0);
@@ -46,16 +42,18 @@ public class SidebarPage extends BookPage
RenderHelper.enableGUIStandardItemLighting();
manual.renderitem.zLevel = 100;
int offset = text.length() / 4 + 10;
for (int i = 0; i < icons.length; i++)
{
if (isTranslatable)
{
for (int i = 0; i < icons.length; i++) {
if (isTranslatable) {
iconText[i] = StatCollector.translateToLocal(iconText[i]);
}
manual.renderitem.renderItemIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 8, localHeight + 18 * i + offset);
manual.renderitem.renderItemIntoGUI(
manual.fonts,
manual.getMC().renderEngine,
icons[i],
localWidth + 8,
localHeight + 18 * i + offset);
int yOffset = 39;
if (iconText[i].length() > 40)
yOffset = 34;
if (iconText[i].length() > 40) yOffset = 34;
manual.fonts.drawSplitString(iconText[i], localWidth + 30, localHeight + 18 * i + offset, 140, 0);
}
manual.renderitem.zLevel = 0;
@@ -5,23 +5,19 @@ import net.minecraft.util.StatCollector;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class TextPage extends BookPage
{
public class TextPage extends BookPage {
String text;
@Override
public void readPageFromXML (Element element)
{
public void readPageFromXML(Element element) {
NodeList nodes = element.getElementsByTagName("text");
if (nodes != null)
text = nodes.item(0).getTextContent();
if (nodes != null) text = nodes.item(0).getTextContent();
}
@Override
public void renderContentLayer (int localWidth, int localHeight, boolean IsTranslatable)
{
if (IsTranslatable)
text = StatCollector.translateToLocal(text);
public void renderContentLayer(int localWidth, int localHeight, boolean IsTranslatable) {
if (IsTranslatable) text = StatCollector.translateToLocal(text);
manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0);
}
}
@@ -5,23 +5,19 @@ import net.minecraft.util.StatCollector;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class TitlePage extends BookPage
{
public class TitlePage extends BookPage {
String text;
@Override
public void readPageFromXML (Element element)
{
public void readPageFromXML(Element element) {
NodeList nodes = element.getElementsByTagName("text");
if (nodes != null)
text = nodes.item(0).getTextContent();
if (nodes != null) text = nodes.item(0).getTextContent();
}
@Override
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
{
if (isTranslatable)
text = StatCollector.translateToLocal(text);
public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) {
if (isTranslatable) text = StatCollector.translateToLocal(text);
manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0);
}
}
@@ -4,25 +4,21 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ComparisonHelper
{
public static boolean areEquivalent (Item item, Block block)
{
public class ComparisonHelper {
public static boolean areEquivalent(Item item, Block block) {
return item == Item.getItemFromBlock(block);
}
public static boolean areEquivalent (Block block1, Block block2)
{
public static boolean areEquivalent(Block block1, Block block2) {
return block1 == block2;
}
public static boolean areEquivalent (Item item1, Item item2)
{
public static boolean areEquivalent(Item item1, Item item2) {
return item1.equals(item2);
}
public static boolean areEquivalent (ItemStack is1, ItemStack is2)
{
return is1.getItem() == is2.getItem();
public static boolean areEquivalent(ItemStack is1, ItemStack is2) {
return is1.getItem() == is2.getItem();
}
}
+14 -21
View File
@@ -1,41 +1,34 @@
package mantle.common;
import static mantle.lib.CoreRepo.logger;
import mantle.lib.CoreConfig;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.potion.Potion;
import net.minecraft.world.biome.BiomeGenBase;
public class IDDumps
{
public static void dump(){
if (CoreConfig.dumpBiomeIDs)
{
for (BiomeGenBase b : BiomeGenBase.getBiomeGenArray())
{
if (b != null && b.biomeName != null)
{
public class IDDumps {
public static void dump() {
if (CoreConfig.dumpBiomeIDs) {
for (BiomeGenBase b : BiomeGenBase.getBiomeGenArray()) {
if (b != null && b.biomeName != null) {
logger.info("Biome ID & Name: " + b.biomeID + " " + b.biomeName);
}
}
}
if (CoreConfig.dumpPotionIDs)
{
for (Potion p : Potion.potionTypes)
{
if (p != null && p.getName() != null)
{
if (CoreConfig.dumpPotionIDs) {
for (Potion p : Potion.potionTypes) {
if (p != null && p.getName() != null) {
logger.info("Potion ID & name: " + p.getId() + " " + p.getName());
}
}
}
if (CoreConfig.dumpEnchantIDs)
{
for (Enchantment e : Enchantment.enchantmentsList)
{
if (e != null && e.getName() != null)
{
if (CoreConfig.dumpEnchantIDs) {
for (Enchantment e : Enchantment.enchantmentsList) {
if (e != null && e.getName() != null) {
logger.info("Enchantment ID & name: " + e.effectId + " " + e.getName());
}
+8 -14
View File
@@ -2,31 +2,25 @@ package mantle.common;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
public class MProxyCommon implements IGuiHandler
{
public class MProxyCommon implements IGuiHandler {
public static int manualGuiID = -1;
@Override
public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
if (ID < 0)
return null;
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID < 0) return null;
return null;
}
@Override
public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
public void registerRenderer ()
{
}
public void registerRenderer() {}
public void readManuals ()
{
}
public void readManuals() {}
}
@@ -1,57 +1,48 @@
package mantle.common.network;
import net.minecraft.entity.player.EntityPlayer;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.entity.player.EntityPlayer;
/**
* AbstractPacket class. Should be the parent of all packets wishing to use the
* PacketPipeline.
* AbstractPacket class. Should be the parent of all packets wishing to use the PacketPipeline.
*
* @author sirgingalot
*/
public abstract class AbstractPacket
{
public abstract class AbstractPacket {
/**
* Encode the packet data into the ByteBuf stream. Complex data sets may
* need specific data handlers (See
* Encode the packet data into the ByteBuf stream. Complex data sets may need specific data handlers (See
*
* @link{cpw.mods.fml.common.network.ByteBuffUtils})
*
* @param ctx
* channel context
* @param buffer
* the buffer to encode into
* @param ctx channel context
* @param buffer the buffer to encode into
*/
public abstract void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer);
public abstract void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer);
/**
* Decode the packet data from the ByteBuf stream. Complex data sets may
* need specific data handlers (See
* Decode the packet data from the ByteBuf stream. Complex data sets may need specific data handlers (See
*
* @link{cpw.mods.fml.common.network.ByteBuffUtils})
*
* @param ctx
* channel context
* @param buffer
* the buffer to decode from
* @param ctx channel context
* @param buffer the buffer to decode from
*/
public abstract void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer);
public abstract void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer);
/**
* Handle a packet on the client side. Note this occurs after decoding has
* completed.
* Handle a packet on the client side. Note this occurs after decoding has completed.
*
* @param player
* the player reference
* @param player the player reference
*/
public abstract void handleClientSide (EntityPlayer player);
public abstract void handleClientSide(EntityPlayer player);
/**
* Handle a packet on the server side. Note this occurs after decoding has
* completed.
* Handle a packet on the server side. Note this occurs after decoding has completed.
*
* @param player
* the player reference
* @param player the player reference
*/
public abstract void handleServerSide (EntityPlayer player);
public abstract void handleServerSide(EntityPlayer player);
}
@@ -1,24 +1,23 @@
package mantle.common.network;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
public class PacketUpdateTE extends AbstractPacket
{
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
public class PacketUpdateTE extends AbstractPacket {
private int x, y, z;
private NBTTagCompound data;
public PacketUpdateTE()
{
public PacketUpdateTE() {
}
public PacketUpdateTE(int x, int y, int z, NBTTagCompound data)
{
public PacketUpdateTE(int x, int y, int z, NBTTagCompound data) {
this.x = x;
this.y = y;
this.z = z;
@@ -26,53 +25,41 @@ public class PacketUpdateTE extends AbstractPacket
}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
PacketBuffer pbuff = new PacketBuffer(buffer);
pbuff.writeInt(x);
pbuff.writeShort(y);
pbuff.writeInt(z);
try
{
try {
pbuff.writeNBTTagCompoundToBuffer(data);
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
PacketBuffer pbuff = new PacketBuffer(buffer);
x = pbuff.readInt();
y = pbuff.readShort();
z = pbuff.readInt();
try
{
try {
data = pbuff.readNBTTagCompoundFromBuffer();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void handleClientSide (EntityPlayer player)
{
public void handleClientSide(EntityPlayer player) {
TileEntity te = player.worldObj.getTileEntity(x, y, z);
if (te != null)
{
if (te != null) {
te.readFromNBT(data);
}
}
@Override
public void handleServerSide (EntityPlayer player)
{
}
public void handleServerSide(EntityPlayer player) {}
}
@@ -7,25 +7,21 @@ import cpw.mods.fml.common.ICrashCallable;
*
* @author Sunstrike <[email protected]>
*/
public class CallableSuppConfig implements ICrashCallable
{
public class CallableSuppConfig implements ICrashCallable {
private String modId;
public CallableSuppConfig(String modId)
{
public CallableSuppConfig(String modId) {
this.modId = modId;
}
@Override
public String call () throws Exception
{
public String call() throws Exception {
return "Environment healthy.";
}
@Override
public String getLabel ()
{
public String getLabel() {
return modId + " Environment";
}
@@ -5,31 +5,26 @@ import java.util.List;
import cpw.mods.fml.common.ICrashCallable;
// Crash handler for when an unsupported mod is running alongside us
public class CallableUnsuppConfig implements ICrashCallable
{
public class CallableUnsuppConfig implements ICrashCallable {
private String modId;
private List<String> modIds;
public CallableUnsuppConfig(String modId, List<String> modIds)
{
public CallableUnsuppConfig(String modId, List<String> modIds) {
this.modId = modId;
this.modIds = modIds;
}
@Override
public String getLabel ()
{
public String getLabel() {
return modId + " Environment";
}
@Override
public String call () throws Exception
{
public String call() throws Exception {
String str = "DO NOT REPORT THIS CRASH! Unsupported mods in environment: ";
Boolean firstEntry = true;
for (String id : modIds)
{
for (String id : modIds) {
str = str + (firstEntry ? id : ", " + id);
firstEntry = false;
}
@@ -37,4 +32,4 @@ public class CallableUnsuppConfig implements ICrashCallable
return str;
}
}
}
+4 -5
View File
@@ -7,16 +7,15 @@ import net.minecraft.entity.player.EntityPlayer;
*
* @author Sunstrike <[email protected]>
*/
public class DebugData
{
public class DebugData {
public final EntityPlayer player;
@SuppressWarnings("rawtypes") public final Class cl;
@SuppressWarnings("rawtypes")
public final Class cl;
public final String[] strings;
@SuppressWarnings("rawtypes")
public DebugData(EntityPlayer player, Class cl, String[] strings)
{
public DebugData(EntityPlayer player, Class cl, String[] strings) {
this.player = player;
this.cl = cl;
this.strings = strings;
+11 -18
View File
@@ -3,7 +3,9 @@ package mantle.debug;
import static mantle.lib.CoreConfig.debug_enableChat;
import static mantle.lib.CoreConfig.debug_enableConsole;
import static mantle.lib.CoreRepo.logger;
import mantle.player.PlayerUtils;
import net.minecraft.entity.player.EntityPlayer;
/**
@@ -11,38 +13,29 @@ import net.minecraft.entity.player.EntityPlayer;
*
* @author Sunstrike <[email protected]>
*/
public class DebugHelper
{
public class DebugHelper {
private DebugHelper()
{
private DebugHelper() {
// No instantiation
}
public static void handleDebugData (DebugData data)
{
if (debug_enableChat)
handleChatDebug(data);
if (debug_enableConsole)
handleConsoleDebug(data);
public static void handleDebugData(DebugData data) {
if (debug_enableChat) handleChatDebug(data);
if (debug_enableConsole) handleConsoleDebug(data);
}
private static void handleChatDebug (DebugData data)
{
private static void handleChatDebug(DebugData data) {
EntityPlayer player = data.player;
String prefix = "[" + data.cl.getSimpleName() + "] ";
for (String str : data.strings)
{
for (String str : data.strings) {
PlayerUtils.sendChatMessage(player, prefix + str);
}
}
private static void handleConsoleDebug (DebugData data)
{
private static void handleConsoleDebug(DebugData data) {
String player = data.player.getGameProfile().getName();
String prefix = "[" + player + ":" + data.cl.getSimpleName() + "] ";
for (String str : data.strings)
{
for (String str : data.strings) {
logger.info(prefix + str);
}
}
+2 -3
View File
@@ -9,9 +9,8 @@ import net.minecraft.entity.player.EntityPlayer;
*
* @author Sunstrike <[email protected]>
*/
public interface IDebuggable
{
public interface IDebuggable {
public DebugData getDebugInfo (EntityPlayer player);
public DebugData getDebugInfo(EntityPlayer player);
}
+20 -17
View File
@@ -1,28 +1,31 @@
package mantle.event;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.eventhandler.Event;
public abstract class ManualOpenEvent extends Event {
public ItemStack bookStack;
public EntityPlayer player;
public ItemStack bookStack;
public EntityPlayer player;
public ManualOpenEvent(ItemStack book, EntityPlayer player) {
this.bookStack = book;
this.player = player;
}
public ManualOpenEvent(ItemStack book, EntityPlayer player) {
this.bookStack = book;
this.player = player;
}
public static class Pre extends ManualOpenEvent {
public Pre(ItemStack book, EntityPlayer player) {
super(book, player);
}
}
public static class Pre extends ManualOpenEvent {
public static class Post extends ManualOpenEvent {
public Post(ItemStack book, EntityPlayer player) {
super(book, player);
}
}
public Pre(ItemStack book, EntityPlayer player) {
super(book, player);
}
}
public static class Post extends ManualOpenEvent {
public Post(ItemStack book, EntityPlayer player) {
super(book, player);
}
}
}
+37 -42
View File
@@ -1,18 +1,22 @@
package mantle.event;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import static mantle.lib.CoreRepo.logger;
import java.util.List;
import java.util.Map;
public abstract class Migration
{
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
public abstract class Migration {
Map<String, Item> remapItem = Maps.newHashMap();
Map<String, Block> remapBlock = Maps.newHashMap();
List<String> ignore = Lists.newArrayList();
@@ -23,66 +27,57 @@ public abstract class Migration
/*
* Store the mod ID so we can convert e.g "item" to "mod:item" later.
*/
public Migration(ModContainer m)
{
public Migration(ModContainer m) {
mod = m;
modID = m.getModId();
}
/*
* Add a new migration to the internal replacement map e.g. "olditem" -> "newitem" (without ID prefix!).
* Use an encapsulated object of form Map<String,Item> to store this.
* The prefix will be created using the ID given during construction during processing.
* Add a new migration to the internal replacement map e.g. "olditem" -> "newitem" (without ID prefix!). Use an
* encapsulated object of form Map<String,Item> to store this. The prefix will be created using the ID given during
* construction during processing.
*/
public void addMigration (String old, Item newItem)
{
public void addMigration(String old, Item newItem) {
remapItem.put(modID + ":" + old, newItem);
}
/*
* Add a new migration to the internal replacement map e.g. "olditem" -> "newitem" (without ID prefix!).
* Use an encapsulated object of form Map<String,Block> to store this.
* The prefix will be created using the ID given during construction during processing.
*/
public void addMigration (String old, Block newBlock)
{
* Add a new migration to the internal replacement map e.g. "olditem" -> "newitem" (without ID prefix!). Use an
* encapsulated object of form Map<String,Block> to store this. The prefix will be created using the ID given during
* construction during processing.
*/
public void addMigration(String old, Block newBlock) {
remapBlock.put(modID + ":" + old, newBlock);
}
/*
* Register an old ID that's been removed entirely. This isn't suitable for renaming operations!
* Store this in a List<String> seperate to the rename mapping.
* Register an old ID that's been removed entirely. This isn't suitable for renaming operations! Store this in a
* List<String> seperate to the rename mapping.
* @param id ID to be removed (without ID prefix!).
*/
public void addRemoval (String id)
{
public void addRemoval(String id) {
ignore.add(modID + ":" + id);
};
/*
* This must be called from your mod's main class as it requires @EventHandler notation
* This works on the assumption the FML event will have a list of string IDs that are missing.
* During this phase, check for old IDs and remap as needed, or destroy ones marked for removal.
* This must be called from your mod's main class as it requires @EventHandler notation This works on the assumption
* the FML event will have a list of string IDs that are missing. During this phase, check for old IDs and remap as
* needed, or destroy ones marked for removal.
*/
public void processMigrationEvent (FMLMissingMappingsEvent event) {
public void processMigrationEvent(FMLMissingMappingsEvent event) {
if ((!remapBlock.isEmpty() || !remapItem.isEmpty())) {
event.applyModContainer(mod);
List<MissingMapping> l = event.get();
if(l != null)
{
if (l != null) {
for (MissingMapping miss : event.get()) {
if (remapItem.containsKey(miss.name))
miss.remap(remapItem.get(miss.name));
else if (remapBlock.containsKey(miss.name))
miss.remap(remapBlock.get(miss.name));
else if (ignore.contains(miss.name))
miss.ignore();
if (remapItem.containsKey(miss.name)) miss.remap(remapItem.get(miss.name));
else if (remapBlock.containsKey(miss.name)) miss.remap(remapBlock.get(miss.name));
else if (ignore.contains(miss.name)) miss.ignore();
}
}
else
{
} else {
logger.error("migration list from FML empty for mod " + modID);
}
}
}
}
}
+6 -6
View File
@@ -1,16 +1,16 @@
package mantle.items;
import net.minecraft.item.Item;
import cpw.mods.fml.common.registry.GameData;
public class ItemUtils
{
public static String getUniqueName (Item item)
{
public class ItemUtils {
public static String getUniqueName(Item item) {
return GameData.getItemRegistry().getNameForObject(item);
}
public static Item getItemFromUniqueName (String uniqueName)
{
public static Item getItemFromUniqueName(String uniqueName) {
return GameData.getItemRegistry().getObject(uniqueName);
}
}
+20 -25
View File
@@ -1,52 +1,49 @@
package mantle.items;
import net.minecraftforge.common.MinecraftForge;
import mantle.event.ManualOpenEvent;
import java.util.List;
import mantle.Mantle;
import mantle.books.BookDataStore;
import mantle.event.ManualOpenEvent;
import mantle.items.abstracts.CraftingItem;
import mantle.lib.CoreRepo;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Manual extends CraftingItem
{
public class Manual extends CraftingItem {
public final String modID;
static String[] name = new String[] { "beginner", "toolstation", "smeltery", "diary" };
static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery", "tinkerbook_blue" };
static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery",
"tinkerbook_blue" };
public Manual()
{
public Manual() {
super(name, textureName, "", "mantle", null);
modID = CoreRepo.modId;
}
public void updateManual ()
{
public void updateManual() {
updateData(new String[] { "test" }, new String[] { "mantlebook_blue" }, "", "mantle");
}
public Manual(String[] name, String[] textureName, String folder, String modTexturePrefix, CreativeTabs tab, String modID)
{
public Manual(String[] name, String[] textureName, String folder, String modTexturePrefix, CreativeTabs tab,
String modID) {
super(name, textureName, "", "mantle", tab);
this.modID = modID;
}
@Override
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
{
ManualOpenEvent.Pre preOpenEvent = new ManualOpenEvent.Pre(stack, player);
MinecraftForge.EVENT_BUS.post(preOpenEvent);
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
ManualOpenEvent.Pre preOpenEvent = new ManualOpenEvent.Pre(stack, player);
MinecraftForge.EVENT_BUS.post(preOpenEvent);
player.openGui(Mantle.instance, mantle.client.MProxyClient.manualGuiID, world, 0, 0, 0);
ManualOpenEvent.Post postOpenEvent = new ManualOpenEvent.Post(stack, player);
@@ -57,21 +54,19 @@ public class Manual extends CraftingItem
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({"unchecked", "rawtypes"})
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
{
list.add("\u00a7o" + StatCollector.translateToLocal(BookDataStore.getBookfromID(stack.getItemDamage()).toolTip));
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
list.add(
"\u00a7o" + StatCollector.translateToLocal(BookDataStore.getBookfromID(stack.getItemDamage()).toolTip));
}
@Override
public String getUnlocalizedName ()
{
public String getUnlocalizedName() {
return modID + ":" + super.getUnlocalizedName();
}
@Override
public String getUnlocalizedName (ItemStack par1ItemStack)
{
public String getUnlocalizedName(ItemStack par1ItemStack) {
return super.getUnlocalizedName(par1ItemStack);
}
}
@@ -8,23 +8,22 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CraftingItem extends Item
{
public class CraftingItem extends Item {
public String modTexPrefix;
public String[] textureNames;
public String[] unlocalizedNames;
public String folder;
public IIcon[] icons;
public CraftingItem(String[] names, String[] tex, String folder, String modTexturePrefix, CreativeTabs tab)
{
public CraftingItem(String[] names, String[] tex, String folder, String modTexturePrefix, CreativeTabs tab) {
super();
this.modTexPrefix = modTexturePrefix;
if (tab != null)
{
if (tab != null) {
this.setCreativeTab(tab);
}
this.setMaxDamage(0);
@@ -34,8 +33,7 @@ public class CraftingItem extends Item
this.folder = folder;
}
public void updateData (String[] names, String[] tex, String folder, String modTexturePrefix)
{
public void updateData(String[] names, String[] tex, String folder, String modTexturePrefix) {
this.modTexPrefix = modTexturePrefix;
this.textureNames = tex;
this.unlocalizedNames = names;
@@ -43,39 +41,32 @@ public class CraftingItem extends Item
}
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage (int meta)
{
public IIcon getIconFromDamage(int meta) {
int arr = MathHelper.clamp_int(meta, 0, unlocalizedNames.length);
if(arr >= icons.length)
return icons[0];
if (arr >= icons.length) return icons[0];
return icons[arr];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IIconRegister iconRegister)
{
public void registerIcons(IIconRegister iconRegister) {
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
for (int i = 0; i < this.icons.length; ++i) {
if (!(textureNames[i].equals("")))
this.icons[i] = iconRegister.registerIcon(modTexPrefix + ":" + folder + textureNames[i]);
}
}
public String getUnlocalizedName (ItemStack stack)
{
public String getUnlocalizedName(ItemStack stack) {
int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, unlocalizedNames.length);
return getUnlocalizedName() + "." + unlocalizedNames[arr];
}
@SuppressWarnings({"unchecked","rawtypes"})
public void getSubItems (Item b, CreativeTabs tab, List list)
{
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item b, CreativeTabs tab, List list) {
for (int i = 0; i < unlocalizedNames.length; i++)
if (!(textureNames[i].equals("")))
list.add(new ItemStack(b, 1, i));
if (!(textureNames[i].equals(""))) list.add(new ItemStack(b, 1, i));
}
}
@@ -1,6 +1,6 @@
package mantle.items.iface;
public interface IDebugItem
{
// Will do more later; this is here for now to enable mods to use the debug stick functionality with their own debug items/tools.
public interface IDebugItem {
// Will do more later; this is here for now to enable mods to use the debug stick functionality with their own debug
// items/tools.
}
+28 -33
View File
@@ -6,11 +6,12 @@ import static mantle.lib.CoreRepo.modId;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FilenameUtils;
import mantle.books.external.ZipLoader;
import net.minecraftforge.common.config.Configuration;
import org.apache.commons.io.FilenameUtils;
/**
* Mantle configuration handler
*
@@ -18,8 +19,8 @@ import net.minecraftforge.common.config.Configuration;
*
* @author Sunstrike <[email protected]>
*/
public class CoreConfig
{
public class CoreConfig {
static Configuration config;
public static File configFolder;
@@ -28,62 +29,57 @@ public class CoreConfig
*
* @param mainConfigFolder Configuration folder (as a Java File)
*/
public static void loadConfiguration (File mainConfigFolder)
{
public static void loadConfiguration(File mainConfigFolder) {
logger.info("Loading configuration from disk.");
try
{
try {
configFolder = new File(mainConfigFolder.getCanonicalPath(), "SlimeKnights");
if (!configFolder.exists())
configFolder.mkdirs();
}
catch (IOException e)
{
if (!configFolder.exists()) configFolder.mkdirs();
} catch (IOException e) {
logger.error("Error getting/creating Mantle configuration directory: " + e.getMessage());
}
config = new Configuration(new File(configFolder, (modId + ".cfg")));
config.load();
silenceEnvChecks = config.get("Environment", "unsupportedLogging", silenceEnvChecks).getBoolean(silenceEnvChecks);
silenceEnvChecks = config.get("Environment", "unsupportedLogging", silenceEnvChecks)
.getBoolean(silenceEnvChecks);
debug_enableConsole = config.get("DebugHelpers", "enableConsole", debug_enableConsole).getBoolean(debug_enableConsole);
debug_enableConsole = config.get("DebugHelpers", "enableConsole", debug_enableConsole)
.getBoolean(debug_enableConsole);
debug_enableChat = config.get("DebugHelpers", "enableChat", debug_enableChat).getBoolean(debug_enableChat);
dumpBiomeIDs = config.get("DebugHelpers", "Dump BIOME ID's in log", dumpBiomeIDs).getBoolean(dumpBiomeIDs);
dumpPotionIDs = config.get("DebugHelpers", "Dump POTION ID's in log", dumpPotionIDs).getBoolean(dumpPotionIDs);
dumpEnchantIDs = config.get("DebugHelpers", "Dump ENCHANT ID's in log", dumpEnchantIDs).getBoolean(dumpEnchantIDs);
dumpRecipeConflicts = config.get("DebugHelpers", "Dump Recipe Conflicts in log when server starts",dumpRecipeConflicts).getBoolean(dumpRecipeConflicts);
dumpEnchantIDs = config.get("DebugHelpers", "Dump ENCHANT ID's in log", dumpEnchantIDs)
.getBoolean(dumpEnchantIDs);
dumpRecipeConflicts = config
.get("DebugHelpers", "Dump Recipe Conflicts in log when server starts", dumpRecipeConflicts)
.getBoolean(dumpRecipeConflicts);
//check for debugging overrides in system environment
// check for debugging overrides in system environment
checkSysOverrides();
if(config.hasChanged())
config.save();
if (config.hasChanged()) config.save();
logger.info("Configuration load completed.");
}
/**
* Checks for MANTLE_DBGCONSOLE/CHAT config overrides in system environment for compile time testing, and other dev work.
* Checks for MANTLE_DBGCONSOLE/CHAT config overrides in system environment for compile time testing, and other dev
* work.
**/
private static void checkSysOverrides ()
{
if (System.getenv("MANTLE_DBGCONSOLE") != null)
{
private static void checkSysOverrides() {
if (System.getenv("MANTLE_DBGCONSOLE") != null) {
debug_enableConsole = true;
logger.info("Mantle Console debugging override enabled via system properties.");
}
if (System.getenv("MANTLE_DBGCHAT") != null)
{
if (System.getenv("MANTLE_DBGCHAT") != null) {
debug_enableChat = true;
logger.info("Mantle Chat debugging override enabled via system properties.");
}
}
public static void loadBookLocations ()
{
for (File f : configFolder.listFiles())
{
if(f.isFile() && FilenameUtils.getExtension(f.getAbsolutePath()).equalsIgnoreCase("zip"))
public static void loadBookLocations() {
for (File f : configFolder.listFiles()) {
if (f.isFile() && FilenameUtils.getExtension(f.getAbsolutePath()).equalsIgnoreCase("zip"))
ZipLoader.loadZip(f);
}
}
@@ -100,5 +96,4 @@ public class CoreConfig
public static boolean dumpEnchantIDs = false;
public static boolean dumpRecipeConflicts = false;
}
+1 -2
View File
@@ -10,8 +10,7 @@ import org.apache.logging.log4j.Logger;
*
* @author Sunstrike <[email protected]>
*/
public final class CoreRepo
{
public final class CoreRepo {
public static final String modId = "GRADLETOKEN_MODID";
public static final String modName = "GRADLETOKEN_MODNAME";
+7 -11
View File
@@ -4,27 +4,23 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class TabTools extends CreativeTabs
{
public class TabTools extends CreativeTabs {
ItemStack display;
public TabTools(String label)
{
public TabTools(String label) {
super(label);
}
public void init (ItemStack stack)
{
public void init(ItemStack stack) {
display = stack;
}
public ItemStack getIconItemStack ()
{
public ItemStack getIconItemStack() {
return display;
}
public Item getTabIconItem ()
{
public Item getTabIconItem() {
return display.getItem();
}
}
}
@@ -3,64 +3,57 @@ package mantle.lib.client;
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.Maps;
import mantle.books.client.BookImage;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
public class MantleClientRegistry
{
import com.google.common.collect.Maps;
public class MantleClientRegistry {
public static Map<String, ItemStack> manualIcons = Maps.newHashMap();
public static Map<String, ItemStack[]> recipeIcons = Maps.newHashMap();
public static HashMap<String, BookImage> imageCache = Maps.newHashMap();
public static ItemStack defaultStack = new ItemStack(Items.iron_ingot);
public static BookImage getBookImageFromCache (String s)
{
public static BookImage getBookImageFromCache(String s) {
return imageCache.get(s);
}
public static void registerManualIcon (String name, ItemStack stack)
{
public static void registerManualIcon(String name, ItemStack stack) {
manualIcons.put(name, stack);
}
public static ItemStack getManualIcon (String textContent)
{
public static ItemStack getManualIcon(String textContent) {
ItemStack stack = manualIcons.get(textContent);
if (stack != null)
return stack;
if (stack != null) return stack;
return defaultStack;
}
public static void registerManualSmallRecipe (String name, ItemStack output, ItemStack... stacks)
{
public static void registerManualSmallRecipe(String name, ItemStack output, ItemStack... stacks) {
ItemStack[] recipe = new ItemStack[5];
recipe[0] = output;
System.arraycopy(stacks, 0, recipe, 1, 4);
recipeIcons.put(name, recipe);
}
public static void registerManualLargeRecipe (String name, ItemStack output, ItemStack... stacks)
{
public static void registerManualLargeRecipe(String name, ItemStack output, ItemStack... stacks) {
ItemStack[] recipe = new ItemStack[10];
recipe[0] = output;
System.arraycopy(stacks, 0, recipe, 1, 9);
recipeIcons.put(name, recipe);
}
public static void registerManualFurnaceRecipe (String name, ItemStack output, ItemStack input)
{
public static void registerManualFurnaceRecipe(String name, ItemStack output, ItemStack input) {
ItemStack[] recipe = new ItemStack[2];
recipe[0] = output;
recipe[1] = input;
recipeIcons.put(name, recipe);
}
public static ItemStack[] getRecipeIcons (String recipeName)
{
public static ItemStack[] getRecipeIcons(String recipeName) {
return recipeIcons.get(recipeName);
}
@@ -22,55 +22,44 @@ import cpw.mods.fml.relauncher.Side;
*
* @author Sunstrike <[email protected]>
*/
public class EnvironmentChecks
{
public class EnvironmentChecks {
private EnvironmentChecks()
{
} // Singleton
private EnvironmentChecks() {} // Singleton
// Usable by other mods to detect Optifine.
public static boolean hasOptifine = false;
/**
* Checks for conflicting stuff in environment; adds callable to any crash logs if so.
* Note: This code adds additional data to crashlogs. It does not trigger any crashes.
* Checks for conflicting stuff in environment; adds callable to any crash logs if so. Note: This code adds
* additional data to crashlogs. It does not trigger any crashes.
*/
@SuppressWarnings("rawtypes")
public static void verifyEnvironmentSanity ()
{
public static void verifyEnvironmentSanity() {
List<String> modIds = new ArrayList<String>();
if (FMLCommonHandler.instance().getSide() == Side.CLIENT && FMLClientHandler.instance().hasOptifine() || Loader.isModLoaded("optifine"))
{
if (!CoreConfig.silenceEnvChecks)
logger.error("[Environment Checks] Optifine detected. This may cause issues due to base edits or ASM usage.");
if (FMLCommonHandler.instance().getSide() == Side.CLIENT && FMLClientHandler.instance().hasOptifine()
|| Loader.isModLoaded("optifine")) {
if (!CoreConfig.silenceEnvChecks) logger.error(
"[Environment Checks] Optifine detected. This may cause issues due to base edits or ASM usage.");
hasOptifine = true;
modIds.add("optifine");
}
try
{
try {
Class cl = Class.forName("org.bukkit.Bukkit");
if (cl != null)
{
if (!CoreConfig.silenceEnvChecks)
logger.error("[Environment Checks] Bukkit implementation detected. This may cause issues. Bukkit implementations include Craftbukkit and Cauldron(MCPC+).");
if (cl != null) {
if (!CoreConfig.silenceEnvChecks) logger.error(
"[Environment Checks] Bukkit implementation detected. This may cause issues. Bukkit implementations include Craftbukkit and Cauldron(MCPC+).");
modIds.add("bukkit");
}
}
catch (Exception ex)
{
} catch (Exception ex) {
// No Bukkit in environment.
}
if (modIds.size() == 0)
{
if (modIds.size() == 0) {
ICrashCallable callable = new CallableSuppConfig(modId);
FMLCommonHandler.instance().registerCrashCallable(callable);
}
else
{
} else {
ICrashCallable callable = new CallableUnsuppConfig(modId, modIds);
FMLCommonHandler.instance().registerCrashCallable(callable);
}
+34 -43
View File
@@ -10,76 +10,67 @@ package mantle.math;
import java.util.LinkedList;
public class Dozenal
{
public class Dozenal {
@SuppressWarnings("unused")
public static String convertToDozenal (byte i)
{
public static String convertToDozenal(byte i) {
return convertDecimal(i);
}
@SuppressWarnings("unused")
public static String convertToDozenal (short i)
{
public static String convertToDozenal(short i) {
return convertDecimal(i);
}
@SuppressWarnings("unused")
public static String convertToDozenal (int i)
{
public static String convertToDozenal(int i) {
return convertDecimal(i);
}
public static String convertDecimal (int i)
{
public static String convertDecimal(int i) {
int num = i;
LinkedList<Character> list = new LinkedList<Character>();
while (num > 0)
{
while (num > 0) {
list.add(getDozenalCharacter(num % 12));
num /= 12;
}
StringBuilder builder = new StringBuilder();
for (int iter = list.size() - 1; iter > 0; iter--)
{
for (int iter = list.size() - 1; iter > 0; iter--) {
builder.append(list.get(iter));
}
return builder.toString();
}
public static char getDozenalCharacter (int i)
{
public static char getDozenalCharacter(int i) {
assert i < 12 : "Base 10 number should be less than 12";
switch (i)
{
case 0:
return '0'; //Zero
case 1:
return '1'; //One
case 2:
return '2'; //Two
case 3:
return '3'; //Three
case 4:
return '4'; //Four
case 5:
return '5'; //Five
case 6:
return '6'; //Six
case 7:
return '7'; //Seven
case 8:
return '8'; //Eight
case 9:
return '9'; //Nine
case 10:
return 'X'; //Dec
case 11:
return 'E'; //El
switch (i) {
case 0:
return '0'; // Zero
case 1:
return '1'; // One
case 2:
return '2'; // Two
case 3:
return '3'; // Three
case 4:
return '4'; // Four
case 5:
return '5'; // Five
case 6:
return '6'; // Six
case 7:
return '7'; // Seven
case 8:
return '8'; // Eight
case 9:
return '9'; // Nine
case 10:
return 'X'; // Dec
case 11:
return 'E'; // El
}
return 'Q';
}
}
}
@@ -3,16 +3,16 @@ package mantle.module;
/**
* Interface for modules for dealing with other mods.
*
* Note that all ILoadableModule's should have a static String field "modId" which contains the mod ID of the mod it supports.
* This is accessed by reflection because Java is dumb and has no statics in interfaces.
* Note that all ILoadableModule's should have a static String field "modId" which contains the mod ID of the mod it
* supports. This is accessed by reflection because Java is dumb and has no statics in interfaces.
*
* @author Arkan <[email protected]>
*/
@Deprecated //See Pulsar package for replacement
@Deprecated // See Pulsar package for replacement
public interface ILoadableModule {
// Example modId field
//public static String modId = "ExampleMod";
// public static String modId = "ExampleMod";
// Called during PreInit
public abstract void preInit();
@@ -23,4 +23,4 @@ public interface ILoadableModule {
// Called during PostInit
public abstract void postInit();
}
}
@@ -1,24 +1,30 @@
package mantle.module;
import cpw.mods.fml.common.Loader;
import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.util.ArrayList;
import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import cpw.mods.fml.common.Loader;
/**
* Controller for mod compat modules.
*
* @author Sunstrike <[email protected]>
* @author Arkan Emberwalker <[email protected]>
*/
@Deprecated //See PulseManager for replacement
@Deprecated // See PulseManager for replacement
public class ModuleController {
private enum State {
WAITING, PREINIT, INIT, POSTINIT, DONE
WAITING,
PREINIT,
INIT,
POSTINIT,
DONE
}
private ArrayList<ILoadableModule> modules = new ArrayList<ILoadableModule>();
@@ -41,11 +47,12 @@ public class ModuleController {
* Constructor for a config-using plugin loader
*
* @param confName The name for the configuration file (should end in .cfg)
* @param modName The human-readable name of the invoking mod. Used for logger construction.
* @param modName The human-readable name of the invoking mod. Used for logger construction.
*/
public ModuleController(String confName, String modName) {
this.logger = LogManager.getLogger(modName + "-ModuleController");
this.config = new Configuration(new File(Loader.instance().getConfigDir().toString() + File.separator + confName));
this.config = new Configuration(
new File(Loader.instance().getConfigDir().toString() + File.separator + confName));
}
/**
@@ -102,8 +109,8 @@ public class ModuleController {
/**
* Unchecked handler for registering a module forcefully.
*
* This version bypasses any config test; use registerModule where possible. This is only intended for modules
* the user is not allowed to configure (e.g. Mystcraft blacklist plugins).
* This version bypasses any config test; use registerModule where possible. This is only intended for modules the
* user is not allowed to configure (e.g. Mystcraft blacklist plugins).
*
* @param mod The module to attempt to register.
* @return True on success, false on error.
@@ -119,7 +126,7 @@ public class ModuleController {
private String getModId(Class<? extends ILoadableModule> mod) {
String mID;
try {
mID = (String)mod.getField("modId").get(null);
mID = (String) mod.getField("modId").get(null);
} catch (Exception e) {
logger.error("Module loading failed for class " + mod + "; modId field may be missing.");
return null;
@@ -177,4 +184,4 @@ public class ModuleController {
return true;
}
}
}
+2 -4
View File
@@ -8,14 +8,12 @@ import net.minecraft.util.ChatComponentText;
*
* @author progwml6
*/
public class PlayerUtils
{
public class PlayerUtils {
/**
* Sends a given message to a specific player (due to 1.7 axing addChatMessage())
*/
public static void sendChatMessage (EntityPlayer p, String message)
{
public static void sendChatMessage(EntityPlayer p, String message) {
if (p != null && message != null && !message.isEmpty())
p.addChatComponentMessage(new ChatComponentText(message));
}
@@ -1,16 +1,19 @@
package mantle.pulsar.config;
import cpw.mods.fml.common.Loader;
import mantle.pulsar.pulse.PulseMeta;
import net.minecraftforge.common.config.Configuration;
import java.io.*;
import mantle.pulsar.pulse.PulseMeta;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.common.Loader;
/**
* Mantle specific pulsar addon class to support using the forge CFG format for configurations
*
* @author progwml6
*/
public class ForgeCFG implements IConfiguration{
public class ForgeCFG implements IConfiguration {
private static Configuration config;
private final String confPath;
@@ -21,7 +24,7 @@ public class ForgeCFG implements IConfiguration{
*
* Do NOT make this the same as the overall mod configuration; it will clobber it!
*
* @param confName The config file name (without path or .cfg suffix)
* @param confName The config file name (without path or .cfg suffix)
* @param description The description for the group that the config entries will be placed in.
*/
public ForgeCFG(String confName, String description) {
@@ -37,13 +40,13 @@ public class ForgeCFG implements IConfiguration{
@Override
public boolean isModuleEnabled(PulseMeta meta) {
return config.get(description, meta.getId(), meta.isEnabled(), meta.getDescription()).getBoolean(meta.isEnabled());
return config.get(description, meta.getId(), meta.isEnabled(), meta.getDescription())
.getBoolean(meta.isEnabled());
}
@Override
public void flush() {
if(config.hasChanged())
config.save();
if (config.hasChanged()) config.save();
}
}
@@ -4,20 +4,20 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import mantle.pulsar.config.IConfiguration;
import mantle.pulsar.internal.Configuration;
import mantle.pulsar.pulse.PulseMeta;
import mantle.pulsar.internal.logging.ILogger;
import mantle.pulsar.internal.logging.LogManager;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.IPulse;
import mantle.pulsar.pulse.Pulse;
import mantle.pulsar.pulse.PulseMeta;
import mantle.pulsar.pulse.PulseProxy;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
/**
* Manager class for a given mods Pulses.
@@ -26,7 +26,7 @@ import mantle.pulsar.pulse.PulseProxy;
*
* @author Arkan <[email protected]>
*/
@SuppressWarnings({"unused", "deprecated"})
@SuppressWarnings({ "unused", "deprecated" })
public class PulseManager {
private final ILogger log;
@@ -57,7 +57,7 @@ public class PulseManager {
*
* This form creates a PulseManager that supports configuration of Pulses by file. Recommended approach.
*
* @param modId The parents ModID.
* @param modId The parents ModID.
* @param configName The config file name.
*/
public PulseManager(String modId, String configName) {
@@ -72,7 +72,7 @@ public class PulseManager {
* Don't like JSON? Heathen. Lets you handle configuration, to whatever media you like - File, database, death star.
* Whatever really. See {@link mantle.pulsar.config.IConfiguration}.
*
* @param modId The parents ModID.
* @param modId The parents ModID.
* @param config Configuration handler.
*/
public PulseManager(String modId, IConfiguration config) {
@@ -89,8 +89,8 @@ public class PulseManager {
* @param pulse The Pulse to register.
*/
public void registerPulse(Object pulse) {
if (blockNewRegistrations) throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: "
+ pulse);
if (blockNewRegistrations)
throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " + pulse);
if (!configLoaded) {
conf.load();
configLoaded = true;
@@ -152,7 +152,9 @@ public class PulseManager {
log.debug("Parsing field: " + f);
PulseProxy p = f.getAnnotation(PulseProxy.class);
if (p != null) { // Support for deprecated PulseProxy annotation
log.warn("Pulse " + pulse + " used the deprecated PulseProxy annotation. As of Pulsar 0.1.0, it's now preferred to use FML's SidedProxy annotation.");
log.warn(
"Pulse " + pulse
+ " used the deprecated PulseProxy annotation. As of Pulsar 0.1.0, it's now preferred to use FML's SidedProxy annotation.");
log.warn("The old PulseProxy parsing will be removed in the next breaking update (Pulsar 1.x).");
setProxyField(pulse, f, p.clientSide(), p.serverSide());
}
@@ -181,10 +183,10 @@ public class PulseManager {
blockNewRegistrations = true;
for (Map.Entry<Object, PulseMeta> e : pulses.entrySet()) {
if(hasRequiredPulses(e)) {
if (hasRequiredPulses(e)) {
log.debug("Preinitialising Pulse " + e.getValue().getId() + "...");
if (e.getKey() instanceof IPulse) { // Deprecated IPulse handling
IPulse ip = (IPulse)e.getKey();
IPulse ip = (IPulse) e.getKey();
ip.preInit(evt);
} else findAndInvokeHandlers(e.getKey(), evt);
}
@@ -196,7 +198,7 @@ public class PulseManager {
log.debug("Initialising Pulse " + e.getValue().getId() + "...");
if (e.getKey() instanceof IPulse) { // Deprecated IPulse handling
IPulse ip = (IPulse)e.getKey();
IPulse ip = (IPulse) e.getKey();
ip.init(evt);
log.warn("Pulse " + e.getValue().getId() + " is using the deprecated IPulse interface.");
log.warn("This will be removed in the next major version (Pulsar 1.x) - Please switch to @Handler!");
@@ -209,7 +211,7 @@ public class PulseManager {
log.debug("Postinitialising Pulse " + e.getValue().getId() + "...");
if (e.getKey() instanceof IPulse) { // Deprecated IPulse handling
IPulse ip = (IPulse)e.getKey();
IPulse ip = (IPulse) e.getKey();
ip.postInit(evt);
} else findAndInvokeHandlers(e.getKey(), evt);
}
@@ -219,7 +221,7 @@ public class PulseManager {
* Parse an object for a matching handler for the given object.
*
* @param pulse Object to inspect for Handlers
* @param evt The event object
* @param evt The event object
*/
@SuppressWarnings("unchecked")
private void findAndInvokeHandlers(Object pulse, Object evt) {
@@ -256,8 +258,8 @@ public class PulseManager {
}
public boolean isPulseLoaded(String pulseId) {
for(Map.Entry<Object, PulseMeta> entry : pulses.entrySet()) {
if(entry.getValue().getId().equals(pulseId)) {
for (Map.Entry<Object, PulseMeta> entry : pulses.entrySet()) {
if (entry.getValue().getId().equals(pulseId)) {
return true;
}
}
@@ -3,15 +3,16 @@ package mantle.pulsar.internal;
import java.io.*;
import java.util.*;
import mantle.pulsar.config.IConfiguration;
import mantle.pulsar.internal.logging.ILogger;
import mantle.pulsar.pulse.PulseMeta;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import cpw.mods.fml.common.Loader;
import mantle.pulsar.config.IConfiguration;
import mantle.pulsar.internal.logging.ILogger;
import mantle.pulsar.pulse.PulseMeta;
/**
* Default Gson Configuration helper.
@@ -34,7 +35,7 @@ public class Configuration implements IConfiguration {
* Do NOT make this the same as the overall mod configuration; it will clobber it!
*
* @param confName The config file name (without path or .json suffix)
* @param logger The logger to send debug info to.
* @param logger The logger to send debug info to.
*/
public Configuration(String confName, ILogger logger) {
this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".json";
@@ -98,7 +99,7 @@ public class Configuration implements IConfiguration {
private Map<String, ConfigEntry> parseV0Config(File f) throws Exception {
try {
JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f)));
Map<String, Boolean> m = gson.fromJson(reader, new TypeToken<HashMap<String, Boolean>>(){}.getType()); // NASTY!
Map<String, Boolean> m = gson.fromJson(reader, new TypeToken<HashMap<String, Boolean>>() {}.getType()); // NASTY!
if (m == null) {
throw new NullPointerException("Gson returned null.");
}
@@ -116,7 +117,8 @@ public class Configuration implements IConfiguration {
try {
JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f)));
GsonConfig c = gson.fromJson(reader, GsonConfig.class);
if (c.getConfigVersion() > 1) throw new RuntimeException("Pulsar config is from a newer version! Remove it! " + f.getAbsolutePath());
if (c.getConfigVersion() > 1)
throw new RuntimeException("Pulsar config is from a newer version! Remove it! " + f.getAbsolutePath());
if (c.getModules() == null) throw new IllegalArgumentException("Not a valid GsonConfig. Try v0 parsing.");
return c.getModules();
} catch (FileNotFoundException fnfe) {
@@ -140,6 +142,7 @@ public class Configuration implements IConfiguration {
* Internal exception for an unreadable/unwritable config.
*/
private static class FileNotReadWritableException extends RuntimeException {
public FileNotReadWritableException(String message) {
super(message);
}
@@ -12,9 +12,7 @@ public class LogManager {
private static final boolean useLog4j2;
/*
* Detect the presence of log4j2.
*
* If it's present, we can assume we should be using the damn thing.
* Detect the presence of log4j2. If it's present, we can assume we should be using the damn thing.
*/
static {
boolean l4j = false;
+13 -17
View File
@@ -1,8 +1,8 @@
/**
* Project Pulsar
*
* This is a repackaged copy of the Pulsar project, an open source library for internal module loading.
* The upstream repository is at https://github.com/Emberwalker/Pulsar
* This is a repackaged copy of the Pulsar project, an open source library for internal module loading. The upstream
* repository is at https://github.com/Emberwalker/Pulsar
*
* This code package is licensed under the MIT License, as below.
*
@@ -12,25 +12,21 @@
*
* Copyright (c) 2014 Arkan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* -----
*
* @author Arkan <[email protected]>
*/
package mantle.pulsar;
package mantle.pulsar;
@@ -9,6 +9,5 @@ import java.lang.annotation.*;
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface Handler
{}
@Target({ ElementType.METHOD })
public @interface Handler {}
+1 -1
View File
@@ -8,7 +8,7 @@ import java.lang.annotation.*;
* @author Arkan <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Target({ ElementType.TYPE })
@Documented
public @interface Pulse {
@@ -10,7 +10,7 @@ import java.lang.annotation.*;
* @author Arkan <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@Target({ ElementType.FIELD })
@Documented
@Deprecated
public @interface PulseProxy {
+32 -27
View File
@@ -2,10 +2,13 @@ package mantle.utils;
import static mantle.lib.CoreRepo.logger;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import cpw.mods.fml.common.registry.GameRegistry;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import mantle.lib.CoreConfig;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
@@ -15,18 +18,20 @@ import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import cpw.mods.fml.common.registry.GameRegistry;
public class CraftingHandler {
private static boolean ia1NG;
public static void logConflicts () {
public static void logConflicts() {
//GameRegistry.addShapelessRecipe(new ItemStack(Items.diamond_hoe), Blocks.planks, Items.stick, Items.chainmail_boots);
//GameRegistry.addShapelessRecipe(new ItemStack(Items.apple), Blocks.planks, Items.stick, Items.chainmail_boots);
// GameRegistry.addShapelessRecipe(new ItemStack(Items.diamond_hoe), Blocks.planks, Items.stick,
// Items.chainmail_boots);
// GameRegistry.addShapelessRecipe(new ItemStack(Items.apple), Blocks.planks, Items.stick,
// Items.chainmail_boots);
if (CoreConfig.dumpRecipeConflicts) {
for (Map.Entry<IRecipe, List<IRecipe>> me : getPotentialConflicts().entrySet()) {
String s = "";
@@ -38,7 +43,7 @@ public class CraftingHandler {
}
}
public static Map<IRecipe, List<IRecipe>> getPotentialConflicts () {
public static Map<IRecipe, List<IRecipe>> getPotentialConflicts() {
logger.info("dumping recipe conflicts to log this can take a while");
Map<IRecipe, List<IRecipe>> conflicts = Maps.newHashMap();
CraftingManager inst = CraftingManager.getInstance();
@@ -78,7 +83,7 @@ public class CraftingHandler {
return conflicts;
}
private static boolean compare (IRecipe i1, IRecipe i2) {
private static boolean compare(IRecipe i1, IRecipe i2) {
if (areItemStacksEqual(i1.getRecipeOutput(), i2.getRecipeOutput())) {
return false;
}
@@ -93,7 +98,7 @@ public class CraftingHandler {
ia1 = ((ShapedRecipes) i1).recipeItems.clone();
} else if (i1 instanceof ShapelessRecipes) {
il1 = new ArrayList<ItemStack>(((ShapelessRecipes) i1).recipeItems);
//logger.error("SL Recipe: \n" + print(i1));
// logger.error("SL Recipe: \n" + print(i1));
is1l = true;
} else if (i1 instanceof ShapedOreRecipe) {
Object[] o = ((ShapedOreRecipe) i1).getInput();
@@ -238,11 +243,11 @@ public class CraftingHandler {
logger.error(e.getMessage(), e);
}
}
//logger.error("CONFLICT SET: \n" + print(i1) + print(i2));
// logger.error("CONFLICT SET: \n" + print(i1) + print(i2));
return true;
}
private static String print (IRecipe i1) {
private static String print(IRecipe i1) {
String out = "";
if (i1 instanceof ShapedRecipes) {
out += "SHAPED " + toStr(i1.getRecipeOutput()) + "\n";
@@ -303,27 +308,27 @@ public class CraftingHandler {
return out;
}
private static String toStr (ItemStack is) {
private static String toStr(ItemStack is) {
return GameRegistry.findUniqueIdentifierFor(((ItemStack) is).getItem()) + " " + ((ItemStack) is).toString();
}
public static boolean areItemStacksEqual (ItemStack a, ItemStack b) {
public static boolean areItemStacksEqual(ItemStack a, ItemStack b) {
if ((a == null || b == null) && !(a == null && b == null)) {
return false;
}
if ((a == null && b == null)) {
return true;
}
return a.stackSize != b.stackSize
? false
: (a.getItem() != b.getItem()
? false
: (compdamage(a, b)
? false
: (a.stackTagCompound == null && b.stackTagCompound != null ? false : a.stackTagCompound == null || a.stackTagCompound.equals(b.stackTagCompound))));
return a.stackSize != b.stackSize ? false
: (a.getItem() != b.getItem() ? false
: (compdamage(a, b) ? false
: (a.stackTagCompound == null && b.stackTagCompound != null ? false
: a.stackTagCompound == null
|| a.stackTagCompound.equals(b.stackTagCompound))));
}
public static boolean compdamage (ItemStack a, ItemStack b) {
return a.getItemDamage() != b.getItemDamage() || a.getItemDamage() == OreDictionary.WILDCARD_VALUE || b.getItemDamage() == OreDictionary.WILDCARD_VALUE;
public static boolean compdamage(ItemStack a, ItemStack b) {
return a.getItemDamage() != b.getItemDamage() || a.getItemDamage() == OreDictionary.WILDCARD_VALUE
|| b.getItemDamage() == OreDictionary.WILDCARD_VALUE;
}
}
}
@@ -4,6 +4,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemMetaWrapper {
public final Item item;
public final Integer meta;
@@ -12,8 +13,7 @@ public class ItemMetaWrapper {
this.meta = meta;
}
public ItemMetaWrapper(ItemStack stack)
{
public ItemMetaWrapper(ItemStack stack) {
this.item = stack.getItem();
this.meta = stack.getItemDamage();
}
@@ -3,6 +3,7 @@ package mantle.utils;
import net.minecraft.item.ItemStack;
public class ItemStackNBTWrapper {
public final ItemStack stack;
public ItemStackNBTWrapper(ItemStack stack) {
@@ -4,6 +4,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemStackWrapper extends ItemMetaWrapper {
public final Integer stacksize;
public ItemStackWrapper(Item item, Integer meta, Integer stacksize) {
+20 -37
View File
@@ -13,85 +13,68 @@ import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.common.ChestGenHooks;
@SuppressWarnings("unchecked")
public class RecipeRemover
{
public static void removeShapedRecipes (List<ItemStack> removelist)
{
for (ItemStack stack : removelist)
removeShapedRecipe(stack);
public class RecipeRemover {
public static void removeShapedRecipes(List<ItemStack> removelist) {
for (ItemStack stack : removelist) removeShapedRecipe(stack);
}
public static void removeAnyRecipe (ItemStack resultItem)
{
public static void removeAnyRecipe(ItemStack resultItem) {
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); i++)
{
for (int i = 0; i < recipes.size(); i++) {
IRecipe tmpRecipe = recipes.get(i);
ItemStack recipeResult = tmpRecipe.getRecipeOutput();
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
{
if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
recipes.remove(i--);
}
}
}
public static void removeShapedRecipe (ItemStack resultItem)
{
public static void removeShapedRecipe(ItemStack resultItem) {
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); i++)
{
for (int i = 0; i < recipes.size(); i++) {
IRecipe tmpRecipe = recipes.get(i);
if (tmpRecipe instanceof ShapedRecipes)
{
if (tmpRecipe instanceof ShapedRecipes) {
ShapedRecipes recipe = (ShapedRecipes) tmpRecipe;
ItemStack recipeResult = recipe.getRecipeOutput();
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
{
if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
recipes.remove(i--);
}
}
}
}
public static void removeShapelessRecipe (ItemStack resultItem)
{
public static void removeShapelessRecipe(ItemStack resultItem) {
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); i++)
{
for (int i = 0; i < recipes.size(); i++) {
IRecipe tmpRecipe = recipes.get(i);
if (tmpRecipe instanceof ShapelessRecipes)
{
if (tmpRecipe instanceof ShapelessRecipes) {
ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe;
ItemStack recipeResult = recipe.getRecipeOutput();
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
{
if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
recipes.remove(i--);
}
}
}
}
public static void removeFurnaceRecipe (ItemStack resultItem)
{
public static void removeFurnaceRecipe(ItemStack resultItem) {
Map<ItemStack, ItemStack> recipes = FurnaceRecipes.smelting().getSmeltingList();
recipes.remove(resultItem);
}
public static void removeFurnaceRecipe (Item i, int metadata)
{
public static void removeFurnaceRecipe(Item i, int metadata) {
removeFurnaceRecipe(new ItemStack(i, 1, metadata));
}
public static void removeFurnaceRecipe (Item i)
{
public static void removeFurnaceRecipe(Item i) {
removeFurnaceRecipe(new ItemStack(i, 1, 32767));
}
//removes from all vanilla worldgen chests :D
public static void removeFromChests (ItemStack resultItem)
{
// removes from all vanilla worldgen chests :D
public static void removeFromChests(ItemStack resultItem) {
ChestGenHooks.getInfo(ChestGenHooks.BONUS_CHEST).removeItem(resultItem);
ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).removeItem(resultItem);
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).removeItem(resultItem);
+15 -27
View File
@@ -2,65 +2,56 @@ package mantle.world;
import java.io.Serializable;
import mantle.world.CoordTuple;
import net.minecraft.world.chunk.Chunk;
/**
* Standardized implementation for representing and manipulating Chunk Coordinates. Provides standard Java Collection interaction.
* From COFH LIB(modified to use mantle's coordtuple instead)
* Standardized implementation for representing and manipulating Chunk Coordinates. Provides standard Java Collection
* interaction. From COFH LIB(modified to use mantle's coordtuple instead)
*
* @author King Lemming
*
*/
public final class ChunkCoord implements Comparable<ChunkCoord>, Serializable
{
public final class ChunkCoord implements Comparable<ChunkCoord>, Serializable {
public int chunkX;
public int chunkZ;
public ChunkCoord(Chunk chunk)
{
public ChunkCoord(Chunk chunk) {
this.chunkX = chunk.xPosition;
this.chunkZ = chunk.zPosition;
}
public ChunkCoord(CoordTuple c)
{
public ChunkCoord(CoordTuple c) {
this(c.x >> 4, c.z >> 4);
}
public ChunkCoord(int x, int z)
{
public ChunkCoord(int x, int z) {
this.chunkX = x;
this.chunkZ = z;
}
public int getCenterX ()
{
public int getCenterX() {
return (this.chunkX << 4) + 8;
}
public int getCenterZ ()
{
public int getCenterZ() {
return (this.chunkZ << 4) + 8;
}
public ChunkCoord copy ()
{
public ChunkCoord copy() {
return new ChunkCoord(chunkX, chunkZ);
}
@Override
public boolean equals (Object obj)
{
public boolean equals(Object obj) {
if (!(obj instanceof ChunkCoord))
{
if (!(obj instanceof ChunkCoord)) {
return false;
}
ChunkCoord other = (ChunkCoord) obj;
@@ -68,8 +59,7 @@ public final class ChunkCoord implements Comparable<ChunkCoord>, Serializable
}
@Override
public int hashCode ()
{
public int hashCode() {
int hash = chunkX;
hash *= 31 + this.chunkZ;
@@ -77,16 +67,14 @@ public final class ChunkCoord implements Comparable<ChunkCoord>, Serializable
}
@Override
public String toString ()
{
public String toString() {
return "[" + this.chunkX + ", " + this.chunkZ + "]";
}
/* Comparable */
@Override
public int compareTo (ChunkCoord other)
{
public int compareTo(ChunkCoord other) {
return this.chunkX == other.chunkX ? this.chunkZ - other.chunkZ : this.chunkX - other.chunkX;
}
+64 -90
View File
@@ -6,39 +6,34 @@ package mantle.world;
* @author mDiyo
*/
@SuppressWarnings("rawtypes")
public class CoordTuple implements Comparable
{
public class CoordTuple implements Comparable {
public final int x;
public final int y;
public final int z;
public CoordTuple(double posX, double posY, double posZ)
{
public CoordTuple(double posX, double posY, double posZ) {
x = (int) Math.floor(posX);
y = (int) Math.floor(posY);
z = (int) Math.floor(posZ);
}
public boolean equalCoords (int posX, int posY, int posZ)
{
if (this.x == posX && this.y == posY && this.z == posZ)
return true;
else
return false;
public boolean equalCoords(int posX, int posY, int posZ) {
if (this.x == posX && this.y == posY && this.z == posZ) return true;
else return false;
}
public boolean equals (Object obj) {
if (!(obj instanceof CoordTuple)) {
return false;
}
CoordTuple that = (CoordTuple)obj;
return this.x == that.x && this.y == that.y && this.z == that.z;
public boolean equals(Object obj) {
if (!(obj instanceof CoordTuple)) {
return false;
}
CoordTuple that = (CoordTuple) obj;
return this.x == that.x && this.y == that.y && this.z == that.z;
}
@Override
public int hashCode ()
{
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + x;
@@ -47,126 +42,105 @@ public class CoordTuple implements Comparable
return result;
}
public String toString ()
{
public String toString() {
return "X: " + x + ", Y: " + y + ", Z: " + z;
}
@Override
public int compareTo (Object o)
{
if (o == null)
throw new NullPointerException("Object cannot be null");
public int compareTo(Object o) {
if (o == null) throw new NullPointerException("Object cannot be null");
CoordTuple coord = (CoordTuple) o;
if (x < coord.x)
{
if (x < coord.x) {
return -1;
}
if (x > coord.x)
{
if (x > coord.x) {
return 1;
}
if (y < coord.y)
{
if (y < coord.y) {
return -1;
}
if (y > coord.y)
{
if (y > coord.y) {
return 1;
}
if (z < coord.z)
{
if (z < coord.z) {
return -1;
}
if (z > coord.z)
{
if (z > coord.z) {
return 1;
}
return 0;
}
public static CoordTuple up (int x, int y, int z)
{
public static CoordTuple up(int x, int y, int z) {
return new CoordTuple(x, y + 1, z);
}
public static CoordTuple down (int x, int y, int z)
{
public static CoordTuple down(int x, int y, int z) {
return new CoordTuple(x, y - 1, z);
}
public static CoordTuple north (int x, int y, int z)
{
public static CoordTuple north(int x, int y, int z) {
return new CoordTuple(x, y, z - 1);
}
public static CoordTuple south (int x, int y, int z)
{
public static CoordTuple south(int x, int y, int z) {
return new CoordTuple(x, y, z + 1);
}
public static CoordTuple east (int x, int y, int z)
{
public static CoordTuple east(int x, int y, int z) {
return new CoordTuple(x + 1, y, z);
}
public static CoordTuple west (int x, int y, int z)
{
public static CoordTuple west(int x, int y, int z) {
return new CoordTuple(x - 1, y, z);
}
public static CoordTuple inFront (int x, int y, int z, int meta)
{
switch (meta)
{
case 0:
return down(x, y, z);
case 1:
return up(x, y, z);
case 2:
return north(x, y, z);
case 3:
return south(x, y, z);
case 4:
return west(x, y, z);
case 5:
return east(x, y, z);
default:
return new CoordTuple(x, y, z);
public static CoordTuple inFront(int x, int y, int z, int meta) {
switch (meta) {
case 0:
return down(x, y, z);
case 1:
return up(x, y, z);
case 2:
return north(x, y, z);
case 3:
return south(x, y, z);
case 4:
return west(x, y, z);
case 5:
return east(x, y, z);
default:
return new CoordTuple(x, y, z);
}
}
public static CoordTuple behind (int x, int y, int z, int meta)
{
switch (meta)
{
case 1:
return down(x, y, z);
case 0:
return up(x, y, z);
case 3:
return north(x, y, z);
case 2:
return south(x, y, z);
case 5:
return west(x, y, z);
case 4:
return east(x, y, z);
default:
return new CoordTuple(x, y, z);
public static CoordTuple behind(int x, int y, int z, int meta) {
switch (meta) {
case 1:
return down(x, y, z);
case 0:
return up(x, y, z);
case 3:
return north(x, y, z);
case 2:
return south(x, y, z);
case 5:
return west(x, y, z);
case 4:
return east(x, y, z);
default:
return new CoordTuple(x, y, z);
}
}
public int getDistanceFrom (CoordTuple tuple)
{
public int getDistanceFrom(CoordTuple tuple) {
return getDistanceFrom(tuple.x, tuple.y, tuple.z);
}
public int getDistanceFrom (int x1, int y1, int z1)
{
public int getDistanceFrom(int x1, int y1, int z1) {
int xPos = x - x1;
int yPos = y - y1;
int zPos = z - z1;
@@ -5,20 +5,18 @@ package mantle.world;
*
* @author mDiyo
*/
public class CoordTuplePair
{
public class CoordTuplePair {
public CoordTuple a;
public CoordTuple b;
public CoordTuplePair(CoordTuple a, CoordTuple b)
{
public CoordTuplePair(CoordTuple a, CoordTuple b) {
this.a = a;
this.b = b;
}
public CoordTuplePair(int aX, int aY, int aZ, int bX, int bY, int bZ)
{
public CoordTuplePair(int aX, int aY, int aZ, int bX, int bY, int bZ) {
this.a = new CoordTuple(aX, aY, aZ);
this.b = new CoordTuple(bX, bY, bZ);
}
}
}
+7 -11
View File
@@ -8,23 +8,19 @@ import java.util.Comparator;
* @author mDiyo
*/
@SuppressWarnings("rawtypes")
public class CoordTupleSort implements Comparator
{
public class CoordTupleSort implements Comparator {
@Override
public int compare (Object o1, Object o2)
{
public int compare(Object o1, Object o2) {
CoordTuple c1 = (CoordTuple) o1;
CoordTuple c2 = (CoordTuple) o2;
//Sort by y, then x, then z
if (c1.y != c2.y)
return c1.y - c2.y;
// Sort by y, then x, then z
if (c1.y != c2.y) return c1.y - c2.y;
if (c1.x != c2.x)
return c1.x - c2.x;
if (c1.x != c2.x) return c1.x - c2.x;
if (c1.z != c2.z)
return c1.z - c2.z;
if (c1.z != c2.z) return c1.z - c2.z;
return 0;
}
@@ -5,45 +5,36 @@ package mantle.world;
*
* @author mDiyo
*/
public class DimensionCoordPair
{
public class DimensionCoordPair {
public final int dim;
public final int x;
public final int z;
public DimensionCoordPair(int worldID, int posX, int posZ)
{
public DimensionCoordPair(int worldID, int posX, int posZ) {
dim = worldID;
x = posX;
z = posZ;
}
public boolean equalCoords (int worldID, int posX, int posZ)
{
if (this.dim == posX && this.x == posX && this.z == posZ)
return true;
else
return false;
public boolean equalCoords(int worldID, int posX, int posZ) {
if (this.dim == posX && this.x == posX && this.z == posZ) return true;
else return false;
}
@Override
public boolean equals (Object obj)
{
if (obj == null)
return false;
public boolean equals(Object obj) {
if (obj == null) return false;
if (getClass() == obj.getClass())
{
if (getClass() == obj.getClass()) {
DimensionCoordPair coord = (DimensionCoordPair) obj;
if (this.dim == coord.dim && this.x == coord.x && this.z == coord.z)
return true;
if (this.dim == coord.dim && this.x == coord.x && this.z == coord.z) return true;
}
return false;
}
@Override
public int hashCode ()
{
public int hashCode() {
final int prime = 37;
int result = 1;
result = prime * result + dim;
@@ -52,8 +43,7 @@ public class DimensionCoordPair
return result;
}
public String toString ()
{
public String toString() {
return "Dim: " + dim + ", X: " + x + ", Z: " + z;
}
}
@@ -6,37 +6,30 @@ package mantle.world;
* @author mDiyo
* @author Sunstrike <[email protected]>
*/
public class DimensionCoordTuple
{
public class DimensionCoordTuple {
public final int dim;
public final int x;
public final int y;
public final int z;
public DimensionCoordTuple(int worldID, int posX, int posY, int posZ)
{
public DimensionCoordTuple(int worldID, int posX, int posY, int posZ) {
dim = worldID;
y = posY;
x = posX;
z = posZ;
}
public boolean equalCoords (int worldID, int posX, int posY, int posZ)
{
if (this.dim == worldID && this.x == posX && this.y == posY && this.z == posZ)
return true;
else
return false;
public boolean equalCoords(int worldID, int posX, int posY, int posZ) {
if (this.dim == worldID && this.x == posX && this.y == posY && this.z == posZ) return true;
else return false;
}
@Override
public boolean equals (Object obj)
{
if (obj == null)
return false;
public boolean equals(Object obj) {
if (obj == null) return false;
if (getClass() == obj.getClass())
{
if (getClass() == obj.getClass()) {
DimensionCoordTuple coord = (DimensionCoordTuple) obj;
return equalCoords(coord.dim, coord.x, coord.y, coord.z);
}
@@ -44,8 +37,7 @@ public class DimensionCoordTuple
}
@Override
public int hashCode ()
{
public int hashCode() {
final int prime = 37;
int result = 1;
result = prime * result + dim;
@@ -55,8 +47,7 @@ public class DimensionCoordTuple
return result;
}
public String toString ()
{
public String toString() {
return "Dim: " + dim + ", X: " + x + ", Y: " + y + ", Z: " + z;
}
}
@@ -8,22 +8,20 @@ import net.minecraftforge.common.util.ForgeDirection;
* @author Sunstrike <[email protected]>
*/
@SuppressWarnings("unused")
public class DirectionUtils
{
public class DirectionUtils {
private DirectionUtils()
{
private DirectionUtils() {
// No instantiation
}
public static boolean isRightAngles (ForgeDirection a, ForgeDirection b)
{
public static boolean isRightAngles(ForgeDirection a, ForgeDirection b) {
return a != b && a != b.getOpposite() && a != ForgeDirection.UNKNOWN && b != ForgeDirection.UNKNOWN;
}
public static boolean isHorizontal (ForgeDirection a)
{
return a == ForgeDirection.EAST || a == ForgeDirection.NORTH || a == ForgeDirection.SOUTH || a == ForgeDirection.WEST;
public static boolean isHorizontal(ForgeDirection a) {
return a == ForgeDirection.EAST || a == ForgeDirection.NORTH
|| a == ForgeDirection.SOUTH
|| a == ForgeDirection.WEST;
}
}
+8 -14
View File
@@ -1,31 +1,25 @@
package mantle.world;
import mantle.common.ComparisonHelper;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class WorldHelper
{
public class WorldHelper {
@Deprecated
public static boolean setBlockToAirBool (World w, int x, int y, int z)
{
public static boolean setBlockToAirBool(World w, int x, int y, int z) {
return setBlockToAir(w, x, y, z);
}
public static boolean setBlockToAir (World w, int x, int y, int z)
{
public static boolean setBlockToAir(World w, int x, int y, int z) {
return w.setBlockToAir(x, y, z);
}
public static boolean isAirBlock (IBlockAccess access, int x, int y, int z)
{
return access.getBlock(x,y,z).isAir(access, x,y,z);
public static boolean isAirBlock(IBlockAccess access, int x, int y, int z) {
return access.getBlock(x, y, z).isAir(access, x, y, z);
}
public static boolean isAirBlock (World access, int x, int y, int z)
{
return access.isAirBlock(x,y,z);
public static boolean isAirBlock(World access, int x, int y, int z) {
return access.isAirBlock(x, y, z);
}
}