v4.0.8 Release

*Moved to a new packet handling system.
*Fixed machines not being resistant to TNT.
*Fixed other blocks not being resisitant to TNT.
*Fixed machines breaking instantly.
*Fixed other blocks breaking instantly.
*Lowered machine block hardness and resistance.
*Cleaned up javadocs and proxy.
This commit is contained in:
Aidan Brady 2012-09-20 09:59:30 -04:00
parent a4f7d615a3
commit 435fd3e24a
14 changed files with 185 additions and 119 deletions

View file

@ -15,6 +15,8 @@ public class BlockMachine extends BlockContainer
public BlockMachine(int id)
{
super(id, Material.iron);
setHardness(3.5F);
setResistance(8F);
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving)

View file

@ -78,6 +78,19 @@ public class BlockMulti extends Block
}
return false;
}
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
switch(metadata)
{
case 3:
return 8;
case 5:
return 15;
}
return 0;
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving)
{
@ -85,28 +98,30 @@ public class BlockMulti extends Block
switch(metadata)
{
case 0:
setHardness(3F).setResistance(5F);
setResistance(5F);
break;
case 1:
setHardness(5F).setResistance(10F);
break;
case 2:
setHardness(5F).setResistance(10F);
break;
case 3:
setHardness(10F).setResistance(15F).setLightValue(0.5F);
break;
case 4:
setHardness(5F).setResistance(10F);
break;
case 5:
setHardness(5F).setResistance(10F).setLightValue(0.875F);
default:
setResistance(10F);
break;
}
world.markBlockAsNeedsUpdate(x, y, z);
world.updateAllLightTypes(x, y, z);
}
public float getBlockHardness(World world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
switch(metadata)
{
case 0:
return 3F;
default:
return 5F;
}
}
public String getTextureFile()
{
return "/obsidian/terrain.png";
}
}
}

View file

@ -29,7 +29,7 @@ public class CommonProxy
* Gets the world the client is using from ClientProxy.
* @return client world
*/
public World getClientWorld()
public World getClientWorld()
{
return null;
}
@ -39,7 +39,7 @@ public class CommonProxy
* @param armor indicator
* @return armor index number
*/
public int getArmorIndex(String string)
public int getArmorIndex(String string)
{
return 0;
}
@ -82,7 +82,7 @@ public class CommonProxy
* @param z - gui's z position
* @return the GuiScreen of the interface
*/
public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z)
public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}

View file

@ -0,0 +1,28 @@
package net.uberkat.obsidian.common;
/**
* This class is designated to provide easy packet management in PacketHandler. Each type of packet is assigned to a
* unique ID, which is sent to the server or client as a data int and then handled in PacketHandler along with it's
* corresponding data.
* @author AidanBrady
*
*/
public enum EnumPacketType
{
/** Used for sending a time update to the server. Send this along with an int between 0 and 24. */
TIME(0),
/** Used for sending a weather update to the server. Send this along with an EnumWeatherType. */
WEATHER(1),
/** Used for sending a tile entity update to the server. Send this along with x, y, and z coordinates of the block. */
TILE_ENTITY(2),
/** A custom packet type. Handled in PacketHandler. */
CUSTOM(3);
/** The ID of the packet type */
public final int id;
private EnumPacketType(int i)
{
id = i;
}
}

View file

@ -0,0 +1,28 @@
package net.uberkat.obsidian.common;
/**
* This class is designated for easy management of weather packets sent to the server. Each weather type is set to a
* unique ID, which is sent to the server as a data int and handled in PacketHandler.
* @author AidanBrady
*
*/
public enum EnumWeatherType
{
/** Clears the world of all weather effects, including rain, lightning, and clouds. */
CLEAR(0),
/** Sets the world's weather to thunder. This may or may not include rain. */
STORM(1),
/** Sets the world's weather to both thunder AND rain. */
HAZE(2),
/** Sets the world's weather to rain. */
RAIN(3);
/** The ID of the weather type */
public final int id;
private EnumWeatherType(int i)
{
id = i;
}
}

View file

@ -3,7 +3,7 @@ package net.uberkat.obsidian.common;
import net.minecraft.src.*;
/**
* Item class for handling multiple IDs.
* Item class for handling multiple IDs.
* 0: Platinum Ore
* 1: Platinum Block
* 2: Redstone Block

View file

@ -35,7 +35,7 @@ import cpw.mods.fml.common.registry.TickRegistry;
* @author AidanBrady
*
*/
@Mod(modid = "ObsidianIngots", name = "Obsidian Ingots", version = "4.0.6")
@Mod(modid = "ObsidianIngots", name = "Obsidian Ingots", version = "4.0.8")
@NetworkMod(channels = { "ObsidianIngots" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class ObsidianIngots
{
@ -56,11 +56,19 @@ public class ObsidianIngots
/** Obsidian Ingots configuration instance */
public static Configuration configuration;
//Initial Declarations
public static Version versionNumber = new Version(4, 0, 6);
/** Obsidian Ingots version number */
public static Version versionNumber = new Version(4, 0, 8);
/** The latest version number which is received from the Obsidian Ingots server */
public static String latestVersionNumber;
/** The recent news which is received from the Obsidian Ingots server */
public static String recentNews;
/** The IP used to connect to the Obsidian Ingots server */
public static String hostIP = "71.56.58.57";
/** The port used to connect to the Obsidian Ingots server */
public static int hostPort = 3073;
//Enums: Tools
@ -83,13 +91,13 @@ public class ObsidianIngots
public static EnumArmorMaterial armorGLOWSTONE = EnumHelper.addArmorMaterial("GLOWSTONE", 18, new int[]{3, 7, 6, 3}, 50);
//Block IDs
public static int multiBlockID = 200;
public static int obsidianTNTID = 201;
public static int elementizerID = 202;
public static int enrichmentChamberID = 203;
public static int platinumCompressorID = 204;
public static int combinerID = 205;
public static int crusherID = 206;
public static int multiBlockID = 3000;
public static int obsidianTNTID = 3001;
public static int elementizerID = 3002;
public static int enrichmentChamberID = 3003;
public static int platinumCompressorID = 3004;
public static int combinerID = 3005;
public static int crusherID = 3006;
//Base Items
public static Item WoodPaxel;

View file

@ -151,7 +151,7 @@ public class ObsidianUtils
}
/**
* Creates a fake explosion, with only sounds and effects. No damage is caused to either the blocks or the player.
* Creates a fake explosion, with only sounds and effects. No damage is caused to either blocks or the player.
* @param entityplayer - player to explode
*/
public static void doExplosion(EntityPlayer entityplayer)

View file

@ -35,7 +35,7 @@ public class OreHandler implements IWorldGenerator
int randPosX = chunkX + random.nextInt(16);
int randPosY = random.nextInt(60);
int randPosZ = chunkZ + random.nextInt(16);
(new WorldGenMinable(new ItemStack(ObsidianIngots.MultiBlock, 1, 0).itemID, 16)).generate(world, random, randPosX, randPosY, randPosZ);
(new WorldGenMinable(new ItemStack(ObsidianIngots.MultiBlock, 1, 0).itemID, 8)).generate(world, random, randPosX, randPosY, randPosZ);
}
}
}

View file

@ -24,7 +24,7 @@ import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.server.FMLServerHandler;
/**
* Obsidian Ingots packet handler. As always, use packets sparingly!
* Obsidian Ingots packet handler. As always, use packets sparingly!
* @author AidanBrady
*
*/
@ -38,32 +38,37 @@ public class PacketHandler implements IPacketHandler
if(packet.channel.equals("ObsidianIngots"))
{
try {
int packetData = dataStream.readInt();
int packetType = dataStream.readInt();
if(packetData == 0)
if(packetType == EnumPacketType.TIME.id)
{
System.out.println("[ObsidianIngots] Received '0' packet from " + entityplayer.username + ".");
ObsidianUtils.setHourForward(ModLoader.getMinecraftServerInstance().worldServerForDimension(0), 0);
System.out.println("[ObsidianIngots] Received time update packet from " + entityplayer.username + ".");
ObsidianUtils.setHourForward(ModLoader.getMinecraftServerInstance().worldServerForDimension(0), dataStream.readInt());
}
if(packetData == 1)
if(packetType == EnumPacketType.WEATHER.id)
{
System.out.println("[ObsidianIngots] Received '1' packet from " + entityplayer.username + ".");
ObsidianUtils.setHourForward(ModLoader.getMinecraftServerInstance().worldServerForDimension(0), 6);
System.out.println("[ObsidianIngots] Received weather update packet from " + entityplayer.username + ".");
int weatherType = dataStream.readInt();
if(weatherType == EnumWeatherType.CLEAR.id)
{
entityplayer.worldObj.getWorldInfo().setRaining(false);
entityplayer.worldObj.getWorldInfo().setThundering(false);
}
if(weatherType == EnumWeatherType.HAZE.id)
{
entityplayer.worldObj.getWorldInfo().setRaining(true);
entityplayer.worldObj.getWorldInfo().setThundering(true);
}
if(weatherType == EnumWeatherType.RAIN.id)
{
entityplayer.worldObj.getWorldInfo().setRaining(true);
}
if(weatherType == EnumWeatherType.STORM.id)
{
entityplayer.worldObj.getWorldInfo().setThundering(true);
}
}
if(packetData == 2)
{
System.out.println("[ObsidianIngots] Received '2' packet from " + entityplayer.username + ".");
ObsidianUtils.setHourForward(ModLoader.getMinecraftServerInstance().worldServerForDimension(0), 12);
}
if(packetData == 3)
{
System.out.println("[ObsidianIngots] Received '3' packet from " + entityplayer.username + ".");
ObsidianUtils.setHourForward(ModLoader.getMinecraftServerInstance().worldServerForDimension(0), 18);
}
if(packetData == 4)
if(packetType == EnumPacketType.TILE_ENTITY.id)
{
try {
int x = dataStream.readInt();
@ -82,28 +87,6 @@ public class PacketHandler implements IPacketHandler
e.printStackTrace();
}
}
if(packetData == 5)
{
System.out.println("[ObsidianIngots] Recieved '5' packet from " + entityplayer.username + ".");
entityplayer.worldObj.getWorldInfo().setRaining(false);
entityplayer.worldObj.getWorldInfo().setThundering(false);
}
if(packetData == 6)
{
System.out.println("[ObsidianIngots] Recieved '6' packet from " + entityplayer.username + ".");
entityplayer.worldObj.getWorldInfo().setRaining(true);
entityplayer.worldObj.getWorldInfo().setThundering(true);
}
if(packetData == 7)
{
System.out.println("[ObsidianIngots] Recieved '7' packet from " + entityplayer.username + ".");
entityplayer.worldObj.getWorldInfo().setThundering(true);
}
if(packetData == 8)
{
System.out.println("[ObsidianIngots] Recieved '8' packet from " + entityplayer.username + ".");
entityplayer.worldObj.getWorldInfo().setRaining(true);
}
}
catch (Exception e)
{
@ -124,7 +107,7 @@ public class PacketHandler implements IPacketHandler
DataOutputStream output = new DataOutputStream(bytes);
try {
output.writeInt(4);
output.writeInt(2);
output.writeInt(sender.xCoord);
output.writeInt(sender.yCoord);
output.writeInt(sender.zCoord);
@ -152,13 +135,15 @@ public class PacketHandler implements IPacketHandler
/**
* Sends the server the defined packet data int.
* @param type - packet type
* @param i - int to send
*/
public static void sendPacketDataInt(int i)
public static void sendPacketDataInt(EnumPacketType type, int i)
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
DataOutputStream data = new DataOutputStream(bytes);
try {
data.writeInt(type.id);
data.writeInt(i);
} catch (IOException e) {
System.out.println("[ObsidianIngots] An error occured while writing packet data.");
@ -169,6 +154,6 @@ public class PacketHandler implements IPacketHandler
packet.data = bytes.toByteArray();
packet.length = packet.data.length;
PacketDispatcher.sendPacketToServer(packet);
System.out.println("[ObsidianIngots] Sent '" + i + "' packet to server");
System.out.println("[ObsidianIngots] Sent data int packet '" + i + "' to server");
}
}

View file

@ -13,7 +13,7 @@ import net.minecraftforge.common.ISidedInventory;
import net.uberkat.obsidian.client.AudioManager;
import net.uberkat.obsidian.client.AudioSource;
public class TileEntityMachine extends TileEntity implements IInventory, ISidedInventory, INetworkedMachine
public abstract class TileEntityMachine extends TileEntity implements IInventory, ISidedInventory, INetworkedMachine
{
/** The ItemStacks that hold the items currently being used in the furnace */
protected ItemStack[] machineItemStacks = new ItemStack[3];
@ -103,7 +103,7 @@ public class TileEntityMachine extends TileEntity implements IInventory, ISidedI
/**
* Update call for machines, called every tick. Use this instead of updateEntity().
*/
public void onUpdate() {}
public abstract void onUpdate();
/**
* Synchronizes the client with the server on startup by sending two packets.
@ -245,9 +245,7 @@ public class TileEntityMachine extends TileEntity implements IInventory, ISidedI
public void updateTexture(World world, int x, int y, int z)
{
if(textureIndex < 15) textureIndex++;
if(textureIndex == 15) textureIndex = 0;
textureIndex = (++textureIndex)%15;
world.markBlockAsNeedsUpdate(x, y, z);
}

View file

@ -41,7 +41,6 @@ import net.uberkat.obsidian.common.TileEntityTheoreticalElementizer;
*/
public class ClientProxy extends CommonProxy
{
@Override
public int getArmorIndex(String string)
{
return RenderingRegistry.addNewArmourRendererPrefix(string);

View file

@ -3,6 +3,7 @@ package net.uberkat.obsidian.client;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
import net.uberkat.obsidian.common.EnumPacketType;
import net.uberkat.obsidian.common.ObsidianUtils;
import net.uberkat.obsidian.common.PacketHandler;
@ -20,12 +21,12 @@ public class GuiStopwatch extends GuiScreen {
public void initGui()
{
controlList.clear();
controlList.add(new GuiButton(1, width / 2 - 80, height / 2 - 65, 50, 20, "Sunrise"));
controlList.add(new GuiButton(2, width / 2 - 80, height / 2 - 35, 50, 20, "Noon"));
controlList.add(new GuiButton(3, width / 2 + 5, height / 2 - 65, 50, 20, "Sunset"));
controlList.add(new GuiButton(4, width / 2 + 5, height / 2 - 35, 50, 20, "Midnight"));
controlList.add(new GuiButton(5, width / 2 - 94, height / 2 + 30, 80, 20, "Credits"));
controlList.add(new GuiButton(6, width / 2 - 10, height / 2 + 30, 80, 20, "Close"));
controlList.add(new GuiButton(0, width / 2 - 80, height / 2 - 65, 50, 20, "Sunrise"));
controlList.add(new GuiButton(1, width / 2 - 80, height / 2 - 35, 50, 20, "Noon"));
controlList.add(new GuiButton(2, width / 2 + 5, height / 2 - 65, 50, 20, "Sunset"));
controlList.add(new GuiButton(3, width / 2 + 5, height / 2 - 35, 50, 20, "Midnight"));
controlList.add(new GuiButton(4, width / 2 - 94, height / 2 + 30, 80, 20, "Credits"));
controlList.add(new GuiButton(5, width / 2 - 10, height / 2 + 30, 80, 20, "Close"));
}
public void drawScreen(int i, int j, float f)
@ -57,39 +58,39 @@ public class GuiStopwatch extends GuiScreen {
public void actionPerformed(GuiButton guibutton)
{
if(guibutton.id == 0)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.TIME, 0);
mc.displayGuiScreen(null);
}
if(guibutton.id == 1)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(0);
PacketHandler.sendPacketDataInt(EnumPacketType.TIME, 6);
mc.displayGuiScreen(null);
}
if(guibutton.id == 2)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(1);
PacketHandler.sendPacketDataInt(EnumPacketType.TIME, 12);
mc.displayGuiScreen(null);
}
if(guibutton.id == 3)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(2);
PacketHandler.sendPacketDataInt(EnumPacketType.TIME, 18);
mc.displayGuiScreen(null);
}
if(guibutton.id == 4)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(3);
mc.displayGuiScreen(null);
}
if(guibutton.id == 5)
{
mc.displayGuiScreen(new GuiCredits());
}
if(guibutton.id == 6)
if(guibutton.id == 5)
{
mc.displayGuiScreen(null);
}

View file

@ -3,6 +3,8 @@ package net.uberkat.obsidian.client;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
import net.uberkat.obsidian.common.EnumPacketType;
import net.uberkat.obsidian.common.EnumWeatherType;
import net.uberkat.obsidian.common.ObsidianUtils;
import net.uberkat.obsidian.common.PacketHandler;
@ -20,12 +22,12 @@ public class GuiWeatherOrb extends GuiScreen {
public void initGui()
{
controlList.clear();
controlList.add(new GuiButton(1, width / 2 - 80, height / 2 - 65, 50, 20, "Clear"));
controlList.add(new GuiButton(2, width / 2 - 80, height / 2 - 35, 50, 20, "Storm"));
controlList.add(new GuiButton(3, width / 2 + 5, height / 2 - 65, 50, 20, "Haze"));
controlList.add(new GuiButton(4, width / 2 + 5, height / 2 - 35, 50, 20, "Rain"));
controlList.add(new GuiButton(5, width / 2 - 94, height / 2 + 30, 80, 20, "Credits"));
controlList.add(new GuiButton(6, width / 2 - 10, height / 2 + 30, 80, 20, "Close"));
controlList.add(new GuiButton(0, width / 2 - 80, height / 2 - 65, 50, 20, "Clear"));
controlList.add(new GuiButton(1, width / 2 - 80, height / 2 - 35, 50, 20, "Storm"));
controlList.add(new GuiButton(2, width / 2 + 5, height / 2 - 65, 50, 20, "Haze"));
controlList.add(new GuiButton(3, width / 2 + 5, height / 2 - 35, 50, 20, "Rain"));
controlList.add(new GuiButton(4, width / 2 - 94, height / 2 + 30, 80, 20, "Credits"));
controlList.add(new GuiButton(5, width / 2 - 10, height / 2 + 30, 80, 20, "Close"));
}
public void drawScreen(int i, int j, float f)
@ -57,39 +59,39 @@ public class GuiWeatherOrb extends GuiScreen {
public void actionPerformed(GuiButton guibutton)
{
if(guibutton.id == 0)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(EnumPacketType.WEATHER, EnumWeatherType.CLEAR.id);
mc.displayGuiScreen(null);
}
if(guibutton.id == 1)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(5);
PacketHandler.sendPacketDataInt(EnumPacketType.WEATHER, EnumWeatherType.STORM.id);
mc.displayGuiScreen(null);
}
if(guibutton.id == 2)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(6);
PacketHandler.sendPacketDataInt(EnumPacketType.WEATHER, EnumWeatherType.HAZE.id);
mc.displayGuiScreen(null);
}
if(guibutton.id == 3)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(7);
PacketHandler.sendPacketDataInt(EnumPacketType.WEATHER, EnumWeatherType.RAIN.id);
mc.displayGuiScreen(null);
}
if(guibutton.id == 4)
{
player.inventory.getCurrentItem().damageItem(4999, player);
ObsidianUtils.doExplosion(player);
PacketHandler.sendPacketDataInt(8);
mc.displayGuiScreen(null);
}
if(guibutton.id == 5)
{
mc.displayGuiScreen(new GuiCredits());
}
if(guibutton.id == 6)
if(guibutton.id == 5)
{
mc.displayGuiScreen(null);
}