mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
run repo through formatter
This commit is contained in:
1 parent
5585d680a3
commit
ffaea7d4b7
140 files changed
+1050
-892
No files matched your search
@@ -75,8 +75,8 @@ public class MiningExplosion extends Explosion
|
||||
if (k1 != Blocks.air)
|
||||
{
|
||||
Block block = k1;
|
||||
float f3 = this.exploder != null ? this.exploder.func_145772_a(this, this.world, l, i1, j1, block) : block.getExplosionResistance(this.exploder, world,
|
||||
l, i1, j1, explosionX, explosionY, explosionZ);
|
||||
float f3 = this.exploder != null ? this.exploder.func_145772_a(this, this.world, l, i1, j1, block) : block.getExplosionResistance(this.exploder, world, l, i1, j1,
|
||||
explosionX, explosionY, explosionZ);
|
||||
f1 -= (f3 + 0.8F) * f2 * 0.25f;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public class SmelteryDamageSource extends DamageSource
|
||||
EntityLivingBase entityliving1 = par1EntityLiving.func_94060_bK();
|
||||
String s = "death." + type + this.damageType;
|
||||
String s1 = s + ".player";
|
||||
return entityliving1 != null && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[] {par1EntityLiving.func_145748_c_(), entityliving1.func_145748_c_()}): new ChatComponentTranslation(s, new Object[] {par1EntityLiving.func_145748_c_()});
|
||||
return entityliving1 != null && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[] { par1EntityLiving.func_145748_c_(), entityliving1.func_145748_c_() })
|
||||
: new ChatComponentTranslation(s, new Object[] { par1EntityLiving.func_145748_c_() });
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,10 @@ public class TCraftingHandler //implements ICraftingHandler
|
||||
@SubscribeEvent
|
||||
public void onCrafting (ItemCraftedEvent event)//EntityPlayer player, ItemStack itemstack, IInventory craftMatrix)
|
||||
{
|
||||
Item item = event.crafting.getItem();
|
||||
Item item = event.crafting.getItem();
|
||||
if (!event.player.worldObj.isRemote)
|
||||
{
|
||||
if (ComparisonHelper.areEquivalent(item,TRepo.toolStationWood))
|
||||
if (ComparisonHelper.areEquivalent(item, TRepo.toolStationWood))
|
||||
{
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(event.player.getDisplayName());
|
||||
NBTTagCompound tags = event.player.getEntityData().getCompoundTag("TConstruct");
|
||||
@@ -32,7 +32,7 @@ public class TCraftingHandler //implements ICraftingHandler
|
||||
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TRepo.manualBook, 1, 1));
|
||||
}
|
||||
}
|
||||
if (ComparisonHelper.areEquivalent(item,TRepo.smeltery) || ComparisonHelper.areEquivalent(item,TRepo.lavaTank))
|
||||
if (ComparisonHelper.areEquivalent(item, TRepo.smeltery) || ComparisonHelper.areEquivalent(item, TRepo.lavaTank))
|
||||
{
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(event.player.getDisplayName());
|
||||
NBTTagCompound tags = event.player.getEntityData().getCompoundTag("TConstruct");
|
||||
@@ -44,9 +44,10 @@ public class TCraftingHandler //implements ICraftingHandler
|
||||
}
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.smelteryMaker"), 1);
|
||||
}
|
||||
|
||||
if (ComparisonHelper.areEquivalent(item,TRepo.craftingStationWood)){
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.betterCrafting"), 1);
|
||||
|
||||
if (ComparisonHelper.areEquivalent(item, TRepo.craftingStationWood))
|
||||
{
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.betterCrafting"), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ public class TEventHandler
|
||||
{
|
||||
if (evt.entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
WorldHelper.setBlockToAir(evt.world,hitX, hitY, hitZ);
|
||||
WorldHelper.setBlockToAir(evt.world, hitX, hitY, hitZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -629,22 +629,26 @@ public class TEventHandler
|
||||
@SubscribeEvent
|
||||
public void livingUpdate (LivingUpdateEvent event)
|
||||
{
|
||||
if(event.entityLiving instanceof EntityPlayer){
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.getDisplayName());
|
||||
|
||||
if(stats != null){
|
||||
ArmorExtended armor = stats.armor;
|
||||
for(int i = 0; i < armor.getSizeInventory(); i++){
|
||||
if(armor.getStackInSlot(i) != null){
|
||||
armor.getStackInSlot(i).getItem().onUpdate(armor.getStackInSlot(i), player.worldObj, player, i, false);
|
||||
armor.getStackInSlot(i).getItem().onArmorTick(player.worldObj, player, armor.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (stats != null)
|
||||
{
|
||||
ArmorExtended armor = stats.armor;
|
||||
for (int i = 0; i < armor.getSizeInventory(); i++)
|
||||
{
|
||||
if (armor.getStackInSlot(i) != null)
|
||||
{
|
||||
armor.getStackInSlot(i).getItem().onUpdate(armor.getStackInSlot(i), player.worldObj, player, i, false);
|
||||
armor.getStackInSlot(i).getItem().onArmorTick(player.worldObj, player, armor.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Player interact event - prevent breaking of tank air blocks in creative
|
||||
@SubscribeEvent
|
||||
public void playerInteract (PlayerInteractEvent event)
|
||||
|
||||
@@ -8,30 +8,38 @@ import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.library.event.ToolCraftedEvent;
|
||||
import tconstruct.library.tools.*;
|
||||
|
||||
public class TEventHandlerAchievement {
|
||||
public class TEventHandlerAchievement
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public void onToolCrafted(ToolCraftedEvent event){
|
||||
if(event.player != null && !(event.player instanceof FakePlayer)){
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.tinkerer"), 1);
|
||||
|
||||
if(event.tool != null && event.tool.getItem() instanceof Weapon){
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.preparedFight"), 1);
|
||||
}
|
||||
|
||||
if(event.inventory != null && event.inventory instanceof ToolForgeLogic && event.tool.getItem() instanceof ToolCore && ((ToolCore)event.tool.getItem()).durabilityTypeExtra() != 0){
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.proTinkerer"), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onToolCrafted (ToolCraftedEvent event)
|
||||
{
|
||||
if (event.player != null && !(event.player instanceof FakePlayer))
|
||||
{
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.tinkerer"), 1);
|
||||
|
||||
if (event.tool != null && event.tool.getItem() instanceof Weapon)
|
||||
{
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.preparedFight"), 1);
|
||||
}
|
||||
|
||||
if (event.inventory != null && event.inventory instanceof ToolForgeLogic && event.tool.getItem() instanceof ToolCore && ((ToolCore) event.tool.getItem()).durabilityTypeExtra() != 0)
|
||||
{
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.proTinkerer"), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemPlacedIntoCasting(SmelteryEvent.ItemInsertedIntoCasting event){
|
||||
if(event.player != null && event.item != null){
|
||||
if(event.item.getItem() instanceof ToolCore){
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.doingItWrong"), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onItemPlacedIntoCasting (SmelteryEvent.ItemInsertedIntoCasting event)
|
||||
{
|
||||
if (event.player != null && event.item != null)
|
||||
{
|
||||
if (event.item.getItem() instanceof ToolCore)
|
||||
{
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.doingItWrong"), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class DimensionBlacklist
|
||||
public static int promisedLandDimensionID = -100;
|
||||
public static int twilightForestDimensionID = -100;
|
||||
|
||||
public static void getBadBimensions()
|
||||
public static void getBadBimensions ()
|
||||
{
|
||||
updateModDimIDs();
|
||||
|
||||
@@ -61,13 +61,13 @@ public class DimensionBlacklist
|
||||
return noPoolDims.contains(dim);
|
||||
}
|
||||
|
||||
private static void updateModDimIDs()
|
||||
private static void updateModDimIDs ()
|
||||
{
|
||||
updateTwiForestID();
|
||||
updateBoPID();
|
||||
}
|
||||
|
||||
private static void updateTwiForestID()
|
||||
private static void updateTwiForestID ()
|
||||
{
|
||||
String location = Loader.instance().getConfigDir().getPath();
|
||||
File newFile = new File(location + File.separator + "TwilightForest.cfg");
|
||||
@@ -80,10 +80,11 @@ public class DimensionBlacklist
|
||||
twilightForestDimensionID = config.get("dimension", "dimensionID", -100).getInt();
|
||||
TConstruct.logger.trace("Twilight Forest Dim ID: " + twilightForestDimensionID);
|
||||
}
|
||||
else twilightForestDimensionID = -100;
|
||||
else
|
||||
twilightForestDimensionID = -100;
|
||||
}
|
||||
|
||||
private static void updateBoPID()
|
||||
private static void updateBoPID ()
|
||||
{
|
||||
String location = Loader.instance().getConfigDir().getPath();
|
||||
File newFile = new File(location + File.separator + "biomesoplenty" + File.separator + "ids.cfg");
|
||||
@@ -96,7 +97,8 @@ public class DimensionBlacklist
|
||||
promisedLandDimensionID = config.get("dimension settings", "Promised Land Dimension ID", -200).getInt();
|
||||
TConstruct.logger.trace("Promised Lands Dim ID: " + promisedLandDimensionID);
|
||||
}
|
||||
else promisedLandDimensionID = -100;
|
||||
else
|
||||
promisedLandDimensionID = -100;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class PHConstruct
|
||||
Configuration config = new Configuration(confFile);
|
||||
/* Load the configuration file */
|
||||
config.load();
|
||||
|
||||
|
||||
superfunWorld = config.get("Superfun", "All the world is Superfun", false).getBoolean(false);
|
||||
TRepo.supressMissingToolLogs = config.get("Logging", "Disable tool build messages", false).getBoolean(false);
|
||||
|
||||
@@ -47,7 +47,6 @@ public class PHConstruct
|
||||
denyMattock = config.get("Difficulty Changes", "Deny creation of non-metal mattocks", false).getBoolean(false);
|
||||
craftEndstone = config.get("Difficulty Changes", "Allow creation of endstone", true).getBoolean(true);
|
||||
|
||||
|
||||
ingotsPerOre = config.get("Smeltery Output Modification", "Ingots per ore", 2, "Number of ingots returned from smelting ores in the smeltery").getDouble(2);
|
||||
ingotsBronzeAlloy = config.get("Smeltery Output Modification", "Bronze ingot return", 4, "Number of ingots returned from smelting Bronze in the smeltery").getDouble(4);
|
||||
ingotsAluminumBrassAlloy = config.get("Smeltery Output Modification", "Aluminum Brass ingot return", 4, "Number of ingots returned from smelting Aluminum Brass in the smeltery").getDouble(4);
|
||||
|
||||
@@ -58,17 +58,20 @@ public abstract class Behavior
|
||||
addBehavior(new ItemStack(Items.snowball), shoot);
|
||||
addBehavior(new ItemStack(Items.ender_pearl), shoot);
|
||||
addBehavior(new ItemStack(Items.shears), shear);
|
||||
|
||||
|
||||
//Make sure the part below this comment is executed last(to avoid conflicts)
|
||||
Iterator i1 = Block.blockRegistry.iterator();
|
||||
while(i1.hasNext()){
|
||||
Object ob = i1.next();
|
||||
if(ob != null && ob instanceof Block){
|
||||
Block b = (Block) ob;
|
||||
if(b.getMaterial().isOpaque() && b.renderAsNormalBlock() && !b.canProvidePower() && !(b instanceof ITileEntityProvider) && !behaviorsListBlocks.containsKey(new ItemStack(b))){
|
||||
addBehavior(new ItemStack(b), blockThrow);
|
||||
}
|
||||
}
|
||||
while (i1.hasNext())
|
||||
{
|
||||
Object ob = i1.next();
|
||||
if (ob != null && ob instanceof Block)
|
||||
{
|
||||
Block b = (Block) ob;
|
||||
if (b.getMaterial().isOpaque() && b.renderAsNormalBlock() && !b.canProvidePower() && !(b instanceof ITileEntityProvider) && !behaviorsListBlocks.containsKey(new ItemStack(b)))
|
||||
{
|
||||
addBehavior(new ItemStack(b), blockThrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ public class BehaviorBlockThrow extends Behavior
|
||||
break;
|
||||
}
|
||||
|
||||
EntityFallingBlock entityfallingsand = new EntityFallingBlock(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 2F), (double) ((float) par4 + 0.5F), BlockUtils.getBlockFromItemStack(par5ItemStack),
|
||||
par5ItemStack.getItemDamage());
|
||||
EntityFallingBlock entityfallingsand = new EntityFallingBlock(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 2F), (double) ((float) par4 + 0.5F),
|
||||
BlockUtils.getBlockFromItemStack(par5ItemStack), par5ItemStack.getItemDamage());
|
||||
entityfallingsand.preventEntitySpawning = false;
|
||||
entityfallingsand.ticksExisted = 2;
|
||||
entityfallingsand.setVelocity(vec0, vec1, vec2);
|
||||
|
||||
@@ -43,8 +43,8 @@ public class BehaviorFirecharge extends Behavior
|
||||
{
|
||||
for (int j = par4 - 2; j <= (par4 + 2); j++)
|
||||
{
|
||||
if ((par1World.getBlock(i, par3, j) == null || (par1World.getBlock(i, par3, j) != null && par1World.getBlock(i, par3, j).isReplaceable(
|
||||
par1World, i, par3, j))) && ItemBlockLandmine.getRandom().nextInt(5) == 0 && Blocks.fire.canPlaceBlockAt(par1World, i, par3, j))
|
||||
if ((par1World.getBlock(i, par3, j) == null || (par1World.getBlock(i, par3, j) != null && par1World.getBlock(i, par3, j).isReplaceable(par1World, i, par3, j)))
|
||||
&& ItemBlockLandmine.getRandom().nextInt(5) == 0 && Blocks.fire.canPlaceBlockAt(par1World, i, par3, j))
|
||||
{
|
||||
par1World.setBlock(i, par3, j, Blocks.fire);
|
||||
}
|
||||
|
||||
@@ -8,35 +8,36 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
* AbstractPacket class. Should be the parent of all packets wishing to use the PacketPipeline.
|
||||
* @author sirgingalot
|
||||
*/
|
||||
public abstract class AbstractPacket {
|
||||
public abstract class AbstractPacket
|
||||
{
|
||||
|
||||
/**
|
||||
* Encode the packet data into the ByteBuf stream. Complex data sets may need specific data handlers (See @link{cpw.mods.fml.common.network.ByteBuffUtils})
|
||||
*
|
||||
* @param ctx channel context
|
||||
* @param buffer the buffer to encode into
|
||||
*/
|
||||
public abstract void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer);
|
||||
/**
|
||||
* Encode the packet data into the ByteBuf stream. Complex data sets may need specific data handlers (See @link{cpw.mods.fml.common.network.ByteBuffUtils})
|
||||
*
|
||||
* @param ctx channel context
|
||||
* @param buffer the buffer to encode into
|
||||
*/
|
||||
public abstract void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer);
|
||||
|
||||
/**
|
||||
* Decode the packet data from the ByteBuf stream. Complex data sets may need specific data handlers (See @link{cpw.mods.fml.common.network.ByteBuffUtils})
|
||||
*
|
||||
* @param ctx channel context
|
||||
* @param buffer the buffer to decode from
|
||||
*/
|
||||
public abstract void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer);
|
||||
/**
|
||||
* Decode the packet data from the ByteBuf stream. Complex data sets may need specific data handlers (See @link{cpw.mods.fml.common.network.ByteBuffUtils})
|
||||
*
|
||||
* @param ctx channel context
|
||||
* @param buffer the buffer to decode from
|
||||
*/
|
||||
public abstract void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer);
|
||||
|
||||
/**
|
||||
* Handle a packet on the client side. Note this occurs after decoding has completed.
|
||||
*
|
||||
* @param player the player reference
|
||||
*/
|
||||
public abstract void handleClientSide(EntityPlayer player);
|
||||
/**
|
||||
* Handle a packet on the client side. Note this occurs after decoding has completed.
|
||||
*
|
||||
* @param player the player reference
|
||||
*/
|
||||
public abstract void handleClientSide (EntityPlayer player);
|
||||
|
||||
/**
|
||||
* Handle a packet on the server side. Note this occurs after decoding has completed.
|
||||
*
|
||||
* @param player the player reference
|
||||
*/
|
||||
public abstract void handleServerSide(EntityPlayer player);
|
||||
/**
|
||||
* Handle a packet on the server side. Note this occurs after decoding has completed.
|
||||
*
|
||||
* @param player the player reference
|
||||
*/
|
||||
public abstract void handleServerSide (EntityPlayer player);
|
||||
}
|
||||
@@ -4,28 +4,33 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class PacketDoubleJump extends AbstractPacket {
|
||||
public class PacketDoubleJump extends AbstractPacket
|
||||
{
|
||||
|
||||
@Override
|
||||
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
@Override
|
||||
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
@Override
|
||||
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide(EntityPlayer player) {
|
||||
@Override
|
||||
public void handleClientSide (EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
//String user = inputStream.readUTF();
|
||||
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
//String user = inputStream.readUTF();
|
||||
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,48 +5,56 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
public class PacketExtendedInventory extends AbstractPacket {
|
||||
public class PacketExtendedInventory extends AbstractPacket
|
||||
{
|
||||
|
||||
byte type;
|
||||
byte type;
|
||||
|
||||
public PacketExtendedInventory() {
|
||||
public PacketExtendedInventory()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public PacketExtendedInventory(byte type) {
|
||||
this.type = type;
|
||||
}
|
||||
public PacketExtendedInventory(byte type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
buffer.writeByte(type);
|
||||
}
|
||||
@Override
|
||||
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
buffer.writeByte(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
type = buffer.readByte();
|
||||
}
|
||||
@Override
|
||||
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
type = buffer.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide(EntityPlayer player) {
|
||||
@Override
|
||||
public void handleClientSide (EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
//String user = inputStream.readUTF();
|
||||
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
switch (type) {
|
||||
case 0:
|
||||
player.openGui(TConstruct.instance, TConstruct.proxy.inventoryGui, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
case 1:
|
||||
player.openGui(TConstruct.instance, TConstruct.proxy.armorGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
case 2:
|
||||
player.openGui(TConstruct.instance, TConstruct.proxy.knapsackGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
//String user = inputStream.readUTF();
|
||||
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
player.openGui(TConstruct.instance, TConstruct.proxy.inventoryGui, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
case 1:
|
||||
player.openGui(TConstruct.instance, TConstruct.proxy.armorGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
case 2:
|
||||
player.openGui(TConstruct.instance, TConstruct.proxy.knapsackGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,191 +18,214 @@ import net.minecraft.network.*;
|
||||
* some code from: cpw
|
||||
*/
|
||||
@ChannelHandler.Sharable
|
||||
public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, AbstractPacket> {
|
||||
public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, AbstractPacket>
|
||||
{
|
||||
|
||||
private EnumMap<Side, FMLEmbeddedChannel> channels;
|
||||
private LinkedList<Class<? extends AbstractPacket>> packets = new LinkedList<Class<? extends AbstractPacket>>();
|
||||
private boolean isPostInitialised = false;
|
||||
private EnumMap<Side, FMLEmbeddedChannel> channels;
|
||||
private LinkedList<Class<? extends AbstractPacket>> packets = new LinkedList<Class<? extends AbstractPacket>>();
|
||||
private boolean isPostInitialised = false;
|
||||
|
||||
/**
|
||||
* Register your packet with the pipeline. Discriminators are automatically set.
|
||||
*
|
||||
* @param clazz the class to register
|
||||
*
|
||||
* @return whether registration was successful. Failure may occur if 256 packets have been registered or if the registry already contains this packet
|
||||
*/
|
||||
public boolean registerPacket(Class<? extends AbstractPacket> clazz) {
|
||||
if (this.packets.size() > 256) {
|
||||
// You should log here!!
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Register your packet with the pipeline. Discriminators are automatically set.
|
||||
*
|
||||
* @param clazz the class to register
|
||||
*
|
||||
* @return whether registration was successful. Failure may occur if 256 packets have been registered or if the registry already contains this packet
|
||||
*/
|
||||
public boolean registerPacket (Class<? extends AbstractPacket> clazz)
|
||||
{
|
||||
if (this.packets.size() > 256)
|
||||
{
|
||||
// You should log here!!
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.packets.contains(clazz)) {
|
||||
// You should log here!!
|
||||
return false;
|
||||
}
|
||||
if (this.packets.contains(clazz))
|
||||
{
|
||||
// You should log here!!
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isPostInitialised) {
|
||||
// You should log here!!
|
||||
return false;
|
||||
}
|
||||
if (this.isPostInitialised)
|
||||
{
|
||||
// You should log here!!
|
||||
return false;
|
||||
}
|
||||
|
||||
this.packets.add(clazz);
|
||||
return true;
|
||||
}
|
||||
this.packets.add(clazz);
|
||||
return true;
|
||||
}
|
||||
|
||||
// In line encoding of the packet, including discriminator setting
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, AbstractPacket msg, List<Object> out) throws Exception {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
Class<? extends AbstractPacket> clazz = msg.getClass();
|
||||
if (!this.packets.contains(msg.getClass())) {
|
||||
throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName());
|
||||
}
|
||||
// In line encoding of the packet, including discriminator setting
|
||||
@Override
|
||||
protected void encode (ChannelHandlerContext ctx, AbstractPacket msg, List<Object> out) throws Exception
|
||||
{
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
Class<? extends AbstractPacket> clazz = msg.getClass();
|
||||
if (!this.packets.contains(msg.getClass()))
|
||||
{
|
||||
throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
byte discriminator = (byte) this.packets.indexOf(clazz);
|
||||
buffer.writeByte(discriminator);
|
||||
msg.encodeInto(ctx, buffer);
|
||||
FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
|
||||
out.add(proxyPacket);
|
||||
}
|
||||
byte discriminator = (byte) this.packets.indexOf(clazz);
|
||||
buffer.writeByte(discriminator);
|
||||
msg.encodeInto(ctx, buffer);
|
||||
FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
|
||||
out.add(proxyPacket);
|
||||
}
|
||||
|
||||
// In line decoding and handling of the packet
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
|
||||
ByteBuf payload = msg.payload();
|
||||
byte discriminator = payload.readByte();
|
||||
Class<? extends AbstractPacket> clazz = this.packets.get(discriminator);
|
||||
if (clazz == null) {
|
||||
throw new NullPointerException("No packet registered for discriminator: " + discriminator);
|
||||
}
|
||||
// In line decoding and handling of the packet
|
||||
@Override
|
||||
protected void decode (ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception
|
||||
{
|
||||
ByteBuf payload = msg.payload();
|
||||
byte discriminator = payload.readByte();
|
||||
Class<? extends AbstractPacket> clazz = this.packets.get(discriminator);
|
||||
if (clazz == null)
|
||||
{
|
||||
throw new NullPointerException("No packet registered for discriminator: " + discriminator);
|
||||
}
|
||||
|
||||
AbstractPacket pkt = clazz.newInstance();
|
||||
pkt.decodeInto(ctx, payload.slice());
|
||||
AbstractPacket pkt = clazz.newInstance();
|
||||
pkt.decodeInto(ctx, payload.slice());
|
||||
|
||||
EntityPlayer player;
|
||||
switch (FMLCommonHandler.instance().getEffectiveSide()) {
|
||||
case CLIENT:
|
||||
player = this.getClientPlayer();
|
||||
pkt.handleClientSide(player);
|
||||
break;
|
||||
EntityPlayer player;
|
||||
switch (FMLCommonHandler.instance().getEffectiveSide())
|
||||
{
|
||||
case CLIENT:
|
||||
player = this.getClientPlayer();
|
||||
pkt.handleClientSide(player);
|
||||
break;
|
||||
|
||||
case SERVER:
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
player = ((NetHandlerPlayServer) netHandler).playerEntity;
|
||||
pkt.handleServerSide(player);
|
||||
break;
|
||||
case SERVER:
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
player = ((NetHandlerPlayServer) netHandler).playerEntity;
|
||||
pkt.handleServerSide(player);
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
default:
|
||||
}
|
||||
|
||||
out.add(pkt);
|
||||
}
|
||||
out.add(pkt);
|
||||
}
|
||||
|
||||
// Method to call from FMLInitializationEvent
|
||||
public void initalise() {
|
||||
this.channels = NetworkRegistry.INSTANCE.newChannel("TConstruct", this);
|
||||
registerPackets();
|
||||
}
|
||||
// Method to call from FMLInitializationEvent
|
||||
public void initalise ()
|
||||
{
|
||||
this.channels = NetworkRegistry.INSTANCE.newChannel("TConstruct", this);
|
||||
registerPackets();
|
||||
}
|
||||
|
||||
public void registerPackets(){
|
||||
registerPacket(PacketDoubleJump.class);
|
||||
registerPacket(PacketExtendedInventory.class);
|
||||
registerPacket(PacketSmeltery.class);
|
||||
registerPacket(PacketStencilTable.class);
|
||||
registerPacket(PacketToolStation.class);
|
||||
}
|
||||
|
||||
// Method to call from FMLPostInitializationEvent
|
||||
// Ensures that packet discriminators are common between server and client by using logical sorting
|
||||
public void postInitialise() {
|
||||
if (this.isPostInitialised) {
|
||||
return;
|
||||
}
|
||||
public void registerPackets ()
|
||||
{
|
||||
registerPacket(PacketDoubleJump.class);
|
||||
registerPacket(PacketExtendedInventory.class);
|
||||
registerPacket(PacketSmeltery.class);
|
||||
registerPacket(PacketStencilTable.class);
|
||||
registerPacket(PacketToolStation.class);
|
||||
}
|
||||
|
||||
this.isPostInitialised = true;
|
||||
Collections.sort(this.packets, new Comparator<Class<? extends AbstractPacket>>() {
|
||||
// Method to call from FMLPostInitializationEvent
|
||||
// Ensures that packet discriminators are common between server and client by using logical sorting
|
||||
public void postInitialise ()
|
||||
{
|
||||
if (this.isPostInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Class<? extends AbstractPacket> clazz1, Class<? extends AbstractPacket> clazz2) {
|
||||
int com = String.CASE_INSENSITIVE_ORDER.compare(clazz1.getCanonicalName(), clazz2.getCanonicalName());
|
||||
if (com == 0) {
|
||||
com = clazz1.getCanonicalName().compareTo(clazz2.getCanonicalName());
|
||||
}
|
||||
this.isPostInitialised = true;
|
||||
Collections.sort(this.packets, new Comparator<Class<? extends AbstractPacket>>()
|
||||
{
|
||||
|
||||
return com;
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public int compare (Class<? extends AbstractPacket> clazz1, Class<? extends AbstractPacket> clazz2)
|
||||
{
|
||||
int com = String.CASE_INSENSITIVE_ORDER.compare(clazz1.getCanonicalName(), clazz2.getCanonicalName());
|
||||
if (com == 0)
|
||||
{
|
||||
com = clazz1.getCanonicalName().compareTo(clazz2.getCanonicalName());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private EntityPlayer getClientPlayer() {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
return com;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to everyone.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendToAll(AbstractPacket message) {
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
|
||||
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
private EntityPlayer getClientPlayer ()
|
||||
{
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to the specified player.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
* @param player The player to send it to
|
||||
*/
|
||||
public void sendTo(AbstractPacket message, EntityPlayerMP player) {
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
|
||||
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||
}
|
||||
/**
|
||||
* Send this message to everyone.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendToAll (AbstractPacket message)
|
||||
{
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
|
||||
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to everyone within a certain range of a point.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
* @param point The {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint} around which to send
|
||||
*/
|
||||
public void sendToAllAround(AbstractPacket message, NetworkRegistry.TargetPoint point) {
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
|
||||
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||
}
|
||||
/**
|
||||
* Send this message to the specified player.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
* @param player The player to send it to
|
||||
*/
|
||||
public void sendTo (AbstractPacket message, EntityPlayerMP player)
|
||||
{
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
|
||||
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to everyone within the supplied dimension.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
* @param dimensionId The dimension id to target
|
||||
*/
|
||||
public void sendToDimension(AbstractPacket message, int dimensionId) {
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId);
|
||||
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||
}
|
||||
/**
|
||||
* Send this message to everyone within a certain range of a point.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
* @param point The {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint} around which to send
|
||||
*/
|
||||
public void sendToAllAround (AbstractPacket message, NetworkRegistry.TargetPoint point)
|
||||
{
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
|
||||
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to the server.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendToServer(AbstractPacket message) {
|
||||
this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);
|
||||
this.channels.get(Side.CLIENT).writeAndFlush(message);
|
||||
}
|
||||
/**
|
||||
* Send this message to everyone within the supplied dimension.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
* @param dimensionId The dimension id to target
|
||||
*/
|
||||
public void sendToDimension (AbstractPacket message, int dimensionId)
|
||||
{
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
|
||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId);
|
||||
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to the server.
|
||||
* <p/>
|
||||
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendToServer (AbstractPacket message)
|
||||
{
|
||||
this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);
|
||||
this.channels.get(Side.CLIENT).writeAndFlush(message);
|
||||
}
|
||||
}
|
||||
@@ -14,53 +14,60 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.blocks.logic.SmelteryLogic;
|
||||
|
||||
public class PacketSmeltery extends AbstractPacket {
|
||||
public class PacketSmeltery extends AbstractPacket
|
||||
{
|
||||
|
||||
int dimension, x, y, z, fluidID;
|
||||
boolean isShiftPressed;
|
||||
|
||||
public PacketSmeltery(){
|
||||
|
||||
}
|
||||
|
||||
public PacketSmeltery(int dimension, int x, int y, int z, boolean isShiftPressed, int fluidID){
|
||||
this.dimension = dimension;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.isShiftPressed = isShiftPressed;
|
||||
this.fluidID = fluidID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
buffer.writeInt(dimension);
|
||||
buffer.writeInt(x);
|
||||
buffer.writeInt(y);
|
||||
buffer.writeInt(z);
|
||||
buffer.writeBoolean(isShiftPressed);
|
||||
|
||||
}
|
||||
int dimension, x, y, z, fluidID;
|
||||
boolean isShiftPressed;
|
||||
|
||||
@Override
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
dimension = buffer.readInt();
|
||||
x = buffer.readInt();
|
||||
public PacketSmeltery()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PacketSmeltery(int dimension, int x, int y, int z, boolean isShiftPressed, int fluidID)
|
||||
{
|
||||
this.dimension = dimension;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.isShiftPressed = isShiftPressed;
|
||||
this.fluidID = fluidID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
buffer.writeInt(dimension);
|
||||
buffer.writeInt(x);
|
||||
buffer.writeInt(y);
|
||||
buffer.writeInt(z);
|
||||
buffer.writeBoolean(isShiftPressed);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
dimension = buffer.readInt();
|
||||
x = buffer.readInt();
|
||||
y = buffer.readInt();
|
||||
z = buffer.readInt();
|
||||
isShiftPressed = buffer.readBoolean();
|
||||
fluidID = buffer.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide(EntityPlayer player) {
|
||||
@Override
|
||||
public void handleClientSide (EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if (te instanceof SmelteryLogic)
|
||||
@@ -87,6 +94,6 @@ public class PacketSmeltery extends AbstractPacket {
|
||||
//Old code: PacketDispatcher.sendPacketToAllInDimension(te.getDescriptionPacket(), dimension);
|
||||
FMLCommonHandler.instance().getClientToServerNetworkManager().scheduleOutboundPacket(te.getDescriptionPacket());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,50 +9,58 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PacketStencilTable extends AbstractPacket {
|
||||
public class PacketStencilTable extends AbstractPacket
|
||||
{
|
||||
|
||||
int x, y, z;
|
||||
ItemStack contents;
|
||||
int x, y, z;
|
||||
ItemStack contents;
|
||||
|
||||
public PacketStencilTable() {
|
||||
public PacketStencilTable()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public PacketStencilTable(int x, int y, int z, ItemStack contents) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.contents = contents;
|
||||
}
|
||||
public PacketStencilTable(int x, int y, int z, ItemStack contents)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
buffer.writeInt(x);
|
||||
buffer.writeInt(y);
|
||||
buffer.writeInt(z);
|
||||
ByteBufUtils.writeItemStack(buffer, contents);
|
||||
}
|
||||
@Override
|
||||
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
buffer.writeInt(x);
|
||||
buffer.writeInt(y);
|
||||
buffer.writeInt(z);
|
||||
ByteBufUtils.writeItemStack(buffer, contents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
x = buffer.readInt();
|
||||
y = buffer.readInt();
|
||||
z = buffer.readInt();
|
||||
}
|
||||
@Override
|
||||
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
x = buffer.readInt();
|
||||
y = buffer.readInt();
|
||||
z = buffer.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide(EntityPlayer player) {
|
||||
@Override
|
||||
public void handleClientSide (EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if (te instanceof InventoryLogic) {
|
||||
((InventoryLogic) te).setInventorySlotContents(1, contents);
|
||||
}
|
||||
}
|
||||
if (te instanceof InventoryLogic)
|
||||
{
|
||||
((InventoryLogic) te).setInventorySlotContents(1, contents);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,52 +8,61 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.blocks.logic.*;
|
||||
|
||||
public class PacketToolStation extends AbstractPacket {
|
||||
public class PacketToolStation extends AbstractPacket
|
||||
{
|
||||
|
||||
private int x, y, z;
|
||||
private String toolName;
|
||||
private int x, y, z;
|
||||
private String toolName;
|
||||
|
||||
public PacketToolStation() {
|
||||
}
|
||||
public PacketToolStation()
|
||||
{
|
||||
}
|
||||
|
||||
public PacketToolStation(int x, int y, int z, String toolName) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.toolName = toolName;
|
||||
}
|
||||
public PacketToolStation(int x, int y, int z, String toolName)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.toolName = toolName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
buffer.writeInt(x);
|
||||
buffer.writeInt(y);
|
||||
buffer.writeInt(z);
|
||||
ByteBufUtils.writeUTF8String(buffer, toolName);
|
||||
}
|
||||
@Override
|
||||
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
buffer.writeInt(x);
|
||||
buffer.writeInt(y);
|
||||
buffer.writeInt(z);
|
||||
ByteBufUtils.writeUTF8String(buffer, toolName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
x = buffer.readInt();
|
||||
y = buffer.readInt();
|
||||
z = buffer.readInt();
|
||||
toolName = ByteBufUtils.readUTF8String(buffer);
|
||||
}
|
||||
@Override
|
||||
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
x = buffer.readInt();
|
||||
y = buffer.readInt();
|
||||
z = buffer.readInt();
|
||||
toolName = ByteBufUtils.readUTF8String(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide(EntityPlayer player) {
|
||||
}
|
||||
@Override
|
||||
public void handleClientSide (EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if (te instanceof ToolStationLogic) {
|
||||
((ToolStationLogic) te).setToolname(toolName);
|
||||
}
|
||||
if (te instanceof ToolForgeLogic) {
|
||||
((ToolForgeLogic) te).setToolname(toolName);
|
||||
}
|
||||
}
|
||||
if (te instanceof ToolStationLogic)
|
||||
{
|
||||
((ToolStationLogic) te).setToolname(toolName);
|
||||
}
|
||||
if (te instanceof ToolForgeLogic)
|
||||
{
|
||||
((ToolForgeLogic) te).setToolname(toolName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -258,7 +258,7 @@ public class ArmorExtended implements IInventory
|
||||
public void readFromNBT (EntityPlayer entityplayer)
|
||||
{
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
NBTTagList tagList = tags.getTagList("TConstruct.Inventory",9);
|
||||
NBTTagList tagList = tags.getTagList("TConstruct.Inventory", 9);
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
|
||||
@@ -49,12 +49,12 @@ public class TPlayerHandler
|
||||
{
|
||||
savePlayerStats(event.player, false);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerRespawn (PlayerRespawnEvent event)
|
||||
{
|
||||
onPlayerRespawn(event.player);
|
||||
}
|
||||
|
||||
|
||||
public void onPlayerLogin (EntityPlayer entityplayer)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user