v4.2.2 Beta #1

*Fixed redstone advanced machine container bug.
*Removed unused methods from IEnergizedItem.
*Added 'IPeripheral' CC support to IElectricMachine.
*Removed tile entity-based texture system.
*Fixed advanced electric machine active update.
*Moved to TextureFX for machine animations.
*Removed old textures from terrain.png and added new pictures for all
animations.
*Added CC support for machines and power units.
*Removed texture preloads for non-existant textures.
*Bumped version to 4.2.2!
This commit is contained in:
Aidan Brady 2012-10-09 16:27:10 -04:00
parent 5f557269be
commit e12825cccc
18 changed files with 195 additions and 70 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -2,6 +2,8 @@ package net.uberkat.obsidian.api;
import java.util.List; import java.util.List;
import dan200.computer.api.IPeripheral;
import ic2.api.IWrenchable; import ic2.api.IWrenchable;
import net.minecraft.src.*; import net.minecraft.src.*;
import net.minecraftforge.common.ISidedInventory; import net.minecraftforge.common.ISidedInventory;
@ -11,7 +13,7 @@ import net.minecraftforge.common.ISidedInventory;
* @author AidanBrady * @author AidanBrady
* *
*/ */
public interface IElectricMachine extends IInventory, ISidedInventory, IWrenchable, INetworkedMachine public interface IElectricMachine extends IInventory, ISidedInventory, IWrenchable, INetworkedMachine, IPeripheral
{ {
/** /**
* Update call for machines. Use instead of updateEntity() - it's called every tick. * Update call for machines. Use instead of updateEntity() - it's called every tick.

View file

@ -50,10 +50,4 @@ public interface IEnergizedItem
* @return leftover energy * @return leftover energy
*/ */
public int discharge(ItemStack itemstack, int amount); public int discharge(ItemStack itemstack, int amount);
/**
* Whether or not this item's energy can be used.
* @return if energy can be used
*/
public boolean canCharge();
} }

View file

@ -3,6 +3,7 @@ package net.uberkat.obsidian.common;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Side; import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly; import cpw.mods.fml.common.asm.SideOnly;
import net.minecraft.src.*; import net.minecraft.src.*;
@ -166,7 +167,8 @@ public class BlockMachine extends BlockContainer
{ {
if(side == tileEntity.facing) if(side == tileEntity.facing)
{ {
return isActive(world, x, y, z) ? tileEntity.textureIndex + 32 : 14; return isActive(world, x, y, z) ? ObsidianIngots.ANIMATED_TEXTURE_INDEX : 14;
} }
else { else {
return 2; return 2;
@ -176,7 +178,7 @@ public class BlockMachine extends BlockContainer
{ {
if(side == tileEntity.facing) if(side == tileEntity.facing)
{ {
return isActive(world, x, y, z) ? tileEntity.textureIndex + 48 : 15; return isActive(world, x, y, z) ? ObsidianIngots.ANIMATED_TEXTURE_INDEX+1 : 15;
} }
else { else {
return 2; return 2;
@ -201,14 +203,14 @@ public class BlockMachine extends BlockContainer
else { else {
if(side == tileEntity.facing) if(side == tileEntity.facing)
{ {
return isActive(world, x, y, z) ? tileEntity.textureIndex + 64 : 16; return isActive(world, x, y, z) ? ObsidianIngots.ANIMATED_TEXTURE_INDEX+2 : 16;
} }
else if(side == ForgeDirection.getOrientation(tileEntity.facing).getOpposite().ordinal()) else if(side == ForgeDirection.getOrientation(tileEntity.facing).getOpposite().ordinal())
{ {
return isActive(world, x, y, z) ? tileEntity.textureIndex + 80 : 17; return isActive(world, x, y, z) ? ObsidianIngots.ANIMATED_TEXTURE_INDEX+3 : 17;
} }
else { else {
return isActive(world, x, y, z) ? tileEntity.textureIndex + 96 : 19; return isActive(world, x, y, z) ? ObsidianIngots.ANIMATED_TEXTURE_INDEX+4 : 19;
} }
} }
} }

View file

@ -75,7 +75,7 @@ public class ContainerAdvancedElectricMachine extends Container
} }
else if(slotStack.itemID == Item.redstone.shiftedIndex) else if(slotStack.itemID == Item.redstone.shiftedIndex)
{ {
if(slotID != 3) if(slotID != 3 && slotID != 0)
{ {
if(!mergeItemStack(slotStack, 3, 4, false)) if(!mergeItemStack(slotStack, 3, 4, false))
{ {
@ -94,7 +94,7 @@ public class ContainerAdvancedElectricMachine extends Container
} }
else if(slotID == 3) else if(slotID == 3)
{ {
if(!mergeItemStack(slotStack, 3, 4, false)) if(!mergeItemStack(slotStack, 0, 1, false))
{ {
return null; return null;
} }

View file

@ -35,7 +35,7 @@ public class ObsidianHooks
IC2GoldDust = getIC2Item("goldDust"); IC2GoldDust = getIC2Item("goldDust");
Ic2Recipes.addMaceratorRecipe(new ItemStack(ObsidianIngots.OreBlock, 1, 0), new ItemStack(ObsidianIngots.PlatinumDust, 2)); Ic2Recipes.addMaceratorRecipe(new ItemStack(ObsidianIngots.OreBlock, 1, 0), new ItemStack(ObsidianIngots.PlatinumDust, 2));
Ic2Recipes.addMatterAmplifier(ObsidianIngots.EnrichedAlloy, 80000); Ic2Recipes.addMatterAmplifier(ObsidianIngots.EnrichedAlloy, 100000);
System.out.println("[ObsidianIngots] Hooked into IC2 successfully."); System.out.println("[ObsidianIngots] Hooked into IC2 successfully.");
} }

View file

@ -38,7 +38,7 @@ import cpw.mods.fml.common.registry.TickRegistry;
* @author AidanBrady * @author AidanBrady
* *
*/ */
@Mod(modid = "ObsidianIngots", name = "Obsidian Ingots", version = "4.2.1") @Mod(modid = "ObsidianIngots", name = "Obsidian Ingots", version = "4.2.2")
@NetworkMod(channels = { "ObsidianIngots" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) @NetworkMod(channels = { "ObsidianIngots" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class ObsidianIngots public class ObsidianIngots
{ {
@ -214,6 +214,8 @@ public class ObsidianIngots
/** Total ticks passed since thePlayer joined theWorld */ /** Total ticks passed since thePlayer joined theWorld */
public static int ticksPassed = 0; public static int ticksPassed = 0;
public static int ANIMATED_TEXTURE_INDEX = 240;
/** /**
* Adds all in-game crafting and smelting recipes. * Adds all in-game crafting and smelting recipes.
*/ */

View file

@ -7,6 +7,8 @@ import universalelectricity.implement.IItemElectric;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import dan200.computer.api.IComputerAccess;
import ic2.api.ElectricItem; import ic2.api.ElectricItem;
import ic2.api.EnergyNet; import ic2.api.EnergyNet;
import ic2.api.IElectricItem; import ic2.api.IElectricItem;
@ -138,7 +140,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
} }
} }
if(canOperate() && inventory[1] != null && secondaryEnergyStored == 0) if(inventory[1] != null && secondaryEnergyStored == 0)
{ {
int fuelTicks = getFuelTicks(inventory[1]); int fuelTicks = getFuelTicks(inventory[1]);
if(fuelTicks > 0) if(fuelTicks > 0)
@ -265,6 +267,11 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
return false; return false;
} }
if(secondaryEnergyStored < SECONDARY_ENERGY_PER_TICK)
{
return false;
}
ItemStack itemstack = RecipeHandler.getOutput(inventory[0], false, getRecipes()); ItemStack itemstack = RecipeHandler.getOutput(inventory[0], false, getRecipes());
if (itemstack == null) if (itemstack == null)
@ -483,4 +490,45 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
{ {
return operatingTicks*i / TICKS_REQUIRED; return operatingTicks*i / TICKS_REQUIRED;
} }
public String getType()
{
return "Advanced Electric Machine";
}
public String[] getMethodNames()
{
return new String[] {"getStored", "getSecondaryStored", "getProgress", "isActive", "facing", "canOperate"};
}
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception
{
switch(method)
{
case 0:
return new Object[] {energyStored};
case 1:
return new Object[] {secondaryEnergyStored};
case 2:
return new Object[] {operatingTicks};
case 3:
return new Object[] {isActive};
case 4:
return new Object[] {facing};
case 5:
return new Object[] {canOperate()};
default:
System.err.println("[ObsidianIngots] Attempted to call unknown method with computer ID " + computer.getID());
return null;
}
}
public boolean canAttachToSide(int side)
{
return true;
}
public void attach(IComputerAccess computer, String computerSide) {}
public void detach(IComputerAccess computer) {}
} }

View file

@ -17,12 +17,6 @@ public abstract class TileEntityBasicMachine extends TileEntity implements IElec
/** The direction this block is facing. */ /** The direction this block is facing. */
public int facing; public int facing;
/** A timer used to update the block's texture. */
public int textureTick = 0;
/** An integer that cycles between 0-15, used to update the block's texture. */
public int textureIndex = 0;
/** A timer used to send packets to clients. */ /** A timer used to send packets to clients. */
public int packetTick = 0; public int packetTick = 0;
@ -57,11 +51,6 @@ public abstract class TileEntityBasicMachine extends TileEntity implements IElec
onUpdate(); onUpdate();
if(worldObj.isRemote)
{
updateTexture();
}
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
if(packetTick == 5) if(packetTick == 5)
@ -77,17 +66,6 @@ public abstract class TileEntityBasicMachine extends TileEntity implements IElec
} }
} }
@SideOnly(Side.CLIENT)
public void updateTexture()
{
if(textureTick % 5 == 0)
{
textureIndex = (++textureIndex)%15;
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
textureTick++;
}
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
{ {
return true; return true;

View file

@ -7,6 +7,8 @@ import universalelectricity.implement.IItemElectric;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import dan200.computer.api.IComputerAccess;
import ic2.api.ElectricItem; import ic2.api.ElectricItem;
import ic2.api.EnergyNet; import ic2.api.EnergyNet;
import ic2.api.IElectricItem; import ic2.api.IElectricItem;
@ -417,4 +419,43 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
{ {
return operatingTicks*i / TICKS_REQUIRED; return operatingTicks*i / TICKS_REQUIRED;
} }
public String getType()
{
return "Electric Machine";
}
public String[] getMethodNames()
{
return new String[] {"getStored", "getProgress", "isActive", "facing", "canOperate"};
}
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception
{
switch(method)
{
case 0:
return new Object[] {energyStored};
case 1:
return new Object[] {operatingTicks};
case 2:
return new Object[] {isActive};
case 3:
return new Object[] {facing};
case 4:
return new Object[] {canOperate()};
default:
System.err.println("[ObsidianIngots] Attempted to call unknown method with computer ID " + computer.getID());
return null;
}
}
public boolean canAttachToSide(int side)
{
return true;
}
public void attach(IComputerAccess computer, String computerSide) {}
public void detach(IComputerAccess computer) {}
} }

View file

@ -26,6 +26,9 @@ import buildcraft.api.core.Orientations;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
import ic2.api.Direction; import ic2.api.Direction;
import ic2.api.ElectricItem; import ic2.api.ElectricItem;
import ic2.api.EnergyNet; import ic2.api.EnergyNet;
@ -40,7 +43,7 @@ import net.minecraftforge.common.ISidedInventory;
import net.uberkat.obsidian.api.IEnergizedItem; import net.uberkat.obsidian.api.IEnergizedItem;
import net.uberkat.obsidian.api.INetworkedMachine; import net.uberkat.obsidian.api.INetworkedMachine;
public class TileEntityPowerUnit extends TileEntityDisableable implements IInventory, ISidedInventory, INetworkedMachine, IWrenchable, IEnergySink, IEnergySource, IEnergyStorage, IPowerReceptor, IElectricityStorage, IElectricityReceiver public class TileEntityPowerUnit extends TileEntityDisableable implements IInventory, ISidedInventory, INetworkedMachine, IWrenchable, IEnergySink, IEnergySource, IEnergyStorage, IPowerReceptor, IElectricityStorage, IElectricityReceiver, IPeripheral
{ {
public ItemStack[] inventory = new ItemStack[2]; public ItemStack[] inventory = new ItemStack[2];
@ -90,32 +93,6 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
} }
} }
public Packet getDescriptionPacket()
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(bytes);
try {
output.writeInt(EnumPacketType.TILE_ENTITY.id);
output.writeInt(xCoord);
output.writeInt(yCoord);
output.writeInt(zCoord);
output.writeInt(facing);
output.writeInt(energyStored);
} catch (IOException e)
{
System.err.println("[ObsidianIngots] Error while writing tile entity packet.");
e.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "ObsidianIngots";
packet.data = bytes.toByteArray();
packet.length = packet.data.length;
return packet;
}
public void updateEntity() public void updateEntity()
{ {
if(!worldObj.isRemote) if(!worldObj.isRemote)
@ -560,4 +537,37 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
{ {
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : var1.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D; return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : var1.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D;
} }
public String getType()
{
return getInvName();
}
public String[] getMethodNames()
{
return new String[] {"getStored", "getOutput"};
}
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception
{
switch(method)
{
case 0:
return new Object[] {energyStored};
case 1:
return new Object[] {output};
default:
System.err.println("[ObsidianIngots] Attempted to call unknown method with computer ID " + computer.getID());
return null;
}
}
public boolean canAttachToSide(int side)
{
return true;
}
public void attach(IComputerAccess computer, String computerSide) {}
public void detach(IComputerAccess computer) {}
} }

View file

@ -7,6 +7,7 @@ import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.TextureFXManager;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Side; import cpw.mods.fml.common.Side;
@ -49,12 +50,26 @@ public class ClientProxy extends CommonProxy
public void registerRenderInformation() public void registerRenderInformation()
{ {
System.out.println("[ObsidianIngots] Beginning render initiative..."); System.out.println("[ObsidianIngots] Beginning render initiative...");
//Preload block/item textures //Preload block/item textures
MinecraftForgeClient.preloadTexture("/obsidian/items.png"); MinecraftForgeClient.preloadTexture("/obsidian/items.png");
MinecraftForgeClient.preloadTexture("/obsidian/terrain.png"); MinecraftForgeClient.preloadTexture("/obsidian/terrain.png");
MinecraftForgeClient.preloadTexture("/obsidian/Compressor.png"); MinecraftForgeClient.preloadTexture("/obsidian/CompressorFront.png");
MinecraftForgeClient.preloadTexture("/obsidian/Combiner.png"); MinecraftForgeClient.preloadTexture("/obsidian/CombinerFront.png");
MinecraftForgeClient.preloadTexture("/obsidian/Elementizer.png"); MinecraftForgeClient.preloadTexture("/obsidian/ElementizerFront.png");
MinecraftForgeClient.preloadTexture("/obsidian/ElementizerBack.png");
MinecraftForgeClient.preloadTexture("/obsidian/ElementizerSide.png");
//Register animated TextureFX for machines
try {
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/obsidian/CompressorFront.png", ObsidianIngots.ANIMATED_TEXTURE_INDEX));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/obsidian/CombinerFront.png", ObsidianIngots.ANIMATED_TEXTURE_INDEX+1));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/obsidian/ElementizerFront.png", ObsidianIngots.ANIMATED_TEXTURE_INDEX+2));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/obsidian/ElementizerBack.png", ObsidianIngots.ANIMATED_TEXTURE_INDEX+3));
TextureFXManager.instance().addAnimation(new TextureAnimatedFX("/obsidian/ElementizerSide.png", ObsidianIngots.ANIMATED_TEXTURE_INDEX+4));
} catch (IOException e) {
System.err.println("[ObsidianIngots] Error registering animation with FML: " + e.getMessage());
}
//Register entity rendering handlers //Register entity rendering handlers
RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new RenderObsidianTNT()); RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new RenderObsidianTNT());

View file

@ -0,0 +1,33 @@
package net.uberkat.obsidian.client;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.TextureFXManager;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.src.ModLoader;
import net.minecraft.src.ModTextureAnimation;
import net.minecraft.src.RenderEngine;
public class TextureAnimatedFX extends ModTextureAnimation
{
public TextureAnimatedFX(String texture, int index) throws IOException
{
super(index, 1, texture, TextureFXManager.instance().loadImageFromTexturePack(FMLClientHandler.instance().getClient().renderEngine, texture), 5);
}
public void bindImage(RenderEngine renderengine)
{
//Binds texture with GL11 to use specific icon index.
GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, renderengine.getTexture("/obsidian/terrain.png"));
}
}