mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-21 12:42:57 +00:00
Upload my Code Changes/Format/imports
This commit is contained in:
1 parent
5bcdb7ca46
commit
5d4e38c0cb
264 files changed
+4014
-3972
No files matched your search
@@ -15,7 +15,7 @@ public class DamageSourceLandmine extends DamageSource
|
||||
|
||||
public IChatComponent func_151519_b (EntityLivingBase par1EntityLivingBase)
|
||||
{
|
||||
//TODO getDeathMessage????
|
||||
// TODO getDeathMessage????
|
||||
return super.func_151519_b(par1EntityLivingBase);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,9 @@ public class EnvironmentChecks
|
||||
} // Singleton
|
||||
|
||||
/**
|
||||
* Checks for conflicting stuff in environment; adds callable to any crash logs if so.
|
||||
* Note: This code adds additional data to crashlogs. It does not trigger any crashes.
|
||||
* Checks for conflicting stuff in environment; adds callable to any crash
|
||||
* logs if so. Note: This code adds additional data to crashlogs. It does
|
||||
* not trigger any crashes.
|
||||
*/
|
||||
private static List<String> incompatibilities = new ArrayList<String>();
|
||||
private static EnvironmentChecks instance = new EnvironmentChecks();
|
||||
@@ -38,7 +39,8 @@ public class EnvironmentChecks
|
||||
incompatibilities.add("GregTech");
|
||||
}
|
||||
|
||||
// Bukkit/Magic Launcher/Optifine are caught by Mantle, so we no longer check for those.
|
||||
// Bukkit/Magic Launcher/Optifine are caught by Mantle, so we no longer
|
||||
// check for those.
|
||||
|
||||
if (modIds.size() == 0)
|
||||
{
|
||||
|
||||
@@ -12,11 +12,13 @@ import tconstruct.util.player.TPlayerStats;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
|
||||
|
||||
public class TCraftingHandler //implements ICraftingHandler
|
||||
public class TCraftingHandler // implements ICraftingHandler
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCrafting (ItemCraftedEvent event)//EntityPlayer player, ItemStack itemstack, IInventory craftMatrix)
|
||||
public void onCrafting (ItemCraftedEvent event)// EntityPlayer player,
|
||||
// ItemStack itemstack,
|
||||
// IInventory craftMatrix)
|
||||
{
|
||||
Item item = event.crafting.getItem();
|
||||
if (!event.player.worldObj.isRemote)
|
||||
|
||||
@@ -15,9 +15,9 @@ public class TDispenserBehaviorArrow extends BehaviorDefaultDispenseItem
|
||||
public ItemStack dispenseStack (IBlockSource dispenser, ItemStack stack)
|
||||
{
|
||||
World world = dispenser.getWorld();
|
||||
//TODO getIPositionFromBlockSource
|
||||
// TODO getIPositionFromBlockSource
|
||||
IPosition iposition = BlockDispenser.func_149939_a(dispenser);
|
||||
//TODO getFacing
|
||||
// TODO getFacing
|
||||
EnumFacing enumfacing = BlockDispenser.func_149937_b(dispenser.getBlockMetadata());
|
||||
|
||||
ItemStack arrowItem = stack.splitStack(1);
|
||||
|
||||
@@ -11,7 +11,8 @@ import tconstruct.items.TitleIcon;
|
||||
public class TDispenserBehaviorSpawnEgg extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
* Dispense the specified stack, play the dispense sound and spawn
|
||||
* particles.
|
||||
*/
|
||||
public ItemStack dispenseStack (IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,6 @@ import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
@@ -57,7 +56,6 @@ import tconstruct.library.tools.FletchingMaterial;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.util.player.ArmorExtended;
|
||||
import tconstruct.util.player.TPlayerStats;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
@@ -236,7 +234,7 @@ public class TEventHandler
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
//Cutlass
|
||||
// Cutlass
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() == TRepo.cutlass && player.isUsingItem())
|
||||
{
|
||||
@@ -290,19 +288,20 @@ public class TEventHandler
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
//if (event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot"))
|
||||
//{
|
||||
// if
|
||||
// (event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot"))
|
||||
// {
|
||||
if (!event.entityLiving.isChild())
|
||||
{
|
||||
/*if (event.entityLiving.getClass() == EntityCow.class)
|
||||
{
|
||||
int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1;
|
||||
|
||||
for (int iter = 0; iter < amount; ++iter)
|
||||
{
|
||||
addDrops(event, new ItemStack(Item.leather, 1));
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* if (event.entityLiving.getClass() == EntityCow.class) { int
|
||||
* amount = random.nextInt(3) + random.nextInt(1 +
|
||||
* event.lootingLevel) + random.nextInt(3) + random.nextInt(1 +
|
||||
* event.lootingLevel) + 1;
|
||||
*
|
||||
* for (int iter = 0; iter < amount; ++iter) { addDrops(event, new
|
||||
* ItemStack(Item.leather, 1)); } }
|
||||
*/
|
||||
|
||||
if (event.entityLiving.getClass() == EntityChicken.class)
|
||||
{
|
||||
@@ -361,10 +360,12 @@ public class TEventHandler
|
||||
addDrops(event, new ItemStack(Items.skull, 1, 2));
|
||||
}
|
||||
}
|
||||
/*if (stack.getItem() == TRepo.breakerBlade && random.nextInt(100) < 10) //Swap out for real beheading
|
||||
{
|
||||
addDrops(event, new ItemStack(Item.skull.itemID, 1, 2));
|
||||
}*/
|
||||
/*
|
||||
* if (stack.getItem() == TRepo.breakerBlade &&
|
||||
* random.nextInt(100) < 10) //Swap out for real beheading {
|
||||
* addDrops(event, new ItemStack(Item.skull.itemID, 1, 2));
|
||||
* }
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +408,7 @@ public class TEventHandler
|
||||
addDrops(event, new ItemStack(Items.ghast_tear, 1));
|
||||
}
|
||||
}
|
||||
//}
|
||||
// }
|
||||
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
@@ -442,7 +443,9 @@ public class TEventHandler
|
||||
}
|
||||
}
|
||||
|
||||
GameRules rules = player.worldObj.getGameRules(); //Player is null if this crashes
|
||||
GameRules rules = player.worldObj.getGameRules(); // Player is null
|
||||
// if this
|
||||
// crashes
|
||||
if (rules == null || !rules.getGameRuleBooleanValue("keepInventory"))
|
||||
{
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.getDisplayName());
|
||||
@@ -477,14 +480,11 @@ public class TEventHandler
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
/*@ForgeSubscribe
|
||||
public void onLivingSpawn (EntityJoinWorldEvent event)
|
||||
{
|
||||
if (event.entity instanceof EntityXPOrb)
|
||||
{
|
||||
TConstruct.logger.info("Entity: " + event.entity);
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* @ForgeSubscribe public void onLivingSpawn (EntityJoinWorldEvent event) {
|
||||
* if (event.entity instanceof EntityXPOrb) {
|
||||
* TConstruct.logger.info("Entity: " + event.entity); } }
|
||||
*/
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingSpawn (LivingSpawnEvent.SpecialSpawn event)
|
||||
@@ -573,41 +573,26 @@ public class TEventHandler
|
||||
if (TRepo.fluidBlocks[id] instanceof LiquidMetalFinite)
|
||||
{
|
||||
WorldHelper.setBlockToAir(evt.world, hitX, hitY, hitZ);
|
||||
/*int quanta = 0;
|
||||
for (int posX = -1; posX <= 1; posX++)
|
||||
{
|
||||
for (int posZ = -1; posZ <= 1; posZ++)
|
||||
{
|
||||
int localID = evt.world.getBlockId(hitX + posX, hitY, hitZ + posZ);
|
||||
if (localID == bID)
|
||||
{
|
||||
quanta += evt.world.getBlockMetadata(hitX + posX, hitY, hitZ + posZ) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (quanta >= 8)
|
||||
{
|
||||
while (quanta > 0)
|
||||
{
|
||||
for (int posX = -1; posX <= 1; posX++)
|
||||
{
|
||||
for (int posZ = -1; posZ <= 1; posZ++)
|
||||
{
|
||||
int localID = evt.world.getBlockId(hitX + posX, hitY, hitZ + posZ);
|
||||
if (localID == bID)
|
||||
{
|
||||
quanta -= 1;
|
||||
int meta = evt.world.getBlockMetadata(hitX + posX, hitY, hitZ + posZ);
|
||||
if (meta > 0)
|
||||
evt.world.setBlockMetadataWithNotify(hitX + posX, hitY, hitZ + posZ, meta - 1, 3);
|
||||
else
|
||||
evt.world.setBlockToAir(hitX + posX, hitY, hitZ + posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* int quanta = 0; for (int posX = -1; posX <= 1;
|
||||
* posX++) { for (int posZ = -1; posZ <= 1; posZ++)
|
||||
* { int localID = evt.world.getBlockId(hitX + posX,
|
||||
* hitY, hitZ + posZ); if (localID == bID) { quanta
|
||||
* += evt.world.getBlockMetadata(hitX + posX, hitY,
|
||||
* hitZ + posZ) + 1; } } }
|
||||
*
|
||||
* if (quanta >= 8) { while (quanta > 0) { for (int
|
||||
* posX = -1; posX <= 1; posX++) { for (int posZ =
|
||||
* -1; posZ <= 1; posZ++) { int localID =
|
||||
* evt.world.getBlockId(hitX + posX, hitY, hitZ +
|
||||
* posZ); if (localID == bID) { quanta -= 1; int
|
||||
* meta = evt.world.getBlockMetadata(hitX + posX,
|
||||
* hitY, hitZ + posZ); if (meta > 0)
|
||||
* evt.world.setBlockMetadataWithNotify(hitX + posX,
|
||||
* hitY, hitZ + posZ, meta - 1, 3); else
|
||||
* evt.world.setBlockToAir(hitX + posX, hitY, hitZ +
|
||||
* posZ); } } } } }
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -621,31 +606,23 @@ public class TEventHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO 1.7 Fix this -- for ticking stuffs in extra armor slots
|
||||
/*@SubscribeEvent
|
||||
public void livingUpdate (LivingUpdateEvent event)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
// TODO 1.7 Fix this -- for ticking stuffs in extra armor slots
|
||||
/*
|
||||
* @SubscribeEvent public void livingUpdate (LivingUpdateEvent event) { 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)); } } } } }
|
||||
*/
|
||||
|
||||
//Player interact event - prevent breaking of tank air blocks in creative
|
||||
// Player interact event - prevent breaking of tank air blocks in creative
|
||||
@SubscribeEvent
|
||||
public void playerInteract (PlayerInteractEvent event)
|
||||
{
|
||||
|
||||
@@ -141,31 +141,31 @@ public class PHConstruct
|
||||
freePatterns = config.get("Ultra Hardcore Changes", "Add Patterns to Pattern Chests", false, "Gives all tier 1 patterns when pattern chest is placed").getBoolean(false);
|
||||
AbilityHelper.necroticUHS = config.get("Ultra Hardcore Changes", "Necrotic modifier only heals on hostile mob kills", false).getBoolean(false);
|
||||
|
||||
//Slime pools
|
||||
// Slime pools
|
||||
islandRarity = config.get("Worldgen", "Slime Island Rarity", 1450).getInt(1450);
|
||||
|
||||
//Looks
|
||||
// Looks
|
||||
Property conTexMode = config.get("Looks", "Connected Textures Enabled", true);
|
||||
conTexMode.comment = "0 = disabled, 1 = enabled, 2 = enabled + ignore stained glass meta";
|
||||
connectedTexturesMode = conTexMode.getInt(2);
|
||||
|
||||
//dimension blacklist
|
||||
// dimension blacklist
|
||||
cfgDimBlackList = config.get("DimBlackList", "SlimeIslandDimBlacklist", new int[] {}, "Add dimension ID's to prevent slime islands from generating in them").getIntList();
|
||||
slimeIslGenDim0Only = config.get("DimBlackList", "GenerateSlimeIslandInDim0Only", false,
|
||||
"True: slime islands wont generate in any ages other than overworld(if enabled); False: will generate in all non-blackisted ages").getBoolean(false);
|
||||
slimeIslGenDim0 = config.get("DimBlackList", "slimeIslGenDim0", true, "True: slime islands generate in overworld; False they do not generate").getBoolean(true);
|
||||
genIslandsFlat = config.get("DimBlacklist", "genIslandsFlat", false, "Generate slime islands in flat worlds").getBoolean(false);
|
||||
|
||||
//Experimental functionality
|
||||
// Experimental functionality
|
||||
throwableSmeltery = config.get("Experimental", "Items can be thrown into smelteries", true).getBoolean(true);
|
||||
newSmeltery = config.get("Experimental", "Use new adaptive Smeltery code", false, "Warning: Very buggy").getBoolean(false);
|
||||
meltableHorses = config.get("Experimental", "Allow horses to be melted down for glue", true).getBoolean(true);
|
||||
|
||||
//Addon stuff
|
||||
// Addon stuff
|
||||
isCleaverTwoHanded = config.get("Battlegear", "Can Cleavers have shields", true).getBoolean(true);
|
||||
isHatchetWeapon = config.get("Battlegear", "Are Hatches also weapons", true).getBoolean(true);
|
||||
|
||||
//Achievement Properties
|
||||
// Achievement Properties
|
||||
achievementsEnabled = config.get("Achievement Properties", "AchievementsEnabled", true).getBoolean(true);
|
||||
|
||||
/* Save the configuration file */
|
||||
@@ -182,7 +182,7 @@ public class PHConstruct
|
||||
}
|
||||
}
|
||||
|
||||
//Ore values
|
||||
// Ore values
|
||||
public static boolean generateCopper;
|
||||
public static boolean generateTin;
|
||||
public static boolean generateAluminum;
|
||||
@@ -246,9 +246,9 @@ public class PHConstruct
|
||||
|
||||
public static int seaLevel;
|
||||
|
||||
//Mobs
|
||||
// Mobs
|
||||
|
||||
//Difficulty modifiers
|
||||
// Difficulty modifiers
|
||||
public static boolean keepHunger;
|
||||
public static boolean keepLevels;
|
||||
public static boolean alphaRegen;
|
||||
@@ -277,7 +277,7 @@ public class PHConstruct
|
||||
public static boolean miningLevelIncrease;
|
||||
public static boolean denyMattock;
|
||||
|
||||
//Smeltery Output Modification
|
||||
// Smeltery Output Modification
|
||||
public static double ingotsPerOre;
|
||||
public static double ingotsBronzeAlloy;
|
||||
public static double ingotsAluminumBrassAlloy;
|
||||
@@ -286,7 +286,7 @@ public class PHConstruct
|
||||
public static double ingotsPigironAlloy;
|
||||
|
||||
public static boolean craftEndstone;
|
||||
//Ultra Hardcore modifiers
|
||||
// Ultra Hardcore modifiers
|
||||
public static boolean enableHealthRegen;
|
||||
public static boolean goldAppleRecipe;
|
||||
public static boolean dropPlayerHeads;
|
||||
@@ -296,7 +296,7 @@ public class PHConstruct
|
||||
public static boolean freePatterns;
|
||||
public static int goldHead;
|
||||
|
||||
//Superfun
|
||||
// Superfun
|
||||
public static boolean superfunWorld;
|
||||
public static boolean beginnerBook;
|
||||
|
||||
@@ -305,25 +305,25 @@ public class PHConstruct
|
||||
|
||||
public static int islandRarity;
|
||||
|
||||
//Looks
|
||||
// Looks
|
||||
public static int connectedTexturesMode;
|
||||
public static File cfglocation;
|
||||
|
||||
//dimensionblacklist
|
||||
// dimensionblacklist
|
||||
public static boolean slimeIslGenDim0Only;
|
||||
public static int[] cfgDimBlackList;
|
||||
public static boolean slimeIslGenDim0;
|
||||
public static boolean genIslandsFlat;
|
||||
|
||||
//Experimental functionality
|
||||
// Experimental functionality
|
||||
public static boolean throwableSmeltery;
|
||||
public static boolean newSmeltery;
|
||||
public static boolean meltableHorses;
|
||||
|
||||
//Addon stuff
|
||||
// Addon stuff
|
||||
public static boolean isCleaverTwoHanded;
|
||||
public static boolean isHatchetWeapon;
|
||||
|
||||
//Achievement options
|
||||
// Achievement options
|
||||
public static boolean achievementsEnabled;
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Helper
|
||||
{
|
||||
|
||||
@@ -1,60 +1,81 @@
|
||||
package tconstruct.util.landmine;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class LandmineStack {
|
||||
public class LandmineStack
|
||||
{
|
||||
|
||||
public final boolean isBlock;
|
||||
public final Block block;
|
||||
public final Item item;
|
||||
public final int meta;
|
||||
|
||||
public LandmineStack(Block block)
|
||||
{
|
||||
this(block, -314159265);
|
||||
}
|
||||
|
||||
public LandmineStack(Item item)
|
||||
{
|
||||
this(item, -314159265);
|
||||
}
|
||||
|
||||
public LandmineStack(Block block, int meta)
|
||||
{
|
||||
isBlock = true;
|
||||
this.block = block;
|
||||
this.item = null;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public LandmineStack(Item item, int meta)
|
||||
{
|
||||
isBlock = false;
|
||||
this.block = null;
|
||||
this.item = item;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object o)
|
||||
{
|
||||
// Comparing landmine stacks
|
||||
if (o instanceof LandmineStack)
|
||||
{
|
||||
LandmineStack stack = (LandmineStack) o;
|
||||
if (isBlock)
|
||||
{
|
||||
return block == stack.block && (meta == stack.meta || meta == -314159265);
|
||||
}
|
||||
else
|
||||
{
|
||||
return item == stack.item && (meta == stack.meta || meta == -314159265);
|
||||
}
|
||||
// Comparing landmine stacks with item stacks
|
||||
}
|
||||
else if (o instanceof ItemStack)
|
||||
{
|
||||
ItemStack stack = (ItemStack) o;
|
||||
if (isBlock && stack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
return block == ((ItemBlock) stack.getItem()).field_150939_a && (meta == stack.getItemDamage() || meta == -314159265);
|
||||
}
|
||||
else if (!isBlock)
|
||||
{
|
||||
return item == stack.getItem() && (meta == stack.getItemDamage() || meta == -314159265);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isBlock;
|
||||
public final Block block;
|
||||
public final Item item;
|
||||
public final int meta;
|
||||
|
||||
public LandmineStack(Block block){
|
||||
this(block, -314159265);
|
||||
}
|
||||
|
||||
public LandmineStack(Item item){
|
||||
this(item, -314159265);
|
||||
}
|
||||
|
||||
public LandmineStack(Block block, int meta){
|
||||
isBlock = true;
|
||||
this.block = block;
|
||||
this.item = null;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public LandmineStack(Item item, int meta){
|
||||
isBlock = false;
|
||||
this.block = null;
|
||||
this.item = item;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o){
|
||||
//Comparing landmine stacks
|
||||
if(o instanceof LandmineStack){
|
||||
LandmineStack stack = (LandmineStack)o;
|
||||
if(isBlock){
|
||||
return block == stack.block && (meta == stack.meta || meta == -314159265);
|
||||
}else{
|
||||
return item == stack.item && (meta == stack.meta || meta == -314159265);
|
||||
}
|
||||
//Comparing landmine stacks with item stacks
|
||||
}else if(o instanceof ItemStack){
|
||||
ItemStack stack = (ItemStack) o;
|
||||
if(isBlock && stack.getItem() instanceof ItemBlock){
|
||||
return block == ((ItemBlock)stack.getItem()).field_150939_a && (meta == stack.getItemDamage() || meta == -314159265);
|
||||
}else if(!isBlock){
|
||||
return item == stack.getItem() && (meta == stack.getItemDamage() || meta == -314159265);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +1,27 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import tconstruct.util.landmine.LandmineStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.*;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.*;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.util.landmine.*;
|
||||
import tconstruct.util.landmine.Helper;
|
||||
import tconstruct.util.landmine.LandmineStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class Behavior
|
||||
{
|
||||
@@ -37,7 +43,7 @@ public abstract class Behavior
|
||||
|
||||
public static void registerBuiltInBehaviors ()
|
||||
{
|
||||
System.out.println("Test");
|
||||
System.out.println("Test");
|
||||
defaultBehavior = new BehaviorDefault();
|
||||
|
||||
addBehavior(new LandmineStack(Items.stick), dummy);
|
||||
@@ -54,7 +60,8 @@ public abstract class Behavior
|
||||
addBehavior(new LandmineStack(Items.ender_pearl), shoot);
|
||||
addBehavior(new LandmineStack(Items.shears), shear);
|
||||
|
||||
//Make sure the part below this comment is executed last(to avoid conflicts)
|
||||
// Make sure the part below this comment is executed last(to avoid
|
||||
// conflicts)
|
||||
Iterator i1 = Block.blockRegistry.iterator();
|
||||
while (i1.hasNext())
|
||||
{
|
||||
@@ -81,11 +88,13 @@ public abstract class Behavior
|
||||
{
|
||||
if (!behaviorsListBlocks.isEmpty())
|
||||
{
|
||||
for(int i = 0; i < behaviorsListBlocks.size(); i++){
|
||||
LandmineStack st = (LandmineStack) behaviorsListBlocks.keySet().toArray()[i];
|
||||
if(st.equals(par1ItemStack)){
|
||||
return (Behavior) behaviorsListBlocks.values().toArray()[i];
|
||||
}
|
||||
for (int i = 0; i < behaviorsListBlocks.size(); i++)
|
||||
{
|
||||
LandmineStack st = (LandmineStack) behaviorsListBlocks.keySet().toArray()[i];
|
||||
if (st.equals(par1ItemStack))
|
||||
{
|
||||
return (Behavior) behaviorsListBlocks.values().toArray()[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -98,11 +107,13 @@ public abstract class Behavior
|
||||
{
|
||||
if (!behaviorsListItems.isEmpty())
|
||||
{
|
||||
for(int i = 0; i < behaviorsListItems.size(); i++){
|
||||
LandmineStack st = (LandmineStack) behaviorsListItems.keySet().toArray()[i];
|
||||
if(st.equals(par1ItemStack)){
|
||||
return (Behavior) behaviorsListItems.values().toArray()[i];
|
||||
}
|
||||
for (int i = 0; i < behaviorsListItems.size(); i++)
|
||||
{
|
||||
LandmineStack st = (LandmineStack) behaviorsListItems.keySet().toArray()[i];
|
||||
if (st.equals(par1ItemStack))
|
||||
{
|
||||
return (Behavior) behaviorsListItems.values().toArray()[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -147,7 +158,7 @@ public abstract class Behavior
|
||||
{
|
||||
}
|
||||
|
||||
//Will return false if the effect does not stack among the slots
|
||||
// Will return false if the effect does not stack among the slots
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.World;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorBlockThrow extends Behavior
|
||||
{
|
||||
@@ -28,19 +28,19 @@ public class BehaviorBlockThrow extends Behavior
|
||||
{
|
||||
case 0:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
//vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 1:
|
||||
vec0 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
//vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 2:
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
//vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 3:
|
||||
vec2 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
//vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
// vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 4:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.world.World;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorDummy extends Behavior
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorExplosive extends Behavior
|
||||
{
|
||||
@@ -48,7 +48,8 @@ public class BehaviorExplosive extends Behavior
|
||||
str = "small";
|
||||
}
|
||||
|
||||
//par2List.add("This item explodes with " + str + " power when the landmine is triggered.");
|
||||
// par2List.add("This item explodes with " + str +
|
||||
// " power when the landmine is triggered.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,7 +59,9 @@ public class BehaviorExplosive extends Behavior
|
||||
}
|
||||
|
||||
@Override
|
||||
//Change this to false to greatly decrease the maximum potential of explosions but at the same time, make them launch the player much higher(I mean the explosions with 2 or more TNT
|
||||
// Change this to false to greatly decrease the maximum potential of
|
||||
// explosions but at the same time, make them launch the player much
|
||||
// higher(I mean the explosions with 2 or more TNT
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -14,7 +14,7 @@ import tconstruct.items.blocks.ItemBlockLandmine;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorFirecharge extends Behavior
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ import tconstruct.entity.item.EntityLandmineFirework;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorFirework extends Behavior
|
||||
{
|
||||
@@ -22,7 +22,7 @@ public class BehaviorFirework extends Behavior
|
||||
|
||||
for (int i = 0; i < par5ItemStack.stackSize; i++)
|
||||
{
|
||||
//TODO entity registration and stuffs
|
||||
// TODO entity registration and stuffs
|
||||
EntityLandmineFirework entityfireworkrocket = new EntityLandmineFirework(par1World, (double) par2, (double) par3, (double) par4, par5ItemStack, facing.ordinal())
|
||||
.setRider(i == 0 ? triggerer : null);
|
||||
par1World.spawnEntityInWorld(entityfireworkrocket);
|
||||
|
||||
@@ -17,7 +17,7 @@ import tconstruct.items.blocks.ItemBlockLandmine;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorPotion extends Behavior
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorProjectile extends Behavior
|
||||
{
|
||||
@@ -58,7 +58,7 @@ public class BehaviorProjectile extends Behavior
|
||||
par1World.playAuxSFX(1002, par2, par3, par4, 0);
|
||||
}
|
||||
|
||||
//Projectiles: snowballs, arrows
|
||||
// Projectiles: snowballs, arrows
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
|
||||
@@ -21,7 +21,7 @@ import tconstruct.items.blocks.ItemBlockLandmine;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorShears extends Behavior
|
||||
{
|
||||
@@ -87,7 +87,7 @@ public class BehaviorShears extends Behavior
|
||||
}
|
||||
}
|
||||
|
||||
//Shear some sheep around a small area
|
||||
// Shear some sheep around a small area
|
||||
|
||||
@Override
|
||||
public boolean shouldItemBeRemoved (ItemStack par1ItemStack, boolean willBlockBeRemoved)
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.World;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BehaviorSpawnEgg extends Behavior
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ import tconstruct.util.landmine.behavior.Behavior;
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class SpecialStackHandler
|
||||
{
|
||||
|
||||
@@ -5,39 +5,53 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
* AbstractPacket class. Should be the parent of all packets wishing to use the PacketPipeline.
|
||||
* AbstractPacket class. Should be the parent of all packets wishing to use the
|
||||
* PacketPipeline.
|
||||
*
|
||||
* @author sirgingalot
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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);
|
||||
}
|
||||
@@ -28,8 +28,8 @@ public class PacketDoubleJump extends AbstractPacket
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
//String user = inputStream.readUTF();
|
||||
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
// String user = inputStream.readUTF();
|
||||
// EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,34 +2,41 @@ package tconstruct.util.network.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
public class PacketExtendedInventory extends AbstractPacket
|
||||
{
|
||||
|
||||
byte type;
|
||||
byte[] type;
|
||||
|
||||
public PacketExtendedInventory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PacketExtendedInventory(byte type)
|
||||
public PacketExtendedInventory(byte[] bs)
|
||||
{
|
||||
this.type = type;
|
||||
this.type = bs;
|
||||
TConstruct.logger.error(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
buffer.writeByte(type);
|
||||
// buffer.writeBytes(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
type = buffer.readByte();
|
||||
|
||||
// type = buffer.(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,19 +48,28 @@ public class PacketExtendedInventory extends AbstractPacket
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
//String user = inputStream.readUTF();
|
||||
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
switch (type)
|
||||
// String user = inputStream.readUTF();
|
||||
// EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(type));
|
||||
try
|
||||
{
|
||||
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;
|
||||
switch (inputStream.readByte())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
TConstruct.logger.error("Failed at reading server packet for TConstruct.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,10 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Packet pipeline class. Directs all registered packet data to be handled by the packets themselves.
|
||||
* @author sirgingalot
|
||||
* some code from: cpw
|
||||
* Packet pipeline class. Directs all registered packet data to be handled by
|
||||
* the packets themselves.
|
||||
*
|
||||
* @author sirgingalot some code from: cpw
|
||||
*/
|
||||
@ChannelHandler.Sharable
|
||||
public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, AbstractPacket>
|
||||
@@ -39,11 +40,15 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
|
||||
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
|
||||
* 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)
|
||||
{
|
||||
@@ -139,7 +144,8 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
|
||||
}
|
||||
|
||||
// Method to call from FMLPostInitializationEvent
|
||||
// Ensures that packet discriminators are common between server and client by using logical sorting
|
||||
// Ensures that packet discriminators are common between server and client
|
||||
// by using logical sorting
|
||||
public void postInitialise ()
|
||||
{
|
||||
if (this.isPostInitialised)
|
||||
@@ -174,9 +180,11 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
|
||||
/**
|
||||
* 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
|
||||
* Adapted from CPW's code in
|
||||
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message
|
||||
* The message to send
|
||||
*/
|
||||
public void sendToAll (AbstractPacket message)
|
||||
{
|
||||
@@ -187,10 +195,13 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
|
||||
/**
|
||||
* 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
|
||||
* 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)
|
||||
{
|
||||
@@ -202,10 +213,15 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
|
||||
/**
|
||||
* 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
|
||||
* 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)
|
||||
{
|
||||
@@ -217,10 +233,13 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
|
||||
/**
|
||||
* 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
|
||||
* 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)
|
||||
{
|
||||
@@ -232,9 +251,11 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
|
||||
/**
|
||||
* 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
|
||||
* Adapted from CPW's code in
|
||||
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||
*
|
||||
* @param message
|
||||
* The message to send
|
||||
*/
|
||||
public void sendToServer (AbstractPacket message)
|
||||
{
|
||||
|
||||
@@ -70,7 +70,10 @@ public class PacketSmeltery extends AbstractPacket
|
||||
FluidStack temp = null;
|
||||
|
||||
for (FluidStack liquid : ((SmelteryLogic) te).moltenMetal)
|
||||
{//TODO update fluid stuffs
|
||||
{// TODO
|
||||
// update
|
||||
// fluid
|
||||
// stuffs
|
||||
if (liquid.fluidID == fluidID)
|
||||
{
|
||||
temp = liquid;
|
||||
@@ -85,8 +88,10 @@ public class PacketSmeltery extends AbstractPacket
|
||||
else
|
||||
((SmelteryLogic) te).moltenMetal.add(0, temp);
|
||||
}
|
||||
//TODO check if this works like it should
|
||||
//Old code: PacketDispatcher.sendPacketToAllInDimension(te.getDescriptionPacket(), dimension);
|
||||
// TODO check if this works like it should
|
||||
// Old code:
|
||||
// PacketDispatcher.sendPacketToAllInDimension(te.getDescriptionPacket(),
|
||||
// dimension);
|
||||
FMLCommonHandler.instance().getClientToServerNetworkManager().scheduleOutboundPacket(te.getDescriptionPacket());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ArmorExtended implements IInventory
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
//TConstruct.logger.info("Took something from slot " + slot);
|
||||
// TConstruct.logger.info("Took something from slot " + slot);
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
ItemStack stack = inventory[slot];
|
||||
@@ -82,7 +82,8 @@ public class ArmorExtended implements IInventory
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
inventory[slot] = itemstack;
|
||||
//TConstruct.logger.info("Changed slot " + slot + " on side " + FMLCommonHandler.instance().getEffectiveSide());
|
||||
// TConstruct.logger.info("Changed slot " + slot + " on side " +
|
||||
// FMLCommonHandler.instance().getEffectiveSide());
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
@@ -116,39 +117,23 @@ public class ArmorExtended implements IInventory
|
||||
{
|
||||
EntityPlayer player = parent.get();
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.getDisplayName());
|
||||
//recalculateSkills(player, stats);
|
||||
// recalculateSkills(player, stats);
|
||||
recalculateHealth(player, stats);
|
||||
|
||||
/*if (inventory[2] == null && stats.knapsack != null)
|
||||
{
|
||||
stats.knapsack.unequipItems();
|
||||
}*/
|
||||
/*
|
||||
* if (inventory[2] == null && stats.knapsack != null) {
|
||||
* stats.knapsack.unequipItems(); }
|
||||
*/
|
||||
}
|
||||
|
||||
/*public void recalculateSkills(EntityPlayer player, TPlayerStats stats)
|
||||
{
|
||||
if (inventory[1] != null && inventory[1].getItem() == TRepo.glove)
|
||||
{
|
||||
if (stats.skillList.size() < 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
stats.skillList.add(SkillRegistry.skills.get("Wall Building").copy());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stats.skillList.size() > 0)
|
||||
{
|
||||
stats.skillList.remove(0);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* public void recalculateSkills(EntityPlayer player, TPlayerStats stats) {
|
||||
* if (inventory[1] != null && inventory[1].getItem() == TRepo.glove) { if
|
||||
* (stats.skillList.size() < 1) { try {
|
||||
* stats.skillList.add(SkillRegistry.skills.get("Wall Building").copy()); }
|
||||
* catch (Exception e) { e.printStackTrace(); } } } else { if
|
||||
* (stats.skillList.size() > 0) { stats.skillList.remove(0); } } }
|
||||
*/
|
||||
|
||||
public void recalculateHealth (EntityPlayer player, TPlayerStats stats)
|
||||
{
|
||||
@@ -158,7 +143,8 @@ public class ArmorExtended implements IInventory
|
||||
{
|
||||
ItemStack stack = inventory[6];
|
||||
int meta = stack.getItemDamage();
|
||||
//TConstruct.logger.info("Calculating HP on side " + FMLCommonHandler.instance().getEffectiveSide());
|
||||
// TConstruct.logger.info("Calculating HP on side " +
|
||||
// FMLCommonHandler.instance().getEffectiveSide());
|
||||
if (meta == 2)
|
||||
{
|
||||
int prevHealth = stats.bonusHealth;
|
||||
@@ -172,7 +158,7 @@ public class ArmorExtended implements IInventory
|
||||
stats.bonusHealth = bonusHP;
|
||||
|
||||
int healthChange = bonusHP - prevHealth;
|
||||
//TConstruct.logger.info("healthChange: "+healthChange+" on side "+FMLCommonHandler.instance().getEffectiveSide());
|
||||
// TConstruct.logger.info("healthChange: "+healthChange+" on side "+FMLCommonHandler.instance().getEffectiveSide());
|
||||
if (healthChange != 0)
|
||||
{
|
||||
IAttributeInstance attributeinstance = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
|
||||
|
||||
@@ -2,29 +2,14 @@ package tconstruct.util.player;
|
||||
|
||||
public class ArmorExtendedClient extends ArmorExtended
|
||||
{
|
||||
/*public void recalculateSkills(EntityPlayer player, TPlayerStats stats)
|
||||
{
|
||||
TConstruct.logger.info("Client skills");
|
||||
if (inventory[1] != null && inventory[1].getItem() == TContent.glove)
|
||||
{
|
||||
if (TProxyClient.skillList.size() < 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
TProxyClient.skillList.add(SkillRegistry.skills.get("Wall Building").copy());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TProxyClient.skillList.size() > 0)
|
||||
{
|
||||
TProxyClient.skillList.remove(0);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* public void recalculateSkills(EntityPlayer player, TPlayerStats stats) {
|
||||
* TConstruct.logger.info("Client skills"); if (inventory[1] != null &&
|
||||
* inventory[1].getItem() == TContent.glove) { if
|
||||
* (TProxyClient.skillList.size() < 1) { try {
|
||||
* TProxyClient.skillList.add(SkillRegistry
|
||||
* .skills.get("Wall Building").copy()); } catch (Exception e) {
|
||||
* e.printStackTrace(); } } } else { if (TProxyClient.skillList.size() > 0)
|
||||
* { TProxyClient.skillList.remove(0); } } }
|
||||
*/
|
||||
}
|
||||
@@ -34,7 +34,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
public class TPlayerHandler
|
||||
{
|
||||
/* Player */
|
||||
//public int hunger;
|
||||
// public int hunger;
|
||||
|
||||
public ConcurrentHashMap<String, TPlayerStats> playerStats = new ConcurrentHashMap<String, TPlayerStats>();
|
||||
|
||||
@@ -64,8 +64,8 @@ public class TPlayerHandler
|
||||
|
||||
public void onPlayerLogin (EntityPlayer entityplayer)
|
||||
{
|
||||
//TConstruct.logger.info("Player: "+entityplayer);
|
||||
//Lookup player
|
||||
// TConstruct.logger.info("Player: "+entityplayer);
|
||||
// Lookup player
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
if (!tags.hasKey("TConstruct"))
|
||||
{
|
||||
@@ -86,7 +86,7 @@ public class TPlayerHandler
|
||||
stats.beginnerManual = tags.getCompoundTag("TConstruct").getBoolean("beginnerManual");
|
||||
stats.materialManual = tags.getCompoundTag("TConstruct").getBoolean("materialManual");
|
||||
stats.smelteryManual = tags.getCompoundTag("TConstruct").getBoolean("smelteryManual");
|
||||
//gamerule naturalRegeneration false
|
||||
// gamerule naturalRegeneration false
|
||||
if (!PHConstruct.enableHealthRegen)
|
||||
entityplayer.worldObj.getGameRules().setOrCreateGameRule("naturalRegeneration", "false");
|
||||
if (!stats.beginnerManual)
|
||||
@@ -157,14 +157,15 @@ public class TPlayerHandler
|
||||
|
||||
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);
|
||||
*/
|
||||
//TODO find out what packet needs to be used here (and make sure that player actually is a playerMP and this gets called)
|
||||
/*
|
||||
* Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
* packet.channel = "TConstruct"; packet.data = bos.toByteArray();
|
||||
* packet.length = bos.size();
|
||||
*
|
||||
* PacketDispatcher.sendPacketToPlayer(packet, (Player) player);
|
||||
*/
|
||||
// TODO find out what packet needs to be used here (and make sure that
|
||||
// player actually is a playerMP and this gets called)
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
TConstruct.packetPipeline.sendTo(new PacketDoubleJump(), (EntityPlayerMP) player);
|
||||
@@ -184,7 +185,7 @@ public class TPlayerHandler
|
||||
playerStats.remove(player.getDisplayName());
|
||||
}
|
||||
else
|
||||
//Revalidate all players
|
||||
// Revalidate all players
|
||||
{
|
||||
|
||||
}
|
||||
@@ -193,13 +194,14 @@ public class TPlayerHandler
|
||||
|
||||
public void onPlayerRespawn (EntityPlayer entityplayer)
|
||||
{
|
||||
//Boom!
|
||||
// Boom!
|
||||
TPlayerStats stats = getPlayerStats(entityplayer.getDisplayName());
|
||||
stats.player = new WeakReference<EntityPlayer>(entityplayer);
|
||||
stats.armor.recalculateHealth(entityplayer, stats);
|
||||
|
||||
/*TFoodStats food = new TFoodStats();
|
||||
entityplayer.foodStats = food;*/
|
||||
/*
|
||||
* TFoodStats food = new TFoodStats(); entityplayer.foodStats = food;
|
||||
*/
|
||||
|
||||
if (PHConstruct.keepLevels)
|
||||
entityplayer.experienceLevel = stats.level;
|
||||
@@ -215,14 +217,14 @@ public class TPlayerHandler
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT)
|
||||
{
|
||||
//TProxyClient.controlInstance.resetControls();
|
||||
// TProxyClient.controlInstance.resetControls();
|
||||
if (PHConstruct.keepHunger)
|
||||
entityplayer.getFoodStats().setFoodLevel(stats.hunger);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void livingFall (LivingFallEvent evt) //Only for negating fall damage
|
||||
public void livingFall (LivingFallEvent evt) // Only for negating fall damage
|
||||
{
|
||||
if (evt.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
@@ -230,34 +232,25 @@ public class TPlayerHandler
|
||||
}
|
||||
}
|
||||
|
||||
/*@SubscribeEvent
|
||||
public void livingUpdate (LivingUpdateEvent evt)
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT && evt.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) evt.entityLiving;
|
||||
TPlayerStats stats = playerStats.get(player.getDisplayName());
|
||||
if (player.onGround != stats.prevOnGround)
|
||||
{
|
||||
if (player.onGround)// && -stats.prevMotionY > 0.1)
|
||||
//player.motionY = 0.5;
|
||||
player.motionY = -stats.prevMotionY * 0.8;
|
||||
//player.motionY *= -1.2;
|
||||
stats.prevOnGround = player.onGround;
|
||||
//if ()
|
||||
|
||||
//TConstruct.logger.info("Fall: "+player.fallDistance);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* @SubscribeEvent public void livingUpdate (LivingUpdateEvent evt) { Side
|
||||
* side = FMLCommonHandler.instance().getEffectiveSide(); if (side ==
|
||||
* Side.CLIENT && evt.entityLiving instanceof EntityPlayer) { EntityPlayer
|
||||
* player = (EntityPlayer) evt.entityLiving; TPlayerStats stats =
|
||||
* playerStats.get(player.getDisplayName()); if (player.onGround !=
|
||||
* stats.prevOnGround) { if (player.onGround)// && -stats.prevMotionY > 0.1)
|
||||
* //player.motionY = 0.5; player.motionY = -stats.prevMotionY * 0.8;
|
||||
* //player.motionY *= -1.2; stats.prevOnGround = player.onGround; //if ()
|
||||
*
|
||||
* //TConstruct.logger.info("Fall: "+player.fallDistance); } } }
|
||||
*/
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerDrops (PlayerDropsEvent evt)
|
||||
{
|
||||
TPlayerStats stats = getPlayerStats(evt.entityPlayer.getDisplayName());
|
||||
stats.level = evt.entityPlayer.experienceLevel / 2;
|
||||
//stats.health = 20;
|
||||
// stats.health = 20;
|
||||
int hunger = evt.entityPlayer.getFoodStats().getFoodLevel();
|
||||
if (hunger < 6)
|
||||
stats.hunger = 6;
|
||||
@@ -269,7 +262,7 @@ public class TPlayerHandler
|
||||
public TPlayerStats getPlayerStats (String username)
|
||||
{
|
||||
TPlayerStats stats = playerStats.get(username);
|
||||
//TConstruct.logger.info("Stats: "+stats);
|
||||
// TConstruct.logger.info("Stats: "+stats);
|
||||
if (stats == null)
|
||||
{
|
||||
stats = new TPlayerStats();
|
||||
@@ -294,14 +287,15 @@ public class TPlayerHandler
|
||||
/* Modify Player */
|
||||
public void updateSize (String user, float offset)
|
||||
{
|
||||
/*EntityPlayer player = getEntityPlayer(user);
|
||||
setEntitySize(0.6F, offset, player);
|
||||
player.yOffset = offset - 0.18f;*/
|
||||
/*
|
||||
* EntityPlayer player = getEntityPlayer(user); setEntitySize(0.6F,
|
||||
* offset, player); player.yOffset = offset - 0.18f;
|
||||
*/
|
||||
}
|
||||
|
||||
public static void setEntitySize (float width, float height, Entity entity)
|
||||
{
|
||||
//TConstruct.logger.info("Size: " + height);
|
||||
// TConstruct.logger.info("Size: " + height);
|
||||
if (width != entity.width || height != entity.height)
|
||||
{
|
||||
entity.width = width;
|
||||
@@ -337,7 +331,7 @@ public class TPlayerHandler
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_6;
|
||||
}
|
||||
//entity.yOffset = height;
|
||||
// entity.yOffset = height;
|
||||
}
|
||||
|
||||
Random rand = new Random();
|
||||
|
||||
Reference in new issue
Block a user