Skip to content

Commit

Permalink
2nd update sweep
Browse files Browse the repository at this point in the history
  • Loading branch information
progwml6 committed Dec 29, 2013
1 parent 7337596 commit d8b0a82
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 41 deletions.
4 changes: 3 additions & 1 deletion src/mantle/Mantle.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mantle;

import org.apache.logging.log4j.LogManager;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.SidedProxy;
Expand Down Expand Up @@ -39,7 +41,7 @@ public class Mantle
@EventHandler
public void preInit (FMLPreInitializationEvent evt)
{
logger.setParent(FMLCommonHandler.instance().getFMLLogger());
//logger.setParent(FMLCommonHandler.instance().getFMLLogger());

CoreConfig.loadConfiguration(new net.minecraftforge.common.config.Configuration(evt.getSuggestedConfigurationFile()));

Expand Down
4 changes: 2 additions & 2 deletions src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected void adjustInventory (int size, boolean forceAdjust)
}

stack.stackSize -= itemSize;
EntityItem entityitem = new EntityItem(worldObj, (double) ((float) xCoord + jumpX + offsetX), (double) ((float) yCoord + jumpY),
EntityItem entityitem = new EntityItem(this, (double) ((float) xCoord + jumpX + offsetX), (double) ((float) yCoord + jumpY),
(double) ((float) zCoord + jumpZ + offsetZ), new ItemStack(stack.getItem(), itemSize, stack.getItemDamage()));

if (stack.hasTagCompound())
Expand All @@ -87,7 +87,7 @@ protected void adjustInventory (int size, boolean forceAdjust)
entityitem.motionX = (double) ((float) random.nextGaussian() * offset);
entityitem.motionY = (double) ((float) random.nextGaussian() * offset + 0.2F);
entityitem.motionZ = (double) ((float) random.nextGaussian() * offset);
worldObj.spawnEntityInWorld(entityitem);
this.spawnEntityInWorld(entityitem);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mantle/blocks/abstracts/ExpandableInventoryLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public ItemStack decrStackSize (int slot, int quantity)
@Override
public boolean isUseableByPlayer (EntityPlayer entityplayer)
{
if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
if (this.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
return false;

else
Expand Down
10 changes: 5 additions & 5 deletions src/mantle/blocks/abstracts/InventoryBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer
@Override
public void breakBlock (World par1World, int x, int y, int z, int blockID, int meta)
{
TileEntity te = par1World.getBlockTileEntity(x, y, z);
TileEntity te = par1World.func_147438_o(x, y, z);

if (te != null && te instanceof InventoryLogic)
{
Expand Down Expand Up @@ -134,7 +134,7 @@ public int onBlockPlaced (World world, int x, int y, int z, int side, float hitX
@Override
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
{
TileEntity logic = world.getBlockTileEntity(x, y, z);
TileEntity logic = world.func_147438_o(x, y, z);
if (logic instanceof IFacingLogic)
{
IFacingLogic direction = (IFacingLogic) logic;
Expand Down Expand Up @@ -166,7 +166,7 @@ public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase

public static boolean isActive (IBlockAccess world, int x, int y, int z)
{
TileEntity logic = world.getBlockTileEntity(x, y, z);
TileEntity logic = world.func_147438_o(x, y, z);
if (logic instanceof IActiveLogic)
{
return ((IActiveLogic) logic).getActive();
Expand All @@ -185,7 +185,7 @@ public int damageDropped (int meta)
public abstract String[] getTextureNames ();

@Override
public void registerIcons (IIconRegister iconRegister)
public void func_149651_a (IIconRegister iconRegister)
{
String[] textureNames = getTextureNames();
this.icons = new IIcon[textureNames.length];
Expand All @@ -201,7 +201,7 @@ public void registerIcons (IIconRegister iconRegister)
public void func_149670_a(World world, int x, int y, int z, EntityPlayer player) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem().getItem() == Item.stick)
{
TileEntity te = world.getBlockTileEntity(x, y, z);
TileEntity te = world.func_147438_o(x, y, z);
if (te instanceof IDebuggable)
{
DebugHelper.handleDebugData(((IDebuggable) te).getDebugInfo(player));
Expand Down
6 changes: 3 additions & 3 deletions src/mantle/blocks/abstracts/InventoryLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ItemStack decrStackSize (int slot, int quantity)
@Override
public boolean isUseableByPlayer (EntityPlayer entityplayer)
{
if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
if (this.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
return false;

else
Expand All @@ -125,11 +125,11 @@ public void readInventoryFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
this.invName = tags.getString("InvName");
NBTTagList nbttaglist = tags.getTagList("Items");
NBTTagList nbttaglist = tags.func_150295_c("Items", 0); //TODO WTF goes here <-
inventory = new ItemStack[getSizeInventory()];
for (int iter = 0; iter < nbttaglist.tagCount(); iter++)
{
NBTTagCompound tagList = (NBTTagCompound) nbttaglist.tagAt(iter);
NBTTagCompound tagList = (NBTTagCompound) nbttaglist.func_150305_b(iter); //TODO tagAt?
byte slotID = tagList.getByte("Slot");
if (slotID >= 0 && slotID < inventory.length)
{
Expand Down
4 changes: 2 additions & 2 deletions src/mantle/blocks/abstracts/MultiItemBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public String getUnlocalizedName (ItemStack itemstack)
try {
return (new StringBuilder()).append(unlocalizedName).append(".").append(blockType[sbIndex]).append(append).toString();
} catch (ArrayIndexOutOfBoundsException ex) {
logger.warning("[MultiItemBlock] Caught array index error in getUnlocalizedName: " + ex.getMessage());
logger.warning("[MultiItemBlock] Returning unlocalized name!");
logger.warn("[MultiItemBlock] Caught array index error in getUnlocalizedName: " + ex.getMessage());
logger.warn("[MultiItemBlock] Returning unlocalized name!");
return getUnlocalizedName();
}
}
Expand Down
50 changes: 30 additions & 20 deletions src/mantle/blocks/abstracts/MultiServantLogic.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package mantle.blocks.abstracts;

import cpw.mods.fml.common.registry.GameRegistry;
import mantle.debug.DebugData;
import mantle.debug.IDebuggable;
import mantle.world.CoordTuple;
import mantle.blocks.iface.IMasterLogic;
import mantle.blocks.iface.IServantLogic;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;


public class MultiServantLogic extends TileEntity implements IServantLogic, IDebuggable
{
boolean hasMaster;
CoordTuple master;
short masterID;
Block masterBlock;
byte masterMeat; //Typo, it stays!

public boolean canUpdate ()
Expand All @@ -27,8 +32,8 @@ public boolean hasValidMaster ()
{
if (!hasMaster)
return false;

if (worldObj.getBlockId(master.x, master.y, master.z) == masterID && worldObj.getBlockMetadata(master.x, master.y, master.z) == masterMeat)
//Minecraft.getMinecraft().getMinecraft().theWorld???
if (this.getBlock(master.x, master.y, master.z) == masterBlock && this.getBlockMetadata(master.x, master.y, master.z) == masterMeat)
return true;

else
Expand All @@ -48,22 +53,22 @@ public void overrideMaster (int x, int y, int z)
{
hasMaster = true;
master = new CoordTuple(x, y, z);
masterID = (short) worldObj.getBlockId(x, y, z);
masterMeat = (byte) worldObj.getBlockMetadata(x, y, z);
masterBlock = this.getBlock(x, y, z);
masterMeat = (byte) this.getBlockMetadata(x, y, z);
}

public void removeMaster ()
{
hasMaster = false;
master = null;
masterID = 0;
masterBlock = null;
masterMeat = 0;
}

@Deprecated
public boolean verifyMaster (IMasterLogic logic, int x, int y, int z)
{
if (master.equalCoords(x, y, z) && worldObj.getBlockId(x, y, z) == masterID && worldObj.getBlockMetadata(x, y, z) == masterMeat)
if (master.equalCoords(x, y, z) && this.getBlock(x, y, z) == masterBlock && this.getBlockMetadata(x, y, z) == masterMeat)
return true;
else
return false;
Expand All @@ -72,7 +77,7 @@ public boolean verifyMaster (IMasterLogic logic, int x, int y, int z)
@Deprecated
public boolean setMaster (int x, int y, int z)
{
if (!hasMaster || worldObj.getBlockId(master.x, master.y, master.z) != masterID || (worldObj.getBlockMetadata(master.x, master.y, master.z) != masterMeat))
if (!hasMaster || this.getBlock(master.x, master.y, master.z) != masterBlock || (this.getBlockMetadata(master.x, master.y, master.z) != masterMeat))
{
overrideMaster(x, y, z);
return true;
Expand Down Expand Up @@ -114,7 +119,7 @@ public void notifyMasterOfChange ()
{
if (hasValidMaster())
{
IMasterLogic logic = (IMasterLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
IMasterLogic logic = (IMasterLogic) this.getBlockTileEntity(master.x, master.y, master.z);
logic.notifyChange(this, xCoord, yCoord, zCoord);
}
}
Expand All @@ -128,7 +133,7 @@ public void readCustomNBT (NBTTagCompound tags)
int yCenter = tags.getInteger("yCenter");
int zCenter = tags.getInteger("zCenter");
master = new CoordTuple(xCenter, yCenter, zCenter);
masterID = tags.getShort("MasterID");
masterBlock = GameRegistry.findBlock(tags.getString("MasterModName"), tags.getString("MasterBlockName"));
masterMeat = tags.getByte("masterMeat");
}
}
Expand All @@ -141,7 +146,8 @@ public void writeCustomNBT (NBTTagCompound tags)
tags.setInteger("xCenter", master.x);
tags.setInteger("yCenter", master.y);
tags.setInteger("zCenter", master.z);
tags.setShort("MasterID", masterID);
tags.setString("MasterBlockName", masterBlock.func_149702_O());//<- unlocalized name?
tags.setString("MasterModName", "MODNAME"); //TODO get mod name of block here!!
tags.setByte("masterMeat", masterMeat);
}
}
Expand All @@ -166,24 +172,28 @@ public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeCustomNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}

@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
{
readCustomNBT(packet.data);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
readCustomNBT(packet.func_148857_g());
this.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}

/* 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) {
strs[1] = "masterID: " + masterID + ", masterMeat: " + masterMeat;
} else {
if (hasMaster)
{
strs[1] = "masterBlock: " + masterBlock.toString() + ", masterMeat: " + masterMeat;
}
else
{
strs[1] = "No active master.";
}
return new DebugData(player, getClass(), strs);
Expand Down
6 changes: 3 additions & 3 deletions src/mantle/client/RenderItemCopy.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void doRenderItem (EntityItem par1EntityItem, double par2, double par4, d
{
;
}
else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(block.getRenderType()))
else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(block.func_149645_b()))
{
GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F);

Expand All @@ -90,7 +90,7 @@ else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.r
}

float f7 = 0.25F;
int j = block.getRenderType();
int j = block.func_149645_b();

if (j == 1 || j == 19 || j == 12 || j == 2)
{
Expand Down Expand Up @@ -354,7 +354,7 @@ public void renderItemIntoGUI (SmallFontRenderer par1FontRenderer, TextureManage
float f2;

Block block = Block.func_149634_a(k);
if (block != null && par3ItemStack.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(block.getRenderType()))
if (block != null && par3ItemStack.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(block.func_149645_b()))
{
par2TextureManager.bindTexture(TextureMap.locationBlocksTexture);
GL11.glPushMatrix();
Expand Down
6 changes: 4 additions & 2 deletions src/mantle/lib/CoreRepo.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mantle.lib;

import java.util.logging.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


/**
* Mantle object repository
Expand All @@ -16,6 +18,6 @@ public final class CoreRepo
public static final String modName = "Mantle";
public static final String modVersion = "${version}";

public static final Logger logger = Logger.getLogger(modId);
public static final Logger logger = LogManager.getLogger();

}
4 changes: 2 additions & 2 deletions src/mantle/lib/environment/EnvironmentChecks.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void verifyEnvironmentSanity ()

if (FMLCommonHandler.instance().getSide() == Side.CLIENT && FMLClientHandler.instance().hasOptifine() || Loader.isModLoaded("optifine"))
{
if (!CoreConfig.silenceEnvChecks) logger.severe("[Environment Checks] Optifine detected. This may cause issues due to base edits or ASM usage.");
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");
}
Expand All @@ -49,7 +49,7 @@ public static void verifyEnvironmentSanity ()
Class cl = Class.forName("org.bukkit.Bukkit");
if (cl != null)
{
if (!CoreConfig.silenceEnvChecks) logger.severe("[Environment Checks] Bukkit implementation detected. This may cause issues. Bukkit implementations include Craftbukkit and MCPC+.");
if (!CoreConfig.silenceEnvChecks) logger.error("[Environment Checks] Bukkit implementation detected. This may cause issues. Bukkit implementations include Craftbukkit and MCPC+.");
modIds.add("bukkit");
}
}
Expand Down

0 comments on commit d8b0a82

Please sign in to comment.