diff --git a/tconstruct/TConstruct.java b/tconstruct/TConstruct.java index cdfcce31..f9682ddb 100644 --- a/tconstruct/TConstruct.java +++ b/tconstruct/TConstruct.java @@ -1,6 +1,5 @@ package tconstruct; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import tconstruct.common.TContent; import tconstruct.common.TProxyCommon; @@ -10,7 +9,9 @@ import tconstruct.library.TConstructRegistry; import tconstruct.library.crafting.Detailing; import tconstruct.library.crafting.LiquidCasting; import tconstruct.library.util.TabTools; +import tconstruct.skill.Jump; import tconstruct.skill.SkillRegistry; +import tconstruct.skill.WallBuilding; import tconstruct.util.PHConstruct; import tconstruct.util.TCraftingHandler; import tconstruct.util.TEventHandler; @@ -23,9 +24,7 @@ import tconstruct.worldgen.village.VillageToolStationHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.Mod.PostInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; diff --git a/tconstruct/client/TClientEvents.java b/tconstruct/client/TClientEvents.java index 9f701aec..720ae756 100644 --- a/tconstruct/client/TClientEvents.java +++ b/tconstruct/client/TClientEvents.java @@ -1,8 +1,9 @@ package tconstruct.client; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.SoundPool; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.Tessellator; @@ -12,14 +13,19 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.client.event.sound.SoundLoadEvent; import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; + +import org.lwjgl.opengl.GL11; + import tconstruct.TConstruct; import tconstruct.blocks.LiquidMetalFinite; import tconstruct.client.armor.WingModel; import tconstruct.common.TContent; +import tconstruct.skill.Skill; import tconstruct.util.player.TPlayerStats; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -29,21 +35,6 @@ public class TClientEvents { Minecraft mc = Minecraft.getMinecraft(); - /*@ForgeSubscribe - public void interact (PlayerInteractEvent event) - { - if (event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote) - { - System.out.println("Fired"); - List skills = TProxyClient.skillList; - if (skills.size() > 0) - { - Skill walls = TConstruct.playerTracker.getPlayerStats(event.entityPlayer.username).skillList.get(0); - walls.rightClickActivate(event.entityPlayer, event.entityPlayer.worldObj); - } - } - }*/ - /* Sounds */ /*boolean initSounds; @@ -131,7 +122,7 @@ public class TClientEvents this.mc.func_110434_K().func_110577_a(icons); }*/ - /*if (event.type == RenderGameOverlayEvent.ElementType.HOTBAR) + if (event.type == RenderGameOverlayEvent.ElementType.HOTBAR) { if (stats.skillList == null) return; @@ -142,12 +133,13 @@ public class TClientEvents { if (!skill.getActive()) GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0F); - this.mc.renderEngine.bindTexture(skill.getTextureFile(scaledresolution.getScaleFactor())); + this.mc.func_110434_K().func_110577_a(skill.getResource(scaledresolution.getScaleFactor())); + //this.mc.renderEngine.bindTexture(skill.getTextureFile(scaledresolution.getScaleFactor())); this.drawTexturedModalRect((2+amount*18)*16, 32, 0, 0, 256, 256); amount++; } GL11.glScalef(16f, 16f, 16f); - }*/ + } } public void drawTexturedModalRect (int par1, int par2, int par3, int par4, int par5, int par6) diff --git a/tconstruct/client/TControls.java b/tconstruct/client/TControls.java index 9f575835..173bfea5 100644 --- a/tconstruct/client/TControls.java +++ b/tconstruct/client/TControls.java @@ -42,7 +42,7 @@ public class TControls extends TKeyHandler public TControls() { - super(new KeyBinding[] { armorKey /*, skillOne, skillTwo, skillThree, skillFour, skillFive*/}, new boolean[] { false /*, false, false, false, false, false*/}, getVanillaKeyBindings(), + super(new KeyBinding[] { armorKey ,/* skillOne, skillTwo, skillThree, skillFour, skillFive*/}, new boolean[] { false , /*false, false, false, false, false*/}, getVanillaKeyBindings(), new boolean[] { false, false }); //System.out.println("Controls registered");Natura } @@ -265,10 +265,10 @@ public class TControls extends TKeyHandler { TConstruct.playerTracker.activateSkill(player, key); - System.out.println(MinecraftServer.getServer()); + //System.out.println(MinecraftServer.getServer()); if (MinecraftServer.getServer().isDedicatedServer()) { - System.out.println("Send"); + //System.out.println("Send"); ByteArrayOutputStream bos = new ByteArrayOutputStream(8); DataOutputStream outputStream = new DataOutputStream(bos); try diff --git a/tconstruct/client/TProxyClient.java b/tconstruct/client/TProxyClient.java index 0cce7159..1ba0ebce 100644 --- a/tconstruct/client/TProxyClient.java +++ b/tconstruct/client/TProxyClient.java @@ -169,7 +169,6 @@ public class TProxyClient extends TProxyCommon public static ArmorExtended armorExtended = new ArmorExtended(); public static KnapsackInventory knapsack = new KnapsackInventory(); - public static TPlayerStats stats = new TPlayerStats(); @Override public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) diff --git a/tconstruct/skill/Jump.java b/tconstruct/skill/Jump.java index e5d23c2a..db27a323 100644 --- a/tconstruct/skill/Jump.java +++ b/tconstruct/skill/Jump.java @@ -1,20 +1,16 @@ package tconstruct.skill; import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class Jump extends Skill { + private static final ResourceLocation three = new ResourceLocation("tinker", "textures/skill/Jump48x.png"); @Override - public String getTextureFile (int guiscale) + public ResourceLocation getResource (int guiscale) { - /*if (guiscale == 2) - return "/mods/tinker/textures/skill/Jump32x.png"; - if (guiscale == 3) - return "/mods/tinker/textures/skill/Jump48x.png"; - - return "/mods/tinker/textures/skill/Jump16x.png";*/ - return "/mods/tinker/textures/skill/Jump48x.png"; + return three; } @Override diff --git a/tconstruct/skill/Skill.java b/tconstruct/skill/Skill.java index dc1c4922..95d30831 100644 --- a/tconstruct/skill/Skill.java +++ b/tconstruct/skill/Skill.java @@ -2,6 +2,7 @@ package tconstruct.skill; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; /* Base skill @@ -13,7 +14,8 @@ public abstract class Skill public int skillID; boolean active = true; - public abstract String getTextureFile (int guiscale); + //public abstract String getTextureFile (int guiscale); + public abstract ResourceLocation getResource(int guiscale); public abstract String getSkillName (); diff --git a/tconstruct/skill/SkillRegistry.java b/tconstruct/skill/SkillRegistry.java index b8e7a545..4650e036 100644 --- a/tconstruct/skill/SkillRegistry.java +++ b/tconstruct/skill/SkillRegistry.java @@ -19,4 +19,9 @@ public class SkillRegistry { return skillID++; } + + public static Skill getSkill(String name) + { + return skills.get(name); + } } diff --git a/tconstruct/skill/WallBuilding.java b/tconstruct/skill/WallBuilding.java index 0429fa3f..49b42db6 100644 --- a/tconstruct/skill/WallBuilding.java +++ b/tconstruct/skill/WallBuilding.java @@ -1,6 +1,5 @@ package tconstruct.skill; -import tconstruct.library.tools.AbilityHelper; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -8,19 +7,24 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import tconstruct.library.tools.AbilityHelper; public class WallBuilding extends Skill { + private static final ResourceLocation one = new ResourceLocation("tinker", "textures/skill/Wall16x.png"); + private static final ResourceLocation two = new ResourceLocation("tinker", "textures/skill/Wall32x.png"); + private static final ResourceLocation three = new ResourceLocation("tinker", "textures/skill/Wall48x.png"); + @Override - public String getTextureFile (int guiscale) + public ResourceLocation getResource (int guiscale) { if (guiscale == 2) - return "/mods/tinker/textures/skill/Wall32x.png"; + return two; if (guiscale == 3) - return "/mods/tinker/textures/skill/Wall48x.png"; - - return "/mods/tinker/textures/skill/Wall16x.png"; + return three; + return one; } @Override @@ -33,6 +37,7 @@ public class WallBuilding extends Skill public void activate (Entity entity, World world) { this.active = !active; + System.out.println("Active: " + active); } @Override @@ -94,6 +99,8 @@ public class WallBuilding extends Skill zMax = 1; } + ItemStack copy = stack.copy(); + for (int y = -1; y <= 1; y++) { for (int x = xMin; x <= xMax; x++) @@ -101,31 +108,34 @@ public class WallBuilding extends Skill for (int z = zMin; z <= zMax; z++) { stack.getItem().onItemUse(stack, player, world, xPos + x, yPos + y, zPos + z, mop.sideHit, 0, 0, 0); + if (player.capabilities.isCreativeMode) + { + stack = copy.copy(); + } + if (stack.stackSize < 1) { player.inventory.setInventorySlotContents(player.inventory.currentItem, null); break; } - //world.setBlock(xPos + x, yPos + y, zPos + z, Block.whiteStone.blockID); } } } - //entity.worldObj.setBlock(xPos, yPos, zPos, Block.stone.blockID, 0, 3); - world.playAuxSFX(2001, xPos, yPos, zPos, Block.stone.blockID + (0 << 12)); + + if (player.capabilities.isCreativeMode) + { + player.inventory.setInventorySlotContents(player.inventory.currentItem, stack); + } + Block block = Block.blocksList[copy.itemID]; + if (block != null) + { + world.playSoundEffect((double) ((float) xPos + 0.5F), (double) ((float) yPos + 0.5F), (double) ((float) zPos + 0.5F), block.stepSound.getPlaceSound(), + (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + } + //world.playAuxSFX(2001, xPos, yPos, zPos, copy.itemID + (copy.getItemDamage() << 12)); } } } - /*for (int x = -2; x <= 2; x++) - { - for (int y = -1; y <= 1; y++) - { - //for (int z = -2; z <= 2; z++) - { - world.setBlock((int) Math.floor(entity.posX) + x, (int) Math.floor(entity.posY) + y, (int) Math.floor(entity.posZ) + 2, Block.whiteStone.blockID); - } - } - } - world.playAuxSFX(2001, (int) entity.posX, (int) entity.posY, (int) entity.posZ, Block.stone.blockID + (0 << 12));*/ } } diff --git a/tconstruct/util/TEventHandler.java b/tconstruct/util/TEventHandler.java index 80c0f69c..21e4ba69 100644 --- a/tconstruct/util/TEventHandler.java +++ b/tconstruct/util/TEventHandler.java @@ -1,29 +1,10 @@ package tconstruct.util; import java.util.ArrayList; +import java.util.List; import java.util.Random; -import tconstruct.TConstruct; -import tconstruct.blocks.logic.LiquidTextureLogic; -import tconstruct.common.TContent; -import tconstruct.crystal.TheftValueTracker; -import tconstruct.library.TConstructRegistry; -import tconstruct.library.crafting.PatternBuilder; -import tconstruct.library.crafting.Smeltery; -import tconstruct.library.crafting.ToolBuilder; -import tconstruct.library.event.PartBuilderEvent; -import tconstruct.library.event.ToolCraftEvent; -import tconstruct.library.tools.ArrowMaterial; -import tconstruct.library.tools.BowMaterial; -import tconstruct.library.tools.BowstringMaterial; -import tconstruct.library.tools.FletchingMaterial; -import tconstruct.library.tools.ToolCore; -import tconstruct.library.util.ValueCoordTuple; -import tconstruct.modifiers.ModAttack; -import tconstruct.util.player.TPlayerStats; - import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.monster.EntityCreeper; @@ -47,10 +28,30 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.entity.player.FillBucketEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.event.world.ChunkDataEvent; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent; +import tconstruct.TConstruct; +import tconstruct.common.TContent; +import tconstruct.crystal.TheftValueTracker; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.PatternBuilder; +import tconstruct.library.crafting.Smeltery; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.event.PartBuilderEvent; +import tconstruct.library.event.ToolCraftEvent; +import tconstruct.library.tools.ArrowMaterial; +import tconstruct.library.tools.BowMaterial; +import tconstruct.library.tools.BowstringMaterial; +import tconstruct.library.tools.FletchingMaterial; +import tconstruct.library.tools.ToolCore; +import tconstruct.library.util.ValueCoordTuple; +import tconstruct.modifiers.ModAttack; +import tconstruct.skill.Skill; +import tconstruct.util.player.TPlayerStats; public class TEventHandler { @@ -204,19 +205,19 @@ public class TEventHandler /* Interact */ - /*@ForgeSubscribe + @ForgeSubscribe public void interact (PlayerInteractEvent event) { - if (event.action == Action.RIGHT_CLICK_BLOCK)// && !event.entityPlayer.worldObj.isRemote) + if (event.action == Action.RIGHT_CLICK_BLOCK) { List skills = TConstruct.playerTracker.getPlayerStats(event.entityPlayer.username).skillList; if (skills.size() > 0) { - Skill walls = TConstruct.playerTracker.getPlayerStats(event.entityPlayer.username).skillList.get(0); + Skill walls = skills.get(0); walls.rightClickActivate(event.entityPlayer, event.entityPlayer.worldObj); } } - }*/ + } /* Damage */ /*@ForgeSubscribe diff --git a/tconstruct/util/player/TPlayerHandler.java b/tconstruct/util/player/TPlayerHandler.java index 75d4b878..caf66820 100644 --- a/tconstruct/util/player/TPlayerHandler.java +++ b/tconstruct/util/player/TPlayerHandler.java @@ -8,11 +8,6 @@ import java.util.List; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; -import tconstruct.common.TContent; -import tconstruct.library.tools.AbilityHelper; -import tconstruct.skill.Skill; -import tconstruct.util.PHConstruct; - import net.minecraft.entity.Entity; import net.minecraft.entity.EnumEntitySize; import net.minecraft.entity.player.EntityPlayer; @@ -22,6 +17,11 @@ import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.player.PlayerDropsEvent; +import tconstruct.common.TContent; +import tconstruct.library.tools.AbilityHelper; +import tconstruct.skill.Skill; +import tconstruct.skill.SkillRegistry; +import tconstruct.util.PHConstruct; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.IPlayerTracker; import cpw.mods.fml.common.Loader; @@ -77,7 +77,8 @@ public class TPlayerHandler implements IPlayerTracker } } - stats.skillList = new ArrayList(); + /*stats.skillList = new ArrayList(); + stats.skillList.add(SkillRegistry.getSkill("Wall Building"));*/ //stats.armor.recalculateSkills(entityplayer, stats); playerStats.put(entityplayer.username, stats); @@ -105,7 +106,7 @@ public class TPlayerHandler implements IPlayerTracker } updatePlayerInventory(entityplayer, stats); - //sendSkills(entityplayer, stats); + sendSkills(entityplayer, stats); } void updatePlayerInventory (EntityPlayer entityplayer, TPlayerStats stats)