master
mDiyo 2013-06-04 22:49:44 -07:00
parent 5f73c2152e
commit 9637de4acd
23 changed files with 1800 additions and 496 deletions

View File

@ -38,7 +38,7 @@ import cpw.mods.fml.common.registry.VillagerRegistry;
* @dependencies: IC2 API, MFR API
*/
@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.3.4", dependencies = "required-after:Forge@[7.7.1.675,)")
@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.3.4.5", dependencies = "required-after:Forge@[7.7.1.675,)")
@NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = mods.tinker.tconstruct.util.network.TPacketHandler.class)
public class TConstruct
{
@ -107,8 +107,8 @@ public class TConstruct
content.modIntegration();
content.createEntities();
SkillRegistry.registerSkill("Wall Building", new WallBuilding());
SkillRegistry.registerSkill("Jump", new Jump());
/*SkillRegistry.registerSkill("Wall Building", new WallBuilding());
SkillRegistry.registerSkill("Jump", new Jump());*/
}
public static LiquidCasting getTableCasting()

View File

@ -29,317 +29,320 @@ import cpw.mods.fml.relauncher.SideOnly;
public class OreberryBush extends BlockLeavesBase implements IPlantable
{
Random random;
public Icon[] fastIcons;
public Icon[] fancyIcons;
public String[] textureNames;
public String[] oreTypes;
public int itemMeat;
private int subitems;
Random random;
public Icon[] fastIcons;
public Icon[] fancyIcons;
public String[] textureNames;
public String[] oreTypes;
public int itemMeat;
private int subitems;
public OreberryBush(int id, String[] textureNames, int meta, int sub, String[] oreTypes)
{
super(id, Material.leaves, false);
this.textureNames = textureNames;
this.itemMeat = meta;
this.subitems = sub;
this.oreTypes = oreTypes;
this.setTickRandomly(true);
random = new Random();
this.setHardness(0.3F);
this.setStepSound(Block.soundMetalFootstep);
this.setCreativeTab(TConstructRegistry.blockTab);
}
public OreberryBush(int id, String[] textureNames, int meta, int sub, String[] oreTypes)
{
super(id, Material.leaves, false);
this.textureNames = textureNames;
this.itemMeat = meta;
this.subitems = sub;
this.oreTypes = oreTypes;
this.setTickRandomly(true);
random = new Random();
this.setHardness(0.3F);
this.setStepSound(Block.soundMetalFootstep);
this.setCreativeTab(TConstructRegistry.blockTab);
}
/* Berries show up at meta 12-15 */
/* Berries show up at meta 12-15 */
@SideOnly(Side.CLIENT)
@Override
public void registerIcons (IconRegister iconRegister)
{
this.fastIcons = new Icon[textureNames.length];
this.fancyIcons = new Icon[textureNames.length];
@SideOnly(Side.CLIENT)
@Override
public void registerIcons (IconRegister iconRegister)
{
this.fastIcons = new Icon[textureNames.length];
this.fancyIcons = new Icon[textureNames.length];
for (int i = 0; i < this.fastIcons.length; i++)
{
this.fastIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fast");
this.fancyIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fancy");
}
}
for (int i = 0; i < this.fastIcons.length; i++)
{
if (textureNames[i] != "")
{
this.fastIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fast");
this.fancyIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fancy");
}
}
}
@Override
public Icon getIcon (int side, int metadata)
{
if (graphicsLevel)
{
if (metadata < 12)
{
return fancyIcons[metadata % 4];
}
else
{
return fancyIcons[metadata % 4 + 4];
}
}
else
{
if (metadata < 12)
{
return fastIcons[metadata % 4];
}
else
{
return fastIcons[metadata % 4 + 4];
}
}
}
@Override
public Icon getIcon (int side, int metadata)
{
if (graphicsLevel)
{
if (metadata < 12)
{
return fancyIcons[metadata % 4];
}
else
{
return fancyIcons[metadata % 4 + 4];
}
}
else
{
if (metadata < 12)
{
return fastIcons[metadata % 4];
}
else
{
return fastIcons[metadata % 4 + 4];
}
}
}
/* Bushes are stored by size then type */
@Override
public int damageDropped (int metadata)
{
return metadata % 4;
}
/* Bushes are stored by size then type */
@Override
public int damageDropped (int metadata)
{
return metadata % 4;
}
/* The following methods define a berry bush's size depending on metadata */
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
{
int l = world.getBlockMetadata(x, y, z);
if (l < 4)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D);
}
else if (l < 8)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
}
else
{
return AxisAlignedBB.getBoundingBox(x+0.0625, y, z+0.0625, (double) x + 0.9375D, (double) y + 0.9375D, (double) z + 0.9375D);
}
}
/* The following methods define a berry bush's size depending on metadata */
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
{
int l = world.getBlockMetadata(x, y, z);
if (l < 4)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D);
}
else if (l < 8)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
}
else
{
return AxisAlignedBB.getBoundingBox(x + 0.0625, y, z + 0.0625, (double) x + 0.9375D, (double) y + 0.9375D, (double) z + 0.9375D);
}
}
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
{
int l = world.getBlockMetadata(x, y, z);
if (l < 4)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D);
}
else if (l < 8)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
}
else
{
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 1.0D, (double) z + 1.0D);
}
}
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
{
int l = world.getBlockMetadata(x, y, z);
if (l < 4)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D);
}
else if (l < 8)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
}
else
{
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 1.0D, (double) z + 1.0D);
}
}
@Override
public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int x, int y, int z)
{
int md = iblockaccess.getBlockMetadata(x, y, z);
@Override
public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int x, int y, int z)
{
int md = iblockaccess.getBlockMetadata(x, y, z);
float minX;
float minY = 0F;
float minZ;
float maxX;
float maxY;
float maxZ;
float minX;
float minY = 0F;
float minZ;
float maxX;
float maxY;
float maxZ;
if (md < 4)
{
minX = minZ = 0.25F;
maxX = maxZ = 0.75F;
maxY = 0.5F;
}
else
if (md < 4)
{
minX = minZ = 0.25F;
maxX = maxZ = 0.75F;
maxY = 0.5F;
}
else
if (md < 8)
{
minX = minZ = 0.125F;
maxX = maxZ = 0.875F;
maxY = 0.75F;
}
if (md < 8)
{
minX = minZ = 0.125F;
maxX = maxZ = 0.875F;
maxY = 0.75F;
}
else
{
minX = minZ = 0.0F;
maxX = maxZ = 1.0F;
maxY = 1.0F;
}
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
else
{
minX = minZ = 0.0F;
maxX = maxZ = 1.0F;
maxY = 1.0F;
}
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
/* Left-click harvests berries */
@Override
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player)
{
if (!world.isRemote)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 12)
{
world.setBlock(x, y, z, blockID, meta - 4, 3);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.oreBerries, 1, meta % 4 + itemMeat));
}
}
}
/* Left-click harvests berries */
@Override
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player)
{
if (!world.isRemote)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 12)
{
world.setBlock(x, y, z, blockID, meta - 4, 3);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.oreBerries, 1, meta % 4 + itemMeat));
}
}
}
/* Right-click harvests berries */
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
/*if (world.isRemote)
return false;*/
/* Right-click harvests berries */
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
/*if (world.isRemote)
return false;*/
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 12)
{
if (world.isRemote)
return true;
world.setBlock(x, y, z, blockID, meta - 4, 3);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.oreBerries, 1, meta % 4 + itemMeat));
return true;
}
return false;
}
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 12)
{
if (world.isRemote)
return true;
/* Render logic */
world.setBlock(x, y, z, blockID, meta - 4, 3);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.oreBerries, 1, meta % 4 + itemMeat));
return true;
}
@Override
public boolean isOpaqueCube ()
{
return false;
}
return false;
}
public void setGraphicsLevel (boolean flag)
{
graphicsLevel = flag;
}
/* Render logic */
@Override
public boolean renderAsNormalBlock ()
{
return false;
}
@Override
public boolean isOpaqueCube ()
{
return false;
}
public int getRenderType ()
{
return OreberryRender.model;
}
public void setGraphicsLevel (boolean flag)
{
graphicsLevel = flag;
}
public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int x, int y, int z, int meta)
{
if (meta > 7 || graphicsLevel)
{
return super.shouldSideBeRendered(iblockaccess, x, y, z, meta);
}
else
{
return true;
}
}
@Override
public boolean renderAsNormalBlock ()
{
return false;
}
/* Bush growth */
public int getRenderType ()
{
return OreberryRender.model;
}
@Override
public void updateTick (World world, int x, int y, int z, Random random1)
{
if (world.isRemote)
{
return;
}
public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int x, int y, int z, int meta)
{
if (meta > 7 || graphicsLevel)
{
return super.shouldSideBeRendered(iblockaccess, x, y, z, meta);
}
else
{
return true;
}
}
if (random1.nextInt(20) == 0)// && world.getBlockLightValue(x, y, z) <= 8)
{
int meta = world.getBlockMetadata(x, y, z);
if (world.getFullBlockLightValue(x, y, z) < 10)
{
if (meta < 12)
{
world.setBlock(x, y, z, blockID, meta + 4, 3);
}
}
else if (meta < 8)
{
world.setBlock(x, y, z, blockID, meta + 4, 3);
}
}
}
public boolean canSustainPlant(World world, int x, int y, int z, ForgeDirection direction, IPlantable plant)
{
if (plant instanceof OreberryBush)
return (world.getBlockMetadata(x, y, z) > 7);
return super.canSustainPlant(world, x, y, z, direction, plant);
}
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
if (world.getFullBlockLightValue(x, y, z) < 13)
return super.canPlaceBlockAt(world, x, y, z);
return false;
}
/* Bush growth */
/* Resistance to fire */
@Override
public void updateTick (World world, int x, int y, int z, Random random1)
{
if (world.isRemote)
{
return;
}
@Override
public int getFlammability (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
return 0;
}
if (random1.nextInt(20) == 0)// && world.getBlockLightValue(x, y, z) <= 8)
{
int meta = world.getBlockMetadata(x, y, z);
if (world.getFullBlockLightValue(x, y, z) < 10)
{
if (meta < 12)
{
world.setBlock(x, y, z, blockID, meta + 4, 3);
}
}
else if (meta < 8)
{
world.setBlock(x, y, z, blockID, meta + 4, 3);
}
}
}
@Override
public boolean isFlammable (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
return false;
}
public boolean canSustainPlant (World world, int x, int y, int z, ForgeDirection direction, IPlantable plant)
{
if (plant instanceof OreberryBush)
return (world.getBlockMetadata(x, y, z) > 7);
return super.canSustainPlant(world, x, y, z, direction, plant);
}
@Override
public int getFireSpreadSpeed (World world, int x, int y, int z, int metadata, ForgeDirection face)
{
return 0;
}
public boolean canPlaceBlockAt (World world, int x, int y, int z)
{
if (world.getFullBlockLightValue(x, y, z) < 13)
return super.canPlaceBlockAt(world, x, y, z);
return false;
}
/**
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int var4 = 8; var4 < 8+subitems; ++var4)
{
par3List.add(new ItemStack(par1, 1, var4));
}
}
/* Resistance to fire */
@Override
public EnumPlantType getPlantType (World world, int x, int y, int z)
{
return EnumPlantType.Cave;
}
@Override
public int getFlammability (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
return 0;
}
@Override
public int getPlantID (World world, int x, int y, int z)
{
return this.blockID;
}
@Override
public boolean isFlammable (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
return false;
}
@Override
public int getPlantMetadata (World world, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z) - 4;
}
public void onEntityCollidedWithBlock (World world, int i, int j, int k, Entity entity)
{
if (!(entity instanceof EntityItem))
entity.attackEntityFrom(DamageSource.cactus, 1);
}
@Override
public int getFireSpreadSpeed (World world, int x, int y, int z, int metadata, ForgeDirection face)
{
return 0;
}
/**
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int var4 = 8; var4 < 8 + subitems; ++var4)
{
par3List.add(new ItemStack(par1, 1, var4));
}
}
@Override
public EnumPlantType getPlantType (World world, int x, int y, int z)
{
return EnumPlantType.Cave;
}
@Override
public int getPlantID (World world, int x, int y, int z)
{
return this.blockID;
}
@Override
public int getPlantMetadata (World world, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z) - 4;
}
public void onEntityCollidedWithBlock (World world, int i, int j, int k, Entity entity)
{
if (!(entity instanceof EntityItem))
entity.attackEntityFrom(DamageSource.cactus, 1);
}
}

View File

@ -47,8 +47,25 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi
if (drainte != null && drainte instanceof ITankContainer && tankte != null && tankte instanceof ITankContainer)
{
liquid = ((ITankContainer) drainte).drain(getForgeDirection(), TConstruct.ingotLiquidValue, true);
if (liquid != null)
LiquidStack templiquid = ((ITankContainer) drainte).drain(getForgeDirection(), TConstruct.ingotLiquidValue, false);
System.out.println("Rawr "+templiquid);
if (templiquid != null)
{
int drained = ((ITankContainer) tankte).fill(ForgeDirection.UP, templiquid, false);
if (drained > 0)
{
liquid = ((ITankContainer) drainte).drain(getForgeDirection(), drained, true);
((ITankContainer) tankte).fill(ForgeDirection.UP, liquid, true);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return true;
}
else
{
return false;
}
}
/*if (liquid != null)
{
int drained = ((ITankContainer) tankte).fill(ForgeDirection.UP, liquid, true);
if (drained != liquid.amount)
@ -71,7 +88,7 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi
else
{
((ITankContainer) drainte).fill(getForgeDirection(), liquid, true);
}
}*/
}
}
return false;

View File

@ -0,0 +1,92 @@
package mods.tinker.tconstruct.blocks.traps;
import mods.tinker.tconstruct.client.block.BarricadeRender;
import mods.tinker.tconstruct.library.TConstructRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BarricadeBlock extends Block
{
public BarricadeBlock(int blockID)//, String name, int texture)
{
super(blockID, Material.wood);
setHardness(4.0F);
this.setCreativeTab(TConstructRegistry.blockTab);
//setUnlocalizedName("barricade" + name);
//GameRegistry.addName(this, name + " Barricade");
}
public Icon getIcon(int side, int meta)
{
return Block.wood.getIcon(2, meta % 4);
}
public boolean renderAsNormalBlock ()
{
return false;
}
public boolean isOpaqueCube ()
{
return false;
}
public int getRenderType ()
{
return BarricadeRender.model;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int x, int y, int z)
{
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
}
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int x, int y, int z)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta)
{
if (meta % 4 > 0)
{
world.setBlock(x, y, z, this.blockID, meta - 1, 3);
dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
}
else
{
dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
}
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
ItemStack stack = player.getCurrentEquippedItem();
if ((stack != null) && (stack.itemID == this.blockID) && (!player.isSneaking()))
{
int meta = world.getBlockMetadata(x, y, z);
if (meta % 4 != 3)
{
world.setBlock(x, y, z, this.blockID, meta + 1, 3);
Block.blocksList[this.blockID].onBlockPlacedBy(world, x, y, z, player, stack);
Block.blocksList[this.blockID].onPostBlockPlaced(world, x, y, z, meta);
Block var9 = Block.blocksList[this.blockID];
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, var9.stepSound.getStepSound(), (var9.stepSound.getVolume() + 1.0F) / 2.0F, var9.stepSound.getPitch() * 0.8F);
player.swingItem();
if (!player.capabilities.isCreativeMode)
stack.stackSize -= 1;
return true;
}
}
return false;
}
}

View File

@ -1,4 +1,4 @@
package mods.tinker.tconstruct.blocks;
package mods.tinker.tconstruct.blocks.traps;
import java.util.Iterator;
import java.util.List;
@ -9,10 +9,12 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockFence;
import net.minecraft.block.EnumMobType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@ -30,6 +32,26 @@ public class Landmine extends Block
float var5 = 0.0625F;
this.setBlockBounds(var5, 0.0F, var5, 1.0F - var5, 0.03125F, 1.0F - var5);
}
public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
{
Block block = Block.blocksList[world.getBlockId(x, y-1, z)];
if (block != null)
{
return block.getBlockTexture(world, x, y-1, z, side);
}
return Block.sponge.getIcon(side, world.getBlockMetadata(x, y, z));
}
public Icon getIcon(int side, int meta)
{
return Block.sponge.getIcon(1, meta);
}
public void registerIcons(IconRegister par1IconRegister)
{
}
/**
* How many world ticks before ticking
@ -169,7 +191,7 @@ public class Landmine extends Block
if (var6 && !var5)
{
//world.setBlock(posX, posY, posZ, 0);
world.setBlock(posX, posY, posZ, 0);
world.createExplosion((Entity)null, posX, posY, posZ, 2.0F, true);
/*par1World.setBlockMetadataWithNotify(posX, posY, posZ, 1);
par1World.notifyBlocksOfNeighborChange(posX, posY, posZ, this.blockID);

View File

@ -1,7 +1,5 @@
package mods.tinker.tconstruct.client;
import java.util.List;
import mods.tinker.tconstruct.TConstruct;
import mods.tinker.tconstruct.client.armor.WingModel;
import mods.tinker.tconstruct.common.TContent;
@ -12,13 +10,10 @@ import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.liquids.LiquidStack;
import org.lwjgl.opengl.GL11;
@ -30,7 +25,6 @@ import cpw.mods.fml.relauncher.SideOnly;
public class TClientEvents
{
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player;
/*@ForgeSubscribe
public void interact (PlayerInteractEvent event)
@ -80,21 +74,19 @@ public class TClientEvents
@ForgeSubscribe
public void renderHealthbar (RenderGameOverlayEvent.Post event)
{
if (player == null)
player = mc.thePlayer;
ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
int scaledWidth = scaledresolution.getScaledWidth();
int scaledHeight = scaledresolution.getScaledHeight();
int xBasePos = scaledWidth / 2 - 91;
int yBasePos = scaledHeight - 39;
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(mc.thePlayer.username);
if (event.type == RenderGameOverlayEvent.ElementType.HEALTH)
{
this.mc.renderEngine.bindTexture("/mods/tinker/textures/gui/newhearts.png");
int hp = player.getHealth();
int hp = mc.thePlayer.getHealth();
for (int iter = 0; iter < hp / 20; iter++)
{
int renderHearts = (hp - 20*(iter+1)) / 2;
@ -113,8 +105,11 @@ public class TClientEvents
this.mc.renderEngine.bindTexture("/gui/icons.png");
}
if (event.type == RenderGameOverlayEvent.ElementType.HOTBAR)
/*if (event.type == RenderGameOverlayEvent.ElementType.HOTBAR)
{
if (stats.skillList == null)
return;
int amount = 0;
GL11.glScalef(1/16f, 1/16f, 1/16f);
for (Skill skill : stats.skillList)
@ -126,7 +121,7 @@ public class TClientEvents
amount++;
}
GL11.glScalef(16f, 16f, 16f);
}
}*/
}
public void drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6)

View File

@ -12,6 +12,7 @@ import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.network.PacketDispatcher;
@ -20,11 +21,11 @@ public class TControls extends TKeyHandler
//static KeyBinding grabKey = new KeyBinding("key.grab", 29);
//static KeyBinding stiltsKey = new KeyBinding("key.stilts", 46);
public static KeyBinding armorKey = new KeyBinding("key.tarmor", 24);
public static KeyBinding skillOne = new KeyBinding("key.skill.one", 44);
/*public static KeyBinding skillOne = new KeyBinding("key.skill.one", 44);
public static KeyBinding skillTwo = new KeyBinding("key.skill.two", 45);
public static KeyBinding skillThree = new KeyBinding("key.skill.three", 46);
public static KeyBinding skillFour = new KeyBinding("key.skill.four", 47);
public static KeyBinding skillFive = new KeyBinding("key.skill.five", 48);
public static KeyBinding skillFive = new KeyBinding("key.skill.five", 48);*/
static KeyBinding jumpKey;
static KeyBinding invKey;
static Minecraft mc;
@ -39,7 +40,7 @@ public class TControls extends TKeyHandler
public TControls()
{
super(new KeyBinding[] { armorKey, skillOne, skillTwo, skillThree, skillFour, skillFive }, new boolean[] { false, false, false, false, false, false }, getVanillaKeyBindings(), new boolean[] {
super(new KeyBinding[] { armorKey/*, skillOne, skillTwo, skillThree, skillFour, skillFive*/ }, new boolean[] { false/*, false, false, false, false, false*/ }, getVanillaKeyBindings(), new boolean[] {
false, false });
//System.out.println("Controls registered");Natura
}
@ -71,7 +72,7 @@ public class TControls extends TKeyHandler
{
TProxyClient.addTabsToInventory();
}
if (kb == skillOne)
/*if (kb == skillOne)
{
sendSkillkey(mc.thePlayer, (byte) 0);//, mc.thePlayer.dimension, mc.thePlayer.entityId);
}
@ -90,7 +91,7 @@ public class TControls extends TKeyHandler
if (kb == skillFive)
{
sendSkillkey(mc.thePlayer, (byte) 4);//, mc.thePlayer.dimension, mc.thePlayer.entityId);
}
}*/
/*if (kb == jumpKey) //Double jump
{
if (jumping && !doubleJump)
@ -211,7 +212,7 @@ public class TControls extends TKeyHandler
updateServer(bos);
}
/*public void activateSkill (EntityPlayer player, int slot)
{
if (TProxyClient.skillList.size() > slot)
@ -223,25 +224,29 @@ public class TControls extends TKeyHandler
}
}
}*/
public void sendSkillkey (EntityPlayer player, byte key)//, int dim, int id)
public void sendSkillkey (EntityPlayer player, byte key)
{
TConstruct.playerTracker.activateSkill(player, key);
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
try
{
outputStream.writeByte(4);
//outputStream.writeInt(dim);
//outputStream.writeInt(id);
outputStream.writeByte(key);
}
catch (Exception ex)
{
ex.printStackTrace();
}
updateServer(bos);
System.out.println(MinecraftServer.getServer());
if (MinecraftServer.getServer().isDedicatedServer())
{
System.out.println("Send");
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
try
{
outputStream.writeByte(4);
outputStream.writeByte(key);
}
catch (Exception ex)
{
ex.printStackTrace();
}
updateServer(bos);
}
}
static void updateServer (ByteArrayOutputStream bos)

View File

@ -10,65 +10,22 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import mods.tinker.tconstruct.TConstruct;
import mods.tinker.tconstruct.blocks.logic.CastingBasinLogic;
import mods.tinker.tconstruct.blocks.logic.CastingTableLogic;
import mods.tinker.tconstruct.blocks.logic.FrypanLogic;
import mods.tinker.tconstruct.blocks.logic.GolemCoreLogic;
import mods.tinker.tconstruct.blocks.logic.PartCrafterLogic;
import mods.tinker.tconstruct.blocks.logic.PatternChestLogic;
import mods.tinker.tconstruct.blocks.logic.PatternShaperLogic;
import mods.tinker.tconstruct.blocks.logic.SmelteryLogic;
import mods.tinker.tconstruct.blocks.logic.ToolStationLogic;
import mods.tinker.tconstruct.client.block.CastingBasinSpecialRender;
import mods.tinker.tconstruct.client.block.CastingTableSpecialRenderer;
import mods.tinker.tconstruct.client.block.FluidRender;
import mods.tinker.tconstruct.client.block.FrypanRender;
import mods.tinker.tconstruct.client.block.GolemCoreRender;
import mods.tinker.tconstruct.client.block.GolemCoreSpecialRender;
import mods.tinker.tconstruct.client.block.OreberryRender;
import mods.tinker.tconstruct.client.block.SearedRender;
import mods.tinker.tconstruct.client.block.SmallFontRenderer;
import mods.tinker.tconstruct.client.block.SmelteryRender;
import mods.tinker.tconstruct.client.block.TableRender;
import mods.tinker.tconstruct.client.block.TankRender;
import mods.tinker.tconstruct.client.entity.CartRender;
import mods.tinker.tconstruct.client.entity.CloneHeadModel;
import mods.tinker.tconstruct.client.entity.CrystalRender;
import mods.tinker.tconstruct.client.entity.FancyItemRender;
import mods.tinker.tconstruct.client.entity.GolemRender;
import mods.tinker.tconstruct.client.entity.SkylaRender;
import mods.tinker.tconstruct.client.entity.SlimeCloneRender;
import mods.tinker.tconstruct.client.entity.SlimeRender;
import mods.tinker.tconstruct.client.entity.projectile.DaggerRender;
import mods.tinker.tconstruct.client.entity.projectile.LaunchedItemRender;
import mods.tinker.tconstruct.client.gui.ArmorExtendedGui;
import mods.tinker.tconstruct.client.gui.FrypanGui;
import mods.tinker.tconstruct.client.gui.GuiManual;
import mods.tinker.tconstruct.client.gui.PartCrafterGui;
import mods.tinker.tconstruct.client.gui.PatternChestGui;
import mods.tinker.tconstruct.client.gui.PatternShaperGui;
import mods.tinker.tconstruct.client.gui.SmelteryGui;
import mods.tinker.tconstruct.client.gui.ToolStationGui;
import mods.tinker.tconstruct.blocks.logic.*;
import mods.tinker.tconstruct.client.block.*;
import mods.tinker.tconstruct.client.entity.*;
import mods.tinker.tconstruct.client.entity.projectile.*;
import mods.tinker.tconstruct.client.gui.*;
import mods.tinker.tconstruct.common.TContent;
import mods.tinker.tconstruct.common.TProxyCommon;
import mods.tinker.tconstruct.entity.BlueSlime;
import mods.tinker.tconstruct.entity.CartEntity;
import mods.tinker.tconstruct.entity.Crystal;
import mods.tinker.tconstruct.entity.FancyEntityItem;
import mods.tinker.tconstruct.entity.GolemBase;
import mods.tinker.tconstruct.entity.Skyla;
import mods.tinker.tconstruct.entity.SlimeClone;
import mods.tinker.tconstruct.entity.projectile.DaggerEntity;
import mods.tinker.tconstruct.entity.projectile.LaunchedPotion;
import mods.tinker.tconstruct.entity.*;
import mods.tinker.tconstruct.entity.projectile.*;
import mods.tinker.tconstruct.items.tools.Dagger;
import mods.tinker.tconstruct.library.TConstructRegistry;
import mods.tinker.tconstruct.library.client.TConstructClientRegistry;
import mods.tinker.tconstruct.library.client.ToolGuiElement;
import mods.tinker.tconstruct.library.crafting.ToolBuilder;
import mods.tinker.tconstruct.library.tools.ToolCore;
import mods.tinker.tconstruct.skill.Skill;
import mods.tinker.tconstruct.util.player.ArmorExtended;
import mods.tinker.tconstruct.util.player.ArmorExtendedClient;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
@ -236,6 +193,7 @@ public class TProxyClient extends TProxyCommon
RenderingRegistry.registerBlockHandler(new FluidRender());
RenderingRegistry.registerBlockHandler(new GolemCoreRender());
RenderingRegistry.registerBlockHandler(new OreberryRender());
RenderingRegistry.registerBlockHandler(new BarricadeRender());
//RenderingRegistry.registerBlockHandler(new BrickRender());
//RenderingRegistry.registerBlockHandler(new BallRepeaterRender());

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,8 @@ import mods.tinker.tconstruct.blocks.logic.PatternShaperLogic;
import mods.tinker.tconstruct.blocks.logic.SmelteryDrainLogic;
import mods.tinker.tconstruct.blocks.logic.SmelteryLogic;
import mods.tinker.tconstruct.blocks.logic.ToolStationLogic;
import mods.tinker.tconstruct.blocks.traps.BarricadeBlock;
import mods.tinker.tconstruct.blocks.traps.Landmine;
import mods.tinker.tconstruct.entity.BlueSlime;
import mods.tinker.tconstruct.entity.FancyEntityItem;
import mods.tinker.tconstruct.entity.projectile.DaggerEntity;
@ -98,6 +100,7 @@ import mods.tinker.tconstruct.modifiers.TActiveOmniMod;
import mods.tinker.tconstruct.util.PHConstruct;
import mods.tinker.tconstruct.util.RecipeRemover;
import net.minecraft.block.Block;
import net.minecraft.block.EnumMobType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialLiquid;
@ -196,6 +199,7 @@ public class TContent implements IFuelHandler
//Traps
public static Block landmine;
public static Block barricade;
//InfiBlocks
public static Block speedBlock;
@ -428,6 +432,12 @@ public class TContent implements IFuelHandler
/*golemPedestal = new GolemPedestalBlock(PHConstruct.golemPedestal).setUnlocalizedName("golempedestal");
GameRegistry.registerBlock(golemPedestal, "Golem Pedestal");
GameRegistry.registerTileEntity(GolemPedestalLogic.class, "TConstruct.GolemPedestal");*/
//Traps
/*landmine = new Landmine(PHConstruct.landmine, EnumMobType.mobs, Material.wood).setUnlocalizedName("tconstruct.landmine");
GameRegistry.registerBlock(landmine, "Landmine");
barricade = new BarricadeBlock(PHConstruct.barricade).setUnlocalizedName("tconstruct.barricade");
GameRegistry.registerBlock(barricade, "Barricade");*/
}
void registerItems ()
@ -824,7 +834,7 @@ public class TContent implements IFuelHandler
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolStationWood, 1, 1), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', "logWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(toolStationWood, 1, 10), "p", "w", 'p', new ItemStack(blankPattern, 1, 0), 'w', "plankWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blankPattern, 1, 0), "ps", "sp", 'p', "plankWood", 's', Item.stick));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blankPattern, 1, 0), "ps", "sp", 'p', "plankWood", 's', "stickWood"));
GameRegistry.addRecipe(new ItemStack(manualBook), "wp", 'w', new ItemStack(blankPattern, 1, 0), 'p', Item.paper);
GameRegistry.addShapelessRecipe(new ItemStack(manualBook, 2, 0), new ItemStack(manualBook, 1, 0), Item.book);
GameRegistry.addShapelessRecipe(new ItemStack(manualBook, 1, 1), new ItemStack(manualBook, 1, 0));
@ -911,7 +921,8 @@ public class TContent implements IFuelHandler
GameRegistry.addRecipe(new ItemStack(searedBlock, 1, 0), "bbb", "b b", "b b", 'b', searedBrick); //Table
GameRegistry.addRecipe(new ItemStack(searedBlock, 1, 1), "b b", " b ", 'b', searedBrick); //Faucet
GameRegistry.addRecipe(new ItemStack(searedBlock, 1, 2), "b b", "b b", "bbb", 'b', searedBrick); //Basin
GameRegistry.addRecipe(new ItemStack(Block.pumpkinLantern, 1, 0), "p", "s", 'p', new ItemStack(Block.pumpkin), 'w', new ItemStack(toolRod, 1, 1));
GameRegistry.addRecipe(new ItemStack(stoneTorch, 4), "p", "w", 'p', new ItemStack(Item.coal, 1, Short.MAX_VALUE), 'w', new ItemStack(toolRod, 1, 1));
GameRegistry.addRecipe(new ItemStack(toolRod, 4, 1), "c", "c", 'c', new ItemStack(Block.stone));
GameRegistry.addRecipe(new ItemStack(toolRod, 2, 1), "c", "c", 'c', new ItemStack(Block.cobblestone));

View File

@ -5,6 +5,7 @@ import mods.tinker.tconstruct.common.TContent;
import mods.tinker.tconstruct.library.TConstructRegistry;
import mods.tinker.tconstruct.library.crafting.ToolBuilder;
import mods.tinker.tconstruct.library.tools.ToolCore;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.boss.IBossDisplayData;
@ -368,6 +369,11 @@ public class BlueSlime extends EntityLiving implements IMob, IBossDisplayData
}
}
}
public boolean handleWaterMovement()
{
return false;
}
protected void func_70808_l ()
{
@ -443,7 +449,7 @@ public class BlueSlime extends EntityLiving implements IMob, IBossDisplayData
tags.setInteger("MiningSpeed", 800);
this.entityDropItem(toolStack, 0f);
if (rand.nextInt(10) == 0)
if (rand.nextInt(5) == 0)
{
ItemStack dropStack = new ItemStack(TContent.heartCanister, 1, 1);
this.entityDropItem(dropStack, 0f);

View File

@ -9,15 +9,15 @@ public class SkillRegistry
public static HashMap<String, Skill> skills = new HashMap<String, Skill>();
static int skillID = 0;
public static HashMap<Integer, String> skillMapping = new HashMap<Integer, String>(); //Simplifies network transmission
public static HashMap<Integer, Skill> skillMapping = new HashMap<Integer, Skill>(); //Simplifies network transmission
public static void registerSkill(String name, Skill skill)
{
skills.put(name, skill);
skillMapping.put(getNextID(), name);
skillMapping.put(getNextAvailableID(), skill);
}
static Integer getNextID ()
static Integer getNextAvailableID ()
{
return skillID++;
}

View File

@ -74,7 +74,7 @@ public class AbilityHelper
int durability = tags.getCompoundTag("InfiTool").getInteger("Damage");
float stonebound = tags.getCompoundTag("InfiTool").getFloat("Shoddy");
float stoneboundDamage = -stonebound * durability / 100f;
float stoneboundDamage = -stonebound * durability / 50f;
int earlyModDamage = 0;
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
@ -103,6 +103,8 @@ public class AbilityHelper
}
damage += stoneboundDamage;
if (damage < 1)
damage = 1;
if (player.isSprinting())
{
@ -338,6 +340,10 @@ public class AbilityHelper
int mineSpeed = tags.getCompoundTag("InfiTool").getInteger("MiningSpeed");
if (tags.getCompoundTag("InfiTool").hasKey("MiningSpeed2"))
mineSpeed = (mineSpeed + tags.getCompoundTag("InfiTool").getInteger("MiningSpeed2")) / 2;
int durability = tags.getInteger("Damage");
float shoddy = tags.getFloat("Shoddy");
mineSpeed += shoddy * durability / 100f;
mineSpeed /= 15;
if (charge < mineSpeed)

View File

@ -776,5 +776,77 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox
{
return true;
}
/* Proper stack damage */
public int getItemDamageFromStack(ItemStack stack)
{
NBTTagCompound tags = stack.getTagCompound();
if (tags == null)
{
/*System.out.println("Tool item is uninitalized! This method should never be called with a default item");
Exception e = new NullPointerException();
e.printStackTrace();*/
return 0;
}
if (tags.hasKey("charge"))
{
int charge = tags.getInteger("charge");
if (charge > 0)
return charge;
}
return tags.getCompoundTag("InfiTool").getInteger("Damage");
}
/**
* Return the itemDamage display value represented by this itemstack.
* @param stack the stack
* @return the damage value
*/
public int getItemDamageFromStackForDisplay(ItemStack stack)
{
NBTTagCompound tags = stack.getTagCompound();
if (tags == null)
{
/*System.out.println("Tool item is uninitalized! This method should never be called with a default item");
Exception e = new NullPointerException();
e.printStackTrace();*/
return 0;
}
if (tags.hasKey("charge"))
{
int charge = tags.getInteger("charge");
if (charge > 0)
return charge;
}
return tags.getCompoundTag("InfiTool").getInteger("Damage");
}
/**
* Return the maxDamage for this ItemStack. Defaults to the maxDamage field in this item, but can be overridden here for other sources such as NBT.
*
* @param stack The itemstack that is damaged
* @return the damage value
*/
public int getItemMaxDamageFromStack(ItemStack stack)
{
NBTTagCompound tags = stack.getTagCompound();
if (tags == null)
{
/*System.out.println("Tool item is uninitalized! This method should never be called with a default item");
Exception e = new NullPointerException();
e.printStackTrace();*/
return 0;
}
if (tags.hasKey("charge"))
{
int charge = tags.getInteger("charge");
if (charge > 0)
return this.getMaxCharge(stack);
}
return tags.getCompoundTag("InfiTool").getInteger("TotalDurability");
}
}

View File

@ -31,7 +31,7 @@ public class TActiveOmniMod extends ActiveToolMod
@Override
public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity)
{
if (!world.isRemote && entity instanceof EntityLiving && !((EntityLiving) entity).isSwingInProgress)
if (!world.isRemote && entity instanceof EntityLiving && !((EntityLiving) entity).isSwingInProgress && stack.getTagCompound() != null)
{
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (tags.hasKey("Moss"))

View File

@ -6,7 +6,6 @@ import net.minecraft.world.World;
public class Jump extends Skill
{
@Override
public String getTextureFile (int guiscale)
{

View File

@ -12,7 +12,8 @@ import net.minecraft.world.World;
*/
public abstract class Skill
{
{
public int skillID;
boolean active = true;
public abstract String getTextureFile(int guiscale);
public abstract String getSkillName();
@ -34,6 +35,11 @@ public abstract class Skill
return 0;
}
public void setActive(boolean flag)
{
this.active = flag;
}
public boolean getActive()
{
return active;
@ -41,9 +47,21 @@ public abstract class Skill
public Skill copy() throws InstantiationException, IllegalAccessException
{
return this.getClass().newInstance();
Skill skill = this.getClass().newInstance();
skill.setSkillID(this.skillID);
return skill;
}
public void setSkillID(int i)
{
skillID = i;
}
public int getSkillID ()
{
return skillID;
}
/* Save/Load */
public void saveToNBT (NBTTagCompound tag)
{

View File

@ -6,6 +6,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
@ -13,7 +14,6 @@ import net.minecraftforge.common.ForgeDirection;
public class WallBuilding extends Skill
{
@Override
public String getTextureFile (int guiscale)
{
@ -34,7 +34,6 @@ public class WallBuilding extends Skill
@Override
public void activate (Entity entity, World world)
{
if (!world.isRemote)
this.active = !active;
}

View File

@ -83,7 +83,8 @@ public class PHConstruct
oreGravel = config.getBlock("Ores Gravel", 1488).getInt(1488);
speedBlock = config.getBlock("Speed Block", 1489).getInt(1489);
//landmine = config.getBlock("Landmine", 1481).getInt(1481);
landmine = config.getBlock("Landmine", 1470).getInt(1470);
barricade = config.getBlock("Barricade", 1469).getInt(1469);
/*golemCore = config.getBlock("Golem Core", 1481).getInt(1481);
golemHead = config.getBlock("Golem Head", 1482).getInt(1482);*/
@ -257,7 +258,8 @@ public class PHConstruct
public static int netherOreBerry;
//Traps
//public static int landmine;
public static int landmine;
public static int barricade;
//InfiBlocks
public static int speedBlock;

View File

@ -45,7 +45,7 @@ public class TEventHandler
/* Interact */
@ForgeSubscribe
/*@ForgeSubscribe
public void interact (PlayerInteractEvent event)
{
if (event.action == Action.RIGHT_CLICK_BLOCK)// && !event.entityPlayer.worldObj.isRemote)
@ -57,7 +57,7 @@ public class TEventHandler
walls.rightClickActivate(event.entityPlayer, event.entityPlayer.worldObj);
}
}
}
}*/
/*@ForgeSubscribe
public void onHurt (LivingHurtEvent event)
@ -133,14 +133,14 @@ public class TEventHandler
}
}
@ForgeSubscribe
/*@ForgeSubscribe
public void onLivingSpawn (EntityJoinWorldEvent event)
{
if (event.entity instanceof EntityXPOrb)
{
System.out.println("Entity: " + event.entity);
}
}
}*/
@ForgeSubscribe
public void onLivingSpawn (LivingSpawnEvent.SpecialSpawn event)

View File

@ -3,10 +3,14 @@ package mods.tinker.tconstruct.util.network;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import mods.tinker.tconstruct.TConstruct;
import mods.tinker.tconstruct.blocks.logic.ToolStationLogic;
import mods.tinker.tconstruct.library.SkillRegistry;
import mods.tinker.tconstruct.library.blocks.InventoryLogic;
import mods.tinker.tconstruct.skill.Skill;
import mods.tinker.tconstruct.util.player.TPlayerStats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@ -34,26 +38,33 @@ public class TPacketHandler implements IPacketHandler
if (side == Side.SERVER)
handleServerPacket(packet, (EntityPlayerMP) player);
else
handleClientPacket(packet);
handleClientPacket(packet, (EntityPlayer) player);
}
}
void handleClientPacket (Packet250CustomPayload packet)
void handleClientPacket (Packet250CustomPayload packet, EntityPlayer player)
{
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
byte packetType;
int dimension;
byte packetID;
try
{
packetID = inputStream.readByte();
dimension = inputStream.readInt();
World world = DimensionManager.getWorld(dimension);
if (packetID == 1)
{
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
stats.skillList = new ArrayList<Skill>();
int size = inputStream.readInt();
for (int i = 0; i < size; i++)
{
Skill skill = SkillRegistry.skillMapping.get(inputStream.readInt()).copy();
skill.setActive(inputStream.readBoolean());
stats.skillList.add(skill);
}
}
}
catch (IOException e)
catch (Exception e)
{
System.out.println("Failed at reading client packet for TConstruct.");
e.printStackTrace();

View File

@ -111,11 +111,11 @@ public class ArmorExtended implements IInventory
{
EntityPlayer player = parent.get();
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
recalculateSkills(player, stats);
//recalculateSkills(player, stats);
recalculateHealth(player, stats);
}
public void recalculateSkills(EntityPlayer player, TPlayerStats stats)
/*public void recalculateSkills(EntityPlayer player, TPlayerStats stats)
{
if (inventory[1] != null && inventory[1].getItem() == TContent.glove)
{
@ -138,7 +138,7 @@ public class ArmorExtended implements IInventory
stats.skillList.remove(0);
}
}
}
}*/
public void recalculateHealth(EntityPlayer player, TPlayerStats stats)
{

View File

@ -1,26 +1,30 @@
package mods.tinker.tconstruct.util.player;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import mods.tinker.tconstruct.common.TContent;
import mods.tinker.tconstruct.library.SkillRegistry;
import mods.tinker.tconstruct.library.tools.AbilityHelper;
import mods.tinker.tconstruct.skill.Skill;
import mods.tinker.tconstruct.skill.WallBuilding;
import mods.tinker.tconstruct.util.PHConstruct;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumEntitySize;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.IPlayerTracker;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.relauncher.Side;
public class TPlayerHandler implements IPlayerTracker
@ -65,22 +69,47 @@ public class TPlayerHandler implements IPlayerTracker
}
stats.skillList = new ArrayList<Skill>();
stats.armor.recalculateSkills(entityplayer, stats);
/*try
{
stats.skillList.add(SkillRegistry.skills.get("Wall Building").copy());
}
catch (Exception e)
{
e.printStackTrace();
}/*
//stats.skillList.add(new ActiveSkill(new Jump()));
/*for (Map.Entry<String, SkillBase> entry : SkillRegistry.skills.entrySet())
{
SkillBase skill = entry.getValue();
}*/
//stats.armor.recalculateSkills(entityplayer, stats);
playerStats.put(entityplayer.username, stats);
//sendSkills(entityplayer, stats);
}
void sendSkills (EntityPlayer entityplayer, TPlayerStats stats)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
List<Skill> skills = stats.skillList;
try
{
outputStream.writeByte(1);
outputStream.writeInt(skills.size());
for (Skill skill : stats.skillList)
{
outputStream.writeInt(skill.getSkillID());
outputStream.writeBoolean(skill.getActive());
}
//outputStream.writeByte(key);
}
catch (Exception ex)
{
ex.printStackTrace();
}
updateClientPlayer(bos, entityplayer);
}
void updateClientPlayer (ByteArrayOutputStream bos, EntityPlayer player)
{
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "TConstruct";
packet.data = bos.toByteArray();
packet.length = bos.size();
PacketDispatcher.sendPacketToPlayer(packet, (Player) player);
}
public void activateSkill (EntityPlayer player, int slot)
@ -163,19 +192,7 @@ public class TPlayerHandler implements IPlayerTracker
{
if (evt.entityLiving instanceof EntityPlayer)
{
/*Side side = FMLCommonHandler.instance().getEffectiveSide();
if (side == Side.CLIENT)
{
TProxyClient.controlInstance.landOnGround();
}*/
//else
//System.out.println("Server side");
evt.distance -= 1;
//evt.distance = 0;
//TPlayerStats stats = playerStats.get(((EntityPlayer)evt.entityLiving).username);
//stats.prevMotionY = evt.entityLiving.motionY;
//evt.entityLiving.motionY = 10.2;
}
}
@ -239,7 +256,7 @@ public class TPlayerHandler implements IPlayerTracker
return stats.player.get();
}
}
/* Modify Player */
public void updateSize (String user, float offset)
{
@ -291,69 +308,4 @@ public class TPlayerHandler implements IPlayerTracker
Random rand = new Random();
/* Bows */
/*@ForgeSubscribe
public void arrowShoot (ArrowLooseEvent event)
{
event.setCanceled(true);
int j = event.charge;
boolean flag = event.entityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, event.bow) > 0;
if (flag || event.entityPlayer.inventory.hasItem(Item.arrow.itemID))
{
float f = (float) j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double) f < 0.1D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntityArrow entityarrow = new EntityArrow(event.entityPlayer.worldObj, event.entityPlayer, f * 2.0F);
if (f == 1.0F)
{
entityarrow.setIsCritical(true);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, event.bow);
entityarrow.setDamage(1.5D + k * 0.45D);
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, event.bow);
if (l > 0)
{
entityarrow.setKnockbackStrength(l);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, event.bow) > 0)
{
entityarrow.setFire(100);
}
event.bow.damageItem(1, event.entityPlayer);
event.entityPlayer.worldObj.playSoundAtEntity(event.entityPlayer, "random.bow", 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (flag)
{
entityarrow.canBePickedUp = 2;
}
else
{
event.entityPlayer.inventory.consumeInventoryItem(Item.arrow.itemID);
}
if (!event.entityPlayer.worldObj.isRemote)
{
event.entityPlayer.worldObj.spawnEntityInWorld(entityarrow);
}
}
}*/
}