diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6f3bcd6..75da557 100644 --- a/build.gradle +++ b/build.gradle @@ -7,12 +7,12 @@ buildscript { } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' } } apply plugin: 'net.minecraftforge.gradle.forge' -version = "0.0.2" +version = "0.0.3" group= "uk.co.haxyshideout.ChocoCraft2" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "ChocoCraft2" @@ -24,9 +24,9 @@ configurations { } minecraft { - version = "1.8-11.14.3.1550" + version = "1.9-12.16.0.1865-1.9" runDir = "run" - mappings = "snapshot_20151106" + mappings = "snapshot_20160312" } reobfJar { diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/blocks/GysahlStemBlock.java b/src/main/java/uk/co/haxyshideout/chococraft2/blocks/GysahlStemBlock.java index fe0de00..117d759 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/blocks/GysahlStemBlock.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/blocks/GysahlStemBlock.java @@ -1,49 +1,59 @@ package uk.co.haxyshideout.chococraft2.blocks; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.IGrowable; +import net.minecraft.block.SoundType; import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import uk.co.haxyshideout.chococraft2.config.Additions; import uk.co.haxyshideout.haxylib.blocks.GenericBush; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - /** * Created by clienthax on 12/4/2015. */ -public class GysahlStemBlock extends GenericBush implements IGrowable { - +public class GysahlStemBlock extends GenericBush implements IGrowable +{ public static final Integer MAXSTAGE = 4; public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, MAXSTAGE); - public GysahlStemBlock() { + public GysahlStemBlock() + { setTickRandomly(true); this.setDefaultState(this.blockState.getBaseState().withProperty(STAGE, 0)); - float f = 0.4F; - this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); - this.setStepSound(soundTypeGrass); + this.setStepSound(SoundType.GROUND); this.setHardness(0f); } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) { + public AxisAlignedBB getCollisionBoundingBox(IBlockState worldIn, World pos, BlockPos state) + { + float f = 0.4F; + return new AxisAlignedBB(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); + } + + @Override + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) + { return new ItemStack(Additions.gysahlSeedsItem); } @Override - public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { - if(worldIn.isRemote) + public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random rand) + { + if (worldIn.isRemote) return; super.updateTick(worldIn, pos, state, rand); @@ -53,16 +63,19 @@ public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random ra @Override public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - //if stage = max stage, drop gysahl green item, else drop nothing + // if stage = max stage, drop gysahl green item, else drop nothing List ret = new ArrayList(); - if(state.getValue(STAGE) == MAXSTAGE) { - Random rand = world instanceof World ? ((World)world).rand : new Random(); + if (state.getValue(STAGE) == MAXSTAGE) + { + Random rand = world instanceof World ? ((World) world).rand : new Random(); ret.add(getGysahlItem(rand)); - //If fully grown give a seed drop chance + // If fully grown give a seed drop chance int seedAmount = 3 + fortune; - for(int i = 0; i < seedAmount; i++) { - if(rand.nextInt(15) < 7) { + for (int i = 0; i < seedAmount; i++) + { + if (rand.nextInt(15) < 7) + { ret.add(new ItemStack(Additions.gysahlSeedsItem)); } } @@ -71,52 +84,60 @@ public java.util.List getDrops(IBlockAccess world, return ret; } - private ItemStack getGysahlItem(Random random) { + private ItemStack getGysahlItem(Random random) + { Item item; int chance = random.nextInt(200); - if(chance < 10) + if (chance < 10) item = Additions.gysahlGoldenItem; - else if(chance < 30) + else if (chance < 30) item = Additions.gysahlLoverlyItem; else item = Additions.gysahlGreenItem; - return new ItemStack(item); } @Override - public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { + public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) + { return true; } @Override - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { + public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) + { return true; } @Override - public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { + public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) + { super.updateTick(worldIn, pos, state, rand); this.growStem(worldIn, rand, pos, state); } - private void growStem(World worldIn, Random rand, BlockPos pos, IBlockState state) { - if(worldIn.getLightFromNeighbors(pos) >= 9) { - if( (Integer) state.getValue(STAGE) < MAXSTAGE) { + private void growStem(World worldIn, Random rand, BlockPos pos, IBlockState state) + { + if (worldIn.getLightFromNeighbors(pos) >= 9) + { + if ((Integer) state.getValue(STAGE) < MAXSTAGE) + { float growthChance = getGrowthChance(this, worldIn, pos); - if(rand.nextInt((int)(25F / growthChance) + 1) == 0) { + if (rand.nextInt((int) (25F / growthChance) + 1) == 0) + { worldIn.setBlockState(pos, state.cycleProperty(STAGE), 2); } } } } - public void setGrowthStage(World world, BlockPos pos, IBlockState state) { + public void setGrowthStage(World world, BlockPos pos, IBlockState state) + { world.setBlockState(pos, state.withProperty(STAGE, 4), 2); } - //Stolen from BlockCrops + // Stolen from BlockCrops public float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) { float f = 1.0F; @@ -129,7 +150,7 @@ public float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) float f1 = 0.0F; IBlockState iblockstate = worldIn.getBlockState(blockUnder.add(i, 0, j)); - if (iblockstate.getBlock().canSustainPlant(worldIn, blockUnder.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) + if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockUnder.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) { f1 = 1.0F; @@ -172,7 +193,6 @@ public float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) return f; } - /** * Convert the given metadata into a BlockState for this Block */ @@ -192,10 +212,8 @@ public int getMetaFromState(IBlockState state) } @Override - protected BlockState createBlockState() + protected BlockStateContainer createBlockState() { - return new BlockState(this, STAGE); + return new BlockStateContainer(this, STAGE); } - - } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/blocks/StrawBlock.java b/src/main/java/uk/co/haxyshideout/chococraft2/blocks/StrawBlock.java index 6ee6bec..3dda1b7 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/blocks/StrawBlock.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/blocks/StrawBlock.java @@ -1,20 +1,29 @@ package uk.co.haxyshideout.chococraft2.blocks; -import net.minecraft.block.Block; +import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import uk.co.haxyshideout.haxylib.blocks.GenericBlock; /** * Created by clienthax on 13/4/2015. */ -public class StrawBlock extends GenericBlock { - - public StrawBlock() { +public class StrawBlock extends GenericBlock +{ + public StrawBlock() + { super(Material.carpet); - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); setOpaque(false); setFullCube(false); - setStepSound(Block.soundTypeGrass); + setStepSound(SoundType.GROUND); } + @Override + public AxisAlignedBB getCollisionBoundingBox(IBlockState worldIn, World pos, BlockPos state) + { + return new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); + } } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/client/gui/ChocopediaGui.java b/src/main/java/uk/co/haxyshideout/chococraft2/client/gui/ChocopediaGui.java index 1b929f8..940beff 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/client/gui/ChocopediaGui.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/client/gui/ChocopediaGui.java @@ -35,7 +35,7 @@ enum InputType { public ChocopediaGui(EntityChocobo chocobo) { this.chocobo = chocobo; - owner = Minecraft.getMinecraft().thePlayer.getCommandSenderName(); + owner = Minecraft.getMinecraft().thePlayer.getName(); name = chocobo.getCustomNameTag(); movementType = chocobo.getMovementType(); } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/commands/DebugCommand.java b/src/main/java/uk/co/haxyshideout/chococraft2/commands/DebugCommand.java index 9eec80e..932c4de 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/commands/DebugCommand.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/commands/DebugCommand.java @@ -4,6 +4,7 @@ import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; import uk.co.haxyshideout.chococraft2.config.Constants; import uk.co.haxyshideout.chococraft2.entities.DefaultNames; import uk.co.haxyshideout.chococraft2.entities.EntityChocobo; @@ -27,8 +28,8 @@ public String getCommandUsage(ICommandSender sender) { } @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - + public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException + { DebugHelper.langCheck(Constants.MODID); EntityChocobo chocobo = new EntityChocobo(sender.getEntityWorld()); diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/config/Additions.java b/src/main/java/uk/co/haxyshideout/chococraft2/config/Additions.java index e7b71d9..69e1328 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/config/Additions.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/config/Additions.java @@ -1,15 +1,19 @@ package uk.co.haxyshideout.chococraft2.config; -import uk.co.haxyshideout.chococraft2.entities.EntityChocobo.ChocoboColor; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.init.PotionTypes; +import net.minecraft.init.SoundEvents; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.PotionType; import net.minecraftforge.common.util.EnumHelper; import uk.co.haxyshideout.chococraft2.blocks.GysahlStemBlock; import uk.co.haxyshideout.chococraft2.blocks.StrawBlock; +import uk.co.haxyshideout.chococraft2.entities.EntityChocobo.ChocoboColor; import uk.co.haxyshideout.chococraft2.items.ChocoboWhistleItem; import uk.co.haxyshideout.chococraft2.items.SpawnEggItem; import uk.co.haxyshideout.haxylib.items.GenericArmor; @@ -22,108 +26,93 @@ * Created by clienthax on 12/4/2015. Should contain every block and item that * is added from the mod. */ -@SuppressWarnings("unused") -public class Additions { - - public static Block gysahlStemBlock; - public static Block strawBlock; - - public static Item gysahlGreenItem; - public static Item gysahlSeedsItem; - public static Item gysahlGoldenItem; - public static Item gysahlLoverlyItem; - public static Item gysahlPinkItem; - public static Item gysahlRedItem; - public static Item gysahlRawPicklesItem; - public static Item gysahlCookedPicklesItem; - public static Item gysahlCakeItem; - public static Item gysahlChibiItem;// I have no idea what this is for. - aprantly makes it so baby's never grow up - - public static Item chocoboFeatherItem; - public static Item chocoboLegRawItem; - public static Item chocoboLegCookedItem; - public static Item chocopediaItem; - public static Item chocoboSaddleItem; - public static Item chocoboSaddleBagItem; - public static Item chocoboPackBagItem; - public static Item chocoboWhistleItem; - - public static Item purpleSpawnEggItem; - public static Item redSpawnEggItem; - public static Item blackSpawnEggItem; - public static Item greenSpawnEggItem; - public static Item yellowSpawnEggItem; - public static Item goldSpawnEggItem; - public static Item whiteSpawnEggItem; - public static Item blueSpawnEggItem; - public static Item pinkSpawnEggItem; - - public static Item chocoDisguiseHelm; - public static Item chocoDisguiseChest; - public static Item chocoDisguiseLegs; - public static Item chocoDisguiseBoots; - - public static final ArmorMaterial chocoDisguiseMaterial = EnumHelper.addArmorMaterial("chocoDisguise", Constants.MODID + ":chocoDisguise", 200, - new int[] {3, 7, 6, 3}, 10); - - // Register items and blocks etc in here - public static void registerAdditions() { - gysahlStemBlock = new GysahlStemBlock().setUnlocalizedName("gysahlStemBlock").setCreativeTab(ChocoCreativeTabs.chococraft2); - strawBlock = new StrawBlock().setUnlocalizedName("strawBlock").setCreativeTab(ChocoCreativeTabs.chococraft2); - - gysahlGreenItem = new GenericItem().setUnlocalizedName("gysahlGreenItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - gysahlSeedsItem = - new GenericItemSeeds(gysahlStemBlock, Blocks.farmland).setUnlocalizedName("gysahlSeedsItem").setCreativeTab( - ChocoCreativeTabs.chococraft2); - gysahlGoldenItem = new GenericItem().setUnlocalizedName("gysahlGoldenItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - gysahlLoverlyItem = new GenericItem().setUnlocalizedName("gysahlLoverlyItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - gysahlPinkItem = new GenericItem().setUnlocalizedName("gysahlPinkItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - gysahlRedItem = new GenericItem().setUnlocalizedName("gysahlRedItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - gysahlRawPicklesItem = new GenericItem().setUnlocalizedName("gysahlRawPicklesItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - gysahlCookedPicklesItem = - new GenericItemFood(2, false).setUnlocalizedName("gysahlCookedPicklesItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - gysahlCakeItem = new GenericItem().setUnlocalizedName("gysahlCakeItem").setMaxStackSize(8).setCreativeTab(ChocoCreativeTabs.chococraft2); - gysahlChibiItem = new GenericItem().setUnlocalizedName("gysahlChibiItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - - chocoboFeatherItem = new GenericItem().setUnlocalizedName("chocoboFeatherItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - chocoboLegRawItem = - new GenericItemFood(4, 0.3F, true).setPotionEffect(Potion.hunger.getId(), 30, 0, 0.3F).setUnlocalizedName("chocoboLegRawItem") - .setCreativeTab(ChocoCreativeTabs.chococraft2); - chocoboLegCookedItem = new GenericItemFood(8, true).setUnlocalizedName("chocoboLegCookedItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - chocopediaItem = new GenericItem().setUnlocalizedName("chocopediaItem").setMaxStackSize(1).setCreativeTab(ChocoCreativeTabs.chococraft2); - - purpleSpawnEggItem = new SpawnEggItem(ChocoboColor.PURPLE).setUnlocalizedName("purpleSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - redSpawnEggItem = new SpawnEggItem(ChocoboColor.RED).setUnlocalizedName("redSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - blackSpawnEggItem = new SpawnEggItem(ChocoboColor.BLACK).setUnlocalizedName("blackSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - greenSpawnEggItem = new SpawnEggItem(ChocoboColor.GREEN).setUnlocalizedName("greenSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - goldSpawnEggItem = new SpawnEggItem(ChocoboColor.GOLD).setUnlocalizedName("goldSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - blueSpawnEggItem = new SpawnEggItem(ChocoboColor.BLUE).setUnlocalizedName("blueSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - pinkSpawnEggItem = new SpawnEggItem(ChocoboColor.PINK).setUnlocalizedName("pinkSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - whiteSpawnEggItem = new SpawnEggItem(ChocoboColor.WHITE).setUnlocalizedName("whiteSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - yellowSpawnEggItem = new SpawnEggItem(ChocoboColor.YELLOW).setUnlocalizedName("yellowSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); - - chocoboSaddleItem = - new GenericItem().setUnlocalizedName("chocoboSaddleItem").setMaxStackSize(5).setCreativeTab(ChocoCreativeTabs.chococraft2); - chocoboSaddleBagItem = - new GenericItem().setUnlocalizedName("chocoboSaddleBagItem").setMaxStackSize(8).setCreativeTab(ChocoCreativeTabs.chococraft2); - chocoboPackBagItem = - new GenericItem().setUnlocalizedName("chocoboPackBagItem").setMaxStackSize(8).setCreativeTab(ChocoCreativeTabs.chococraft2); - chocoboWhistleItem = new ChocoboWhistleItem().setUnlocalizedName("chocoboWhistleItem").setMaxStackSize(1).setCreativeTab(ChocoCreativeTabs.chococraft2); - - chocoDisguiseHelm = - new GenericArmor(chocoDisguiseMaterial, 0, GenericArmor.ArmorType.Helm).setUnlocalizedName("chocoDisguiseHelm").setCreativeTab( - ChocoCreativeTabs.chococraft2); - chocoDisguiseChest = - new GenericArmor(chocoDisguiseMaterial, 0, GenericArmor.ArmorType.Plate).setUnlocalizedName("chocoDisguiseChest").setCreativeTab( - ChocoCreativeTabs.chococraft2); - chocoDisguiseLegs = - new GenericArmor(chocoDisguiseMaterial, 0, GenericArmor.ArmorType.Legs).setUnlocalizedName("chocoDisguiseLegs").setCreativeTab( - ChocoCreativeTabs.chococraft2); - chocoDisguiseBoots = - new GenericArmor(chocoDisguiseMaterial, 0, GenericArmor.ArmorType.Boots).setUnlocalizedName("chocoDisguiseBoots").setCreativeTab( - ChocoCreativeTabs.chococraft2); - - RegistryHelper.registerFieldsWithGameRegistry(Constants.MODID, Additions.class); - } +public class Additions +{ + + public static Block gysahlStemBlock; + public static Block strawBlock; + + public static Item gysahlGreenItem; + public static Item gysahlSeedsItem; + public static Item gysahlGoldenItem; + public static Item gysahlLoverlyItem; + public static Item gysahlPinkItem; + public static Item gysahlRedItem; + public static Item gysahlRawPicklesItem; + public static Item gysahlCookedPicklesItem; + public static Item gysahlCakeItem; + public static Item gysahlChibiItem;// I have no idea what this is for. - aprantly makes it so baby's never grow up + + public static Item chocoboFeatherItem; + public static Item chocoboLegRawItem; + public static Item chocoboLegCookedItem; + public static Item chocopediaItem; + public static Item chocoboSaddleItem; + public static Item chocoboSaddleBagItem; + public static Item chocoboPackBagItem; + public static Item chocoboWhistleItem; + + public static Item purpleSpawnEggItem; + public static Item redSpawnEggItem; + public static Item blackSpawnEggItem; + public static Item greenSpawnEggItem; + public static Item yellowSpawnEggItem; + public static Item goldSpawnEggItem; + public static Item whiteSpawnEggItem; + public static Item blueSpawnEggItem; + public static Item pinkSpawnEggItem; + + public static Item chocoDisguiseHelm; + public static Item chocoDisguiseChest; + public static Item chocoDisguiseLegs; + public static Item chocoDisguiseBoots; + + public static final ArmorMaterial chocoDisguiseMaterial = EnumHelper.addArmorMaterial("chocoDisguise", Constants.MODID + ":chocoDisguise", 200, new int[] { 3, 7, 6, 3 }, 10, SoundEvents.item_armor_equip_generic); + + // Register items and blocks etc in here + public static void registerAdditions() + { + gysahlStemBlock = new GysahlStemBlock().setUnlocalizedName("gysahlStemBlock").setCreativeTab(ChocoCreativeTabs.chococraft2); + strawBlock = new StrawBlock().setUnlocalizedName("strawBlock").setCreativeTab(ChocoCreativeTabs.chococraft2); + + gysahlGreenItem = new GenericItem().setUnlocalizedName("gysahlGreenItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + gysahlSeedsItem = new GenericItemSeeds(gysahlStemBlock, Blocks.farmland).setUnlocalizedName("gysahlSeedsItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + gysahlGoldenItem = new GenericItem().setUnlocalizedName("gysahlGoldenItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + gysahlLoverlyItem = new GenericItem().setUnlocalizedName("gysahlLoverlyItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + gysahlPinkItem = new GenericItem().setUnlocalizedName("gysahlPinkItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + gysahlRedItem = new GenericItem().setUnlocalizedName("gysahlRedItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + gysahlRawPicklesItem = new GenericItem().setUnlocalizedName("gysahlRawPicklesItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + gysahlCookedPicklesItem = new GenericItemFood(2, false).setUnlocalizedName("gysahlCookedPicklesItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + gysahlCakeItem = new GenericItem().setUnlocalizedName("gysahlCakeItem").setMaxStackSize(8).setCreativeTab(ChocoCreativeTabs.chococraft2); + gysahlChibiItem = new GenericItem().setUnlocalizedName("gysahlChibiItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + + chocoboFeatherItem = new GenericItem().setUnlocalizedName("chocoboFeatherItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + chocoboLegRawItem = new GenericItemFood(4, 0.3F, true).setPotionEffect(new PotionEffect(Potion.getPotionById(PotionType.getID(PotionTypes.poison)), 30, 0), 0.3F).setUnlocalizedName("chocoboLegRawItem") + .setCreativeTab(ChocoCreativeTabs.chococraft2); + chocoboLegCookedItem = new GenericItemFood(8, true).setUnlocalizedName("chocoboLegCookedItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + chocopediaItem = new GenericItem().setUnlocalizedName("chocopediaItem").setMaxStackSize(1).setCreativeTab(ChocoCreativeTabs.chococraft2); + + purpleSpawnEggItem = new SpawnEggItem(ChocoboColor.PURPLE).setUnlocalizedName("purpleSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + redSpawnEggItem = new SpawnEggItem(ChocoboColor.RED).setUnlocalizedName("redSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + blackSpawnEggItem = new SpawnEggItem(ChocoboColor.BLACK).setUnlocalizedName("blackSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + greenSpawnEggItem = new SpawnEggItem(ChocoboColor.GREEN).setUnlocalizedName("greenSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + goldSpawnEggItem = new SpawnEggItem(ChocoboColor.GOLD).setUnlocalizedName("goldSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + blueSpawnEggItem = new SpawnEggItem(ChocoboColor.BLUE).setUnlocalizedName("blueSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + pinkSpawnEggItem = new SpawnEggItem(ChocoboColor.PINK).setUnlocalizedName("pinkSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + whiteSpawnEggItem = new SpawnEggItem(ChocoboColor.WHITE).setUnlocalizedName("whiteSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + yellowSpawnEggItem = new SpawnEggItem(ChocoboColor.YELLOW).setUnlocalizedName("yellowSpawnEggItem").setCreativeTab(ChocoCreativeTabs.chococraft2); + + chocoboSaddleItem = new GenericItem().setUnlocalizedName("chocoboSaddleItem").setMaxStackSize(5).setCreativeTab(ChocoCreativeTabs.chococraft2); + chocoboSaddleBagItem = new GenericItem().setUnlocalizedName("chocoboSaddleBagItem").setMaxStackSize(8).setCreativeTab(ChocoCreativeTabs.chococraft2); + chocoboPackBagItem = new GenericItem().setUnlocalizedName("chocoboPackBagItem").setMaxStackSize(8).setCreativeTab(ChocoCreativeTabs.chococraft2); + chocoboWhistleItem = new ChocoboWhistleItem().setUnlocalizedName("chocoboWhistleItem").setMaxStackSize(1).setCreativeTab(ChocoCreativeTabs.chococraft2); + + chocoDisguiseHelm = new GenericArmor(chocoDisguiseMaterial, 0, EntityEquipmentSlot.HEAD).setUnlocalizedName("chocoDisguiseHelm").setCreativeTab(ChocoCreativeTabs.chococraft2); + chocoDisguiseChest = new GenericArmor(chocoDisguiseMaterial, 0, EntityEquipmentSlot.CHEST).setUnlocalizedName("chocoDisguiseChest").setCreativeTab(ChocoCreativeTabs.chococraft2); + chocoDisguiseLegs = new GenericArmor(chocoDisguiseMaterial, 0, EntityEquipmentSlot.LEGS).setUnlocalizedName("chocoDisguiseLegs").setCreativeTab(ChocoCreativeTabs.chococraft2); + chocoDisguiseBoots = new GenericArmor(chocoDisguiseMaterial, 0, EntityEquipmentSlot.FEET).setUnlocalizedName("chocoDisguiseBoots").setCreativeTab(ChocoCreativeTabs.chococraft2); + + RegistryHelper.registerFieldsWithGameRegistry(Constants.MODID, Additions.class); + } } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/config/ChococraftConfig.java b/src/main/java/uk/co/haxyshideout/chococraft2/config/ChococraftConfig.java index 3e3a975..b3dac43 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/config/ChococraftConfig.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/config/ChococraftConfig.java @@ -13,7 +13,10 @@ import com.google.common.io.Resources; import com.google.common.reflect.TypeToken; import lombok.Getter; +import net.minecraft.init.PotionTypes; +import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.PotionType; import net.minecraft.world.biome.BiomeGenBase; import ninja.leaping.configurate.ConfigurationOptions; import ninja.leaping.configurate.commented.CommentedConfigurationNode; @@ -124,8 +127,8 @@ private void loadConfigFile() { public List getSpawnBiomes() { List spawnBiomes = Lists.newArrayListWithCapacity(normalSpawnBiomeNames.size()); - for(BiomeGenBase biomeGenBase : BiomeGenBase.getBiomeGenArray()) { - if(biomeGenBase != null && normalSpawnBiomeNames.contains(biomeGenBase.biomeName)) { + for(BiomeGenBase biomeGenBase : BiomeGenBase.biomeRegistry) { + if(biomeGenBase != null && normalSpawnBiomeNames.contains(biomeGenBase.getBiomeName())) { spawnBiomes.add(biomeGenBase); } } @@ -143,7 +146,7 @@ private void loadAbilityInfo() loadAbilityForColout(new ChocoboAbilityInfo(GOLD).setSpeeds(50, 20, 55).setMaxHP(50).setStepHeight(2, 0.5f).setCanWalkOnWater(true).setCanClimb(true).setCanFly(true).setImmuneToFire(true), abilityNode.getNode("GOLD"));// TODO needs particles loadAbilityForColout(new ChocoboAbilityInfo(PINK).setSpeeds(55, 25, 60).setMaxHP(50).setStepHeight(2, 0.5f).setCanClimb(true).setCanWalkOnWater(true).setCanFly(true), abilityNode.getNode("PINK")); loadAbilityForColout(new ChocoboAbilityInfo(RED).setSpeeds(55, 25, 60).setMaxHP(50).setStepHeight(2, 0.5f).setCanClimb(true).setCanWalkOnWater(true).setCanFly(true), abilityNode.getNode("RED")); - loadAbilityForColout(new ChocoboAbilityInfo(PURPLE).setSpeeds(40, 10, 55).setMaxHP(50).setStepHeight(1, 0.5f).setCanClimb(true).setCanFly(true).setImmuneToFire(true).addRiderAbility(new PotionEffect(12, 100, -1, true, false)), abilityNode.getNode("PURPLE")); + loadAbilityForColout(new ChocoboAbilityInfo(PURPLE).setSpeeds(40, 10, 55).setMaxHP(50).setStepHeight(1, 0.5f).setCanClimb(true).setCanFly(true).setImmuneToFire(true).addRiderAbility(new PotionEffect(Potion.getPotionById(PotionType.getID(PotionTypes.fire_resistance)), 100, -1, true, false)), abilityNode.getNode("PURPLE")); } private void loadAbilityForColout(ChocoboAbilityInfo abilityInfo, CommentedConfigurationNode node) { diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/config/Constants.java b/src/main/java/uk/co/haxyshideout/chococraft2/config/Constants.java index b7927c9..b92451e 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/config/Constants.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/config/Constants.java @@ -1,18 +1,26 @@ package uk.co.haxyshideout.chococraft2.config; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.network.datasync.DataParameter; +import net.minecraft.network.datasync.DataSerializers; +import net.minecraft.network.datasync.EntityDataManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvent; + /** * Created by clienthax on 12/4/2015. */ -public class Constants { +public class Constants +{ public static final String MODID = "chococraft2"; public static final String MODNAME = "ChocoCraft2"; public static final String MODVERSION = "0.0.2"; - // for EntityTamable, 2-5, 13-15, 18-31 are usable - // http://www.minecraftforge.net/wiki/Datawatcher - public static final int dataWatcherVariant = 31; - public static final int dataWatcherBagType = 30; - public static final int dataWatcherSaddled = 29; - public static final int dataWatcherMale = 28; - public static final int dataWatcherFollowingOwner = 27; + public static final DataParameter dataWatcherVariant = EntityDataManager. createKey(EntityAgeable.class, DataSerializers.BYTE); + public static final DataParameter dataWatcherBagType = EntityDataManager. createKey(EntityAgeable.class, DataSerializers.BYTE); + public static final DataParameter dataWatcherSaddled = EntityDataManager. createKey(EntityAgeable.class, DataSerializers.BYTE); + public static final DataParameter dataWatcherMale = EntityDataManager. createKey(EntityAgeable.class, DataSerializers.BYTE); + public static final DataParameter dataWatcherFollowingOwner = EntityDataManager. createKey(EntityAgeable.class, DataSerializers.BYTE); + + public static final SoundEvent babyChocoboSound = new SoundEvent(new ResourceLocation("chococraft2:choco_kweh")); } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/EntityBabyChocobo.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/EntityBabyChocobo.java index 2254219..f73b4ec 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/EntityBabyChocobo.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/EntityBabyChocobo.java @@ -11,7 +11,11 @@ import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvent; import net.minecraft.world.World; import uk.co.haxyshideout.chococraft2.ChocoCraft2; import uk.co.haxyshideout.chococraft2.config.Additions; @@ -20,13 +24,13 @@ public class EntityBabyChocobo extends EntityAnimal { - private int ticksExisted; + private int ticksExisted; public EntityBabyChocobo(World worldIn) { super(worldIn); this.setSize(0.5f, 0.5f); - this.tasks.addTask(2, new EntityAIWander(this, this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue())); + this.tasks.addTask(2, new EntityAIWander(this, this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue())); this.tasks.addTask(3, new EntityAISwimming(this)); this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(5, new EntityAILookIdle(this)); @@ -36,17 +40,18 @@ public EntityBabyChocobo(World worldIn) @Override public void onLivingUpdate() - { - super.onLivingUpdate(); - this.ticksExisted++; - - if(this.ticksExisted >= ChocoCraft2.instance.getConfig().getTicksToAdult() && !this.worldObj.isRemote) - { - growUp(); - } - } - - private void growUp() { + { + super.onLivingUpdate(); + this.ticksExisted++; + + if (this.ticksExisted >= ChocoCraft2.instance.getConfig().getTicksToAdult() && !this.worldObj.isRemote) + { + growUp(); + } + } + + private void growUp() + { this.setDead(); EntityChocobo chocobo = new EntityChocobo(this.worldObj); chocobo.setColor(this.getChocoboColor()); @@ -55,15 +60,15 @@ private void growUp() { } @Override - public boolean interact(EntityPlayer player) + public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { if (worldObj.isRemote)// return if client return false; - if (player.getHeldItem() == null)// Make sure the player is holding something for the following checks + if (player.getHeldItem(hand) == null)// Make sure the player is holding something for the following checks return false; - if (player.getHeldItem().getItem() == Additions.gysahlCakeItem) + if (player.getHeldItem(hand).getItem() == Additions.gysahlCakeItem) { this.consumeItemFromStack(player, player.inventory.getCurrentItem()); growUp(); @@ -71,7 +76,7 @@ public boolean interact(EntityPlayer player) return true; } - + @Override public EntityAgeable createChild(EntityAgeable ageable) { @@ -80,9 +85,9 @@ public EntityAgeable createChild(EntityAgeable ageable) public void setColor(ChocoboColor color) { - dataWatcher.updateObject(Constants.dataWatcherVariant, (byte) color.ordinal()); + dataWatcher.set(Constants.dataWatcherVariant, (byte) color.ordinal()); } - + @Override public void writeEntityToNBT(NBTTagCompound tagCompound) { @@ -103,7 +108,7 @@ protected void entityInit() super.entityInit(); // corresponding to enum.ordinal - this.dataWatcher.addObject(Constants.dataWatcherVariant, (byte) 0); + this.dataWatcher.register(Constants.dataWatcherVariant, (byte) 0); } public boolean isTamed() @@ -118,26 +123,26 @@ public boolean isMale() public ChocoboColor getChocoboColor() { - return ChocoboColor.values()[dataWatcher.getWatchableObjectByte(Constants.dataWatcherVariant)]; + return ChocoboColor.values()[dataWatcher.get(Constants.dataWatcherVariant)]; } @Override - protected String getDeathSound() + protected SoundEvent getDeathSound() { - return "chococraft2:choco_kweh"; + return Constants.babyChocoboSound; } @Override - protected String getHurtSound() + protected SoundEvent getHurtSound() { - return "chococraft2:choco_kweh"; + return Constants.babyChocoboSound; } @Override - protected String getLivingSound() + protected SoundEvent getAmbientSound() { if (rand.nextInt(4) == 0) - return "chococraft2:choco_kweh"; + return Constants.babyChocoboSound; return null; } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/EntityChocobo.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/EntityChocobo.java index eb0a067..b0cb556 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/EntityChocobo.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/EntityChocobo.java @@ -1,11 +1,14 @@ package uk.co.haxyshideout.chococraft2.entities; +import javax.annotation.Nullable; + +import org.lwjgl.input.Keyboard; + import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.passive.EntityAnimal; @@ -19,13 +22,15 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.pathfinding.PathNavigateGround; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import net.minecraft.world.WorldServer; -import org.lwjgl.input.Keyboard; import uk.co.haxyshideout.chococraft2.ChocoCraft2; import uk.co.haxyshideout.chococraft2.config.Additions; import uk.co.haxyshideout.chococraft2.config.Constants; @@ -40,8 +45,6 @@ import uk.co.haxyshideout.haxylib.utils.RandomHelper; import uk.co.haxyshideout.haxylib.utils.WorldHelper; -import javax.annotation.Nullable; - /** * Created by clienthax on 14/4/2015. */ @@ -60,15 +63,7 @@ public class EntityChocobo extends EntityTameable implements IInvBasic public enum ChocoboColor { - YELLOW, - GREEN, - BLUE, - WHITE, - BLACK, - GOLD, - PINK, - RED, - PURPLE + YELLOW, GREEN, BLUE, WHITE, BLACK, GOLD, PINK, RED, PURPLE } public enum BagType @@ -89,7 +84,7 @@ public EntityChocobo(World world) setCustomNameTag(DefaultNames.getRandomName(isMale())); resetFeatherDropTime(); riderState = new RiderState(); - ((PathNavigateGround) this.getNavigator()).setAvoidsWater(true); + ((PathNavigateGround) this.getNavigator()).setCanSwim(false); this.tasks.addTask(1, new EntityAIWander(this, 1.0D)); this.tasks.addTask(1, new ChocoboAIFollowOwner(this, 1.0D, 5.0F, 5.0F));// follow speed 1, min and max 5 this.tasks.addTask(1, new ChocoboAIFollowLure(this, 1.0D, 5.0F, 5.0F)); @@ -97,7 +92,6 @@ public EntityChocobo(World world) this.tasks.addTask(2, new ChocoboAIMate(this, 1.0D)); this.tasks.addTask(1, new EntityAISwimming(this)); - initChest(); // Default init @@ -112,11 +106,8 @@ public EntityChocobo(World world) this.isImmuneToFire = getAbilityInfo().isImmuneToFire(); } - @Override public void mountEntity(Entity entityIn) { - super.mountEntity(entityIn); - if (this.worldObj.isRemote) { if (Minecraft.getMinecraft().thePlayer.getUniqueID().equals(entityIn.getUniqueID())) @@ -128,10 +119,10 @@ public void mountEntity(Entity entityIn) public void setStats() { - getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.getAbilityInfo().getMaxHP());// set max health + getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(this.getAbilityInfo().getMaxHP());// set max health setHealth(getMaxHealth());// reset the hp to max onGroundSpeedFactor = this.getAbilityInfo().getLandSpeed() / 100f; - this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.movementSpeed).setBaseValue(onGroundSpeedFactor); + this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(onGroundSpeedFactor); } public RiderState getRiderState() @@ -143,21 +134,22 @@ public RiderState getRiderState() public void moveEntityWithHeading(float strafe, float forward) { // TODO some point in future, move this to its own ai class - if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityLivingBase) + if (this.getControllingPassenger() != null && this.getControllingPassenger() instanceof EntityLivingBase) { - this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw; - this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F; + this.prevRotationYaw = this.rotationYaw = this.getControllingPassenger().rotationYaw; + this.rotationPitch = this.getControllingPassenger().rotationPitch * 0.5F; this.setRotation(this.rotationYaw, this.rotationPitch); this.rotationYawHead = this.renderYawOffset = this.rotationYaw; - strafe = ((EntityLivingBase) this.riddenByEntity).moveStrafing * 0.5F; - forward = ((EntityLivingBase) this.riddenByEntity).moveForward; + strafe = ((EntityLivingBase) this.getControllingPassenger()).moveStrafing * 0.5F; + forward = ((EntityLivingBase) this.getControllingPassenger()).moveForward; if (forward <= 0.0F) { forward *= 0.25F; } - if(isInWater() && this.getAbilityInfo().canWalkOnWater()) { + if (isInWater() && this.getAbilityInfo().canWalkOnWater()) + { motionY = 0.4d; moveFlying(strafe, forward, 100 / getAbilityInfo().getWaterSpeed()); setJumping(true); @@ -177,7 +169,7 @@ else if (this.riderState.isJumping() && !this.isJumping && this.onGround) } if (!this.worldObj.isRemote) { - this.setAIMoveSpeed((float) this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); + this.setAIMoveSpeed((float) this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue()); super.moveEntityWithHeading(strafe, forward); } @@ -193,7 +185,9 @@ else if (this.riderState.isJumping() && !this.isJumping && this.onGround) this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F; this.limbSwing += this.limbSwingAmount; - } else { + } + else + { super.moveEntityWithHeading(strafe, forward); } } @@ -224,7 +218,8 @@ public void setupTamedAI() } @Override - public boolean isBreedingItem(ItemStack itemStack) { + public boolean isBreedingItem(ItemStack itemStack) + { return itemStack.getItem() == Additions.gysahlLoverlyItem || itemStack.getItem() == Additions.gysahlGoldenItem; } @@ -233,7 +228,7 @@ public void onLivingUpdate() { super.onLivingUpdate(); - if (this.getAbilityInfo().canClimb() || this.riddenByEntity != null) + if (this.getAbilityInfo().canClimb() || this.getControllingPassenger() != null) { this.stepHeight = 1.0F; } @@ -244,14 +239,14 @@ public void onLivingUpdate() if (worldObj.isRemote) { // Client side - if (riddenByEntity != null && riddenByEntity instanceof EntityPlayer) + if (this.getControllingPassenger() != null && this.getControllingPassenger() instanceof EntityPlayer) { - if (Minecraft.getMinecraft().thePlayer.getUniqueID().equals(riddenByEntity.getUniqueID()) && Keyboard.isKeyDown(Keyboard.KEY_SPACE)) + if (Minecraft.getMinecraft().thePlayer.getUniqueID().equals(this.getControllingPassenger().getUniqueID()) && Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { this.riderState.setJumping(true); } - - ChocoCraft2.proxy.updateRiderState((EntityPlayer) riddenByEntity); + + ChocoCraft2.proxy.updateRiderState((EntityPlayer) this.getControllingPassenger()); } this.destPos += (double) (this.onGround ? -1 : 4) * 0.3D; @@ -281,12 +276,12 @@ public void onLivingUpdate() resetFeatherDropTime(); } - if (riddenByEntity != null) + if (this.getControllingPassenger() != null) { // TODO is this needed? rotationPitch = 0; - rotationYaw = riddenByEntity.rotationYaw; - prevRotationYaw = riddenByEntity.rotationYaw; + rotationYaw = this.getControllingPassenger().rotationYaw; + prevRotationYaw = this.getControllingPassenger().rotationYaw; setRotation(rotationYaw, rotationPitch); } @@ -366,67 +361,67 @@ protected void entityInit() { super.entityInit(); // corresponding to enum.ordinal - this.dataWatcher.addObject(Constants.dataWatcherVariant, (byte) 0); + this.dataWatcher.register(Constants.dataWatcherVariant, (byte) 0); // 0 for no bag, 1 for saddlebag, 2 for pack bag - this.dataWatcher.addObject(Constants.dataWatcherBagType, (byte) 0); + this.dataWatcher.register(Constants.dataWatcherBagType, (byte) 0); // 1 if saddled, 0 if not - this.dataWatcher.addObject(Constants.dataWatcherSaddled, (byte) 0); + this.dataWatcher.register(Constants.dataWatcherSaddled, (byte) 0); // 1 if male, 0 if not - this.dataWatcher.addObject(Constants.dataWatcherMale, (byte) 0); + this.dataWatcher.register(Constants.dataWatcherMale, (byte) 0); // 0 if wandering, 1 if following owner, 2 staying still - this.dataWatcher.addObject(Constants.dataWatcherFollowingOwner, (byte) 0); + this.dataWatcher.register(Constants.dataWatcherFollowingOwner, (byte) 0); } public void setColor(ChocoboColor color) { - dataWatcher.updateObject(Constants.dataWatcherVariant, (byte) color.ordinal()); + dataWatcher.set(Constants.dataWatcherVariant, (byte) color.ordinal()); setStats(); } public ChocoboColor getChocoboColor() { - return ChocoboColor.values()[dataWatcher.getWatchableObjectByte(Constants.dataWatcherVariant)]; + return ChocoboColor.values()[dataWatcher.get(Constants.dataWatcherVariant)]; } public void setBag(BagType bag) { - dataWatcher.updateObject(Constants.dataWatcherBagType, (byte) bag.ordinal()); + dataWatcher.set(Constants.dataWatcherBagType, (byte) bag.ordinal()); initChest(); } public BagType getBagType() { - return BagType.values()[dataWatcher.getWatchableObjectByte(Constants.dataWatcherBagType)]; + return BagType.values()[dataWatcher.get(Constants.dataWatcherBagType)]; } public void setSaddled(boolean saddled) { - dataWatcher.updateObject(Constants.dataWatcherSaddled, (byte) (saddled ? 1 : 0)); + dataWatcher.set(Constants.dataWatcherSaddled, (byte) (saddled ? 1 : 0)); } public boolean isSaddled() { - return dataWatcher.getWatchableObjectByte(Constants.dataWatcherSaddled) == 1; + return dataWatcher.get(Constants.dataWatcherSaddled) == 1; } public void setMale(boolean isMale) { - dataWatcher.updateObject(Constants.dataWatcherMale, (byte) (isMale ? 1 : 0)); + dataWatcher.set(Constants.dataWatcherMale, (byte) (isMale ? 1 : 0)); } public boolean isMale() { - return dataWatcher.getWatchableObjectByte(Constants.dataWatcherMale) == 1; + return dataWatcher.get(Constants.dataWatcherMale) == 1; } public void setMovementType(MovementType movementType) { - dataWatcher.updateObject(Constants.dataWatcherFollowingOwner, (byte) movementType.ordinal()); + dataWatcher.set(Constants.dataWatcherFollowingOwner, (byte) movementType.ordinal()); } public MovementType getMovementType() { - return MovementType.values()[dataWatcher.getWatchableObjectByte(Constants.dataWatcherFollowingOwner)]; + return MovementType.values()[dataWatcher.get(Constants.dataWatcherFollowingOwner)]; } /* @@ -438,29 +433,29 @@ public EntityAgeable createChild(EntityAgeable otherParent) { EntityBabyChocobo entity = new EntityBabyChocobo(otherParent.worldObj); entity.setColor(Breeding.getColour(this, (EntityChocobo) otherParent)); - //Reset golden status + // Reset golden status this.fedGoldenGyshal = false; ((EntityChocobo) otherParent).fedGoldenGyshal = false; return entity; } @Override - protected String getDeathSound() + protected SoundEvent getDeathSound() { - return "chococraft2:choco_kweh"; + return new SoundEvent(new ResourceLocation("chococraft2:choco_kweh")); } @Override - protected String getHurtSound() + protected SoundEvent getHurtSound() { - return "chococraft2:choco_kweh"; + return new SoundEvent(new ResourceLocation("chococraft2:choco_kweh")); } @Override - protected String getLivingSound() + protected SoundEvent getAmbientSound() { if (rand.nextInt(4) == 0) - return "chococraft2:choco_kweh"; + return new SoundEvent(new ResourceLocation("chococraft2:choco_kweh")); return null; } @@ -499,14 +494,16 @@ public int getTalkInterval() @Override public boolean getAlwaysRenderNameTagForRender() { - return (isTamed() && riddenByEntity == null); + return (isTamed() && this.getControllingPassenger() == null); } @Override - public boolean interact(EntityPlayer player) + public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { - if (!worldObj.isRemote) { - if (player.getHeldItem() != null && player.getHeldItem().getItem() == Additions.chocopediaItem && isTamed() && getOwner() == player) { + if (!worldObj.isRemote) + { + if (player.getHeldItem(hand) != null && player.getHeldItem(hand).getItem() == Additions.chocopediaItem && isTamed() && getOwner() == player) + { ChocoCraft2.proxy.openChocopedia(this); return true; } @@ -515,9 +512,10 @@ public boolean interact(EntityPlayer player) if (worldObj.isRemote)// return if client return false; - if (player.getHeldItem() == null && isSaddled() && !player.isSneaking()) + if (player.getHeldItem(hand) == null && isSaddled() && !player.isSneaking()) {// If the player is not holding anything and the chocobo is saddled, mount the chocobo - player.mountEntity(this); + player.startRiding(this); + this.mountEntity(player); return true; } @@ -526,28 +524,33 @@ public boolean interact(EntityPlayer player) player.displayGUIChest(chocoboChest); } - if (player.getHeldItem() == null)// Make sure the player is holding something for the following checks + if (player.getHeldItem(hand) == null)// Make sure the player is holding something for the following checks return false; - if (player.getHeldItem().getItem() == Additions.gysahlGreenItem) + if (player.getHeldItem(hand).getItem() == Additions.gysahlGreenItem) {// random chance of taming + random healing amount - if (!isTamed()) { + if (!isTamed()) + { this.consumeItemFromStack(player, player.inventory.getCurrentItem()); - player.addChatComponentMessage(new ChatComponentText("You attempt to tame the wild Chocobo")); - if(RandomHelper.getChanceResult(10)) {//Successfull tame - setOwnerId(player.getUniqueID().toString()); + player.addChatComponentMessage(new TextComponentString("You attempt to tame the wild Chocobo")); + if (RandomHelper.getChanceResult(10)) + {// Successfull tame + setOwnerId(player.getUniqueID()); setTamed(true); InventoryHelper.giveIfMissing(new ItemStack(Additions.chocopediaItem), (EntityPlayerMP) player); - player.addChatComponentMessage(new ChatComponentText("You tamed the Chocobo!")); + player.addChatComponentMessage(new TextComponentString("You tamed the Chocobo!")); } } else if (isTamed()) { - if(getHealth() != getMaxHealth()) { + if (getHealth() != getMaxHealth()) + { this.consumeItemFromStack(player, player.inventory.getCurrentItem()); heal(RandomHelper.getRandomInt(5)); - } else { - player.addChatComponentMessage(new ChatComponentText("This Chocobo is already at full health!")); + } + else + { + player.addChatComponentMessage(new TextComponentString("This Chocobo is already at full health!")); } } return true; @@ -556,7 +559,7 @@ else if (isTamed()) /* * Follow the player who clicked the entity if not tamed, if the chocobo is tamed, verify this is the owner, and then follow, if the entity is already following the player, stop following them. */ - if (player.getHeldItem().getItem() == Additions.chocoboFeatherItem) + if (player.getHeldItem(hand).getItem() == Additions.chocoboFeatherItem) { if (getMovementType() == MovementType.FOLLOW_LURE && entityLuring != null && entityLuring == player) { @@ -575,54 +578,58 @@ else if (isTamed()) if (!isTamed() || getOwner() != player)// Return if the chocobo is not tamed, as the following require that the chocobo is tamed. and that they are being used by the owner return false; - if (player.getHeldItem().getItem() == Additions.gysahlGoldenItem) + if (player.getHeldItem(hand).getItem() == Additions.gysahlGoldenItem) { this.consumeItemFromStack(player, player.inventory.getCurrentItem()); this.fedGoldenGyshal = true; this.setInLove(player); - } else if(player.getHeldItem().getItem() == Additions.gysahlLoverlyItem) + } + else if (player.getHeldItem(hand).getItem() == Additions.gysahlLoverlyItem) { this.consumeItemFromStack(player, player.inventory.getCurrentItem()); this.setInLove(player); } - if (player.getHeldItem().getItem() == Additions.chocoboSaddleItem && !isSaddled()) + if (player.getHeldItem(hand).getItem() == Additions.chocoboSaddleItem && !isSaddled()) { this.consumeItemFromStack(player, player.inventory.getCurrentItem()); // if the player is holding a saddle and the chocobo is not saddled, saddle the chocobo - player.addChatComponentMessage(new ChatComponentText("You put saddle on Chocobo"));//TODO lang + player.addChatComponentMessage(new TextComponentString("You put saddle on Chocobo"));// TODO lang setSaddled(true); return true; } - if (player.getHeldItem().getItem() == Additions.chocoboSaddleBagItem && getBagType() == BagType.NONE && isSaddled()) + if (player.getHeldItem(hand).getItem() == Additions.chocoboSaddleBagItem && getBagType() == BagType.NONE && isSaddled()) {// holding a saddle bag and no bag on chocobo, chocobo needs to be saddled this.consumeItemFromStack(player, player.inventory.getCurrentItem()); setBag(BagType.SADDLE); return true; } - if (player.getHeldItem().getItem() == Additions.chocoboPackBagItem && getBagType() == BagType.NONE) + if (player.getHeldItem(hand).getItem() == Additions.chocoboPackBagItem && getBagType() == BagType.NONE) {// holding a pack bag and no bag on chocobo, remove the saddle if the chocobo is saddled this.consumeItemFromStack(player, player.inventory.getCurrentItem()); setBag(BagType.PACK); return true; } - if(getChocoboColor() == ChocoboColor.GOLD && player.getHeldItem().getItem() == Additions.gysahlRedItem) { + if (getChocoboColor() == ChocoboColor.GOLD && player.getHeldItem(hand).getItem() == Additions.gysahlRedItem) + { this.consumeItemFromStack(player, player.inventory.getCurrentItem()); setColor(ChocoboColor.RED); } - if(getChocoboColor() == ChocoboColor.GOLD && player.getHeldItem().getItem() == Additions.gysahlPinkItem) { + if (getChocoboColor() == ChocoboColor.GOLD && player.getHeldItem(hand).getItem() == Additions.gysahlPinkItem) + { this.consumeItemFromStack(player, player.inventory.getCurrentItem()); setColor(ChocoboColor.PINK); } - if(player.getHeldItem().getItem() == Additions.chocoboWhistleItem) { + if (player.getHeldItem(hand).getItem() == Additions.chocoboWhistleItem) + { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setString("LinkedChocoboUUID", this.getUniqueID().toString()); - player.getHeldItem().setTagCompound(tagCompound); - player.getHeldItem().setStackDisplayName(this.getCommandSenderName()+"'s Whistle"); - player.addChatComponentMessage(new ChatComponentText("You linked the whistle to "+this.getCommandSenderName())); + player.getHeldItem(hand).setTagCompound(tagCompound); + player.getHeldItem(hand).setStackDisplayName(this.getName() + "'s Whistle"); + player.addChatComponentMessage(new TextComponentString("You linked the whistle to " + this.getName())); } return false; @@ -630,10 +637,8 @@ else if (isTamed()) @Override public boolean canMateWith(EntityAnimal otherAnimal) - {//Check that its a chocobo and that its the right sex - return otherAnimal != this && (otherAnimal.getClass() == this.getClass() && - this.isInLove() && otherAnimal.isInLove() && ((EntityChocobo)otherAnimal).isMale() != this.isMale() - ); + {// Check that its a chocobo and that its the right sex + return otherAnimal != this && (otherAnimal.getClass() == this.getClass() && this.isInLove() && otherAnimal.isInLove() && ((EntityChocobo) otherAnimal).isMale() != this.isMale()); } @Override @@ -650,7 +655,7 @@ public EntityPlayerMP getEntityLuring() @Override protected boolean isMovementBlocked() { - return getMovementType() == MovementType.STANDSTILL && riddenByEntity == null; + return getMovementType() == MovementType.STANDSTILL && this.getControllingPassenger() == null; } @Override @@ -663,7 +668,6 @@ public void onDeath(DamageSource cause) } // Inv stuff - public void initChest() { AnimalChest animalChest = chocoboChest; @@ -672,7 +676,7 @@ public void initChest() if (animalChest != null) { - animalChest.func_110132_b(this); + animalChest.removeInventoryChangeListener(this); int i = Math.min(animalChest.getSizeInventory(), this.chocoboChest.getSizeInventory()); for (int j = 0; j < i; ++j) { @@ -683,7 +687,7 @@ public void initChest() } } } - this.chocoboChest.func_110134_a(this); + this.chocoboChest.addInventoryChangeListener(this); } public int getChestSize() diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIAvoidPlayer.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIAvoidPlayer.java index 939942e..4f6c0f1 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIAvoidPlayer.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIAvoidPlayer.java @@ -1,8 +1,10 @@ package uk.co.haxyshideout.chococraft2.entities.ai; +import java.util.List; + import com.google.common.base.Predicate; import com.google.common.base.Predicates; -import net.minecraft.command.IEntitySelector; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.ai.EntityAIBase; @@ -11,13 +13,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathNavigate; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; +import net.minecraft.util.EntitySelectors; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import uk.co.haxyshideout.haxylib.items.GenericArmor; import uk.co.haxyshideout.haxylib.utils.RandomHelper; -import java.util.List; - /** * Created by clienthax on 20/5/2015. */ @@ -94,7 +95,7 @@ public boolean shouldExecute() if(theEntity.worldObj.getWorldTime() % 10 != 0) return false; - List list = this.theEntity.worldObj.getEntitiesInAABBexcluding(this.theEntity, this.theEntity.getEntityBoundingBox().expand((double)this.avoidDistance, 3.0D, (double)this.avoidDistance), Predicates.and(IEntitySelector.NOT_SPECTATING, this.canBeSeenSelector, this.avoidTargetSelector)); + List list = this.theEntity.worldObj.getEntitiesInAABBexcluding(this.theEntity, this.theEntity.getEntityBoundingBox().expand((double)this.avoidDistance, 3.0D, (double)this.avoidDistance), Predicates.and(EntitySelectors.NOT_SPECTATING, this.canBeSeenSelector, this.avoidTargetSelector)); if (list.isEmpty()) { @@ -103,7 +104,7 @@ public boolean shouldExecute() else { this.closestLivingEntity = (Entity)list.get(0); - Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, new Vec3(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ)); + Vec3d vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, new Vec3d(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ)); if (vec3 == null) { diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIFollowLure.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIFollowLure.java index 1956ae8..13ede70 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIFollowLure.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIFollowLure.java @@ -5,8 +5,9 @@ import net.minecraft.entity.passive.EntityTameable; import net.minecraft.pathfinding.PathNavigate; import net.minecraft.pathfinding.PathNavigateGround; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import uk.co.haxyshideout.chococraft2.entities.EntityChocobo; @@ -81,7 +82,7 @@ public boolean continueExecuting() public void startExecuting() { this.field_75343_h = 0; - ((PathNavigateGround)this.chocobo.getNavigator()).setAvoidsWater(false); + ((PathNavigateGround)this.chocobo.getNavigator()).setCanSwim(true); } /** @@ -92,7 +93,7 @@ public void resetTask() { this.theOwner = null; this.petPathfinder.clearPathEntity(); - ((PathNavigateGround)this.chocobo.getNavigator()).setAvoidsWater(true); + ((PathNavigateGround)this.chocobo.getNavigator()).setCanSwim(false); } /** @@ -123,7 +124,7 @@ public void updateTask() { for (int i1 = 0; i1 <= 4; ++i1) { - if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(this.theWorld, new BlockPos(i + l, k - 1, j + i1)) && !this.theWorld.getBlockState(new BlockPos(i + l, k, j + i1)).getBlock().isFullCube() && !this.theWorld.getBlockState(new BlockPos(i + l, k + 1, j + i1)).getBlock().isFullCube()) + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.isSideSolid(new BlockPos(i + l, k - 1, j + i1), EnumFacing.UP) && !this.theWorld.getBlockState(new BlockPos(i + l, k, j + i1)).getBlock().isFullCube(this.theWorld.getBlockState(new BlockPos(i + l, k, j + i1))) && !this.theWorld.getBlockState(new BlockPos(i + l, k + 1, j + i1)).getBlock().isFullCube(this.theWorld.getBlockState(new BlockPos(i + l, k + 1, j + i1)))) { this.chocobo.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.chocobo.rotationYaw, this.chocobo.rotationPitch); this.petPathfinder.clearPathEntity(); diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIFollowOwner.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIFollowOwner.java index 84945e3..ddab9d6 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIFollowOwner.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIFollowOwner.java @@ -5,8 +5,9 @@ import net.minecraft.entity.passive.EntityTameable; import net.minecraft.pathfinding.PathNavigate; import net.minecraft.pathfinding.PathNavigateGround; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import uk.co.haxyshideout.chococraft2.entities.EntityChocobo; @@ -43,7 +44,7 @@ public ChocoboAIFollowOwner(EntityTameable thePetIn, double followSpeedIn, float @Override public boolean shouldExecute() { - EntityLivingBase owner = this.chocobo.getOwnerEntity(); + EntityLivingBase owner = this.chocobo.getOwner(); if (owner == null) { @@ -80,7 +81,7 @@ public boolean continueExecuting() public void startExecuting() { this.field_75343_h = 0; - ((PathNavigateGround)this.chocobo.getNavigator()).setAvoidsWater(false); + ((PathNavigateGround)this.chocobo.getNavigator()).setCanSwim(true); } /** @@ -91,7 +92,7 @@ public void resetTask() { this.theOwner = null; this.petPathfinder.clearPathEntity(); - ((PathNavigateGround)this.chocobo.getNavigator()).setAvoidsWater(true); + ((PathNavigateGround)this.chocobo.getNavigator()).setCanSwim(false); } /** @@ -122,7 +123,7 @@ public void updateTask() { for (int i1 = 0; i1 <= 4; ++i1) { - if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(this.theWorld, new BlockPos(i + l, k - 1, j + i1)) && !this.theWorld.getBlockState(new BlockPos(i + l, k, j + i1)).getBlock().isFullCube() && !this.theWorld.getBlockState(new BlockPos(i + l, k + 1, j + i1)).getBlock().isFullCube()) + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.isSideSolid(new BlockPos(i + l, k - 1, j + i1), EnumFacing.UP) && !this.theWorld.getBlockState(new BlockPos(i + l, k, j + i1)).getBlock().isFullCube(this.theWorld.getBlockState(new BlockPos(i + l, k, j + i1))) && !this.theWorld.getBlockState(new BlockPos(i + l, k + 1, j + i1)).getBlock().isFullCube(this.theWorld.getBlockState(new BlockPos(i + l, k + 1, j + i1)))) { this.chocobo.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.chocobo.rotationYaw, this.chocobo.rotationPitch); this.petPathfinder.clearPathEntity(); diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIMate.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIMate.java index 96ea5d0..3014345 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIMate.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIMate.java @@ -137,7 +137,7 @@ private void spawnBaby() if (entityplayer != null) { - entityplayer.triggerAchievement(StatList.animalsBredStat); + entityplayer.addStat(StatList.animalsBred); } this.theAnimal.setGrowingAge(6000); @@ -157,7 +157,7 @@ private void spawnBaby() this.theWorld.spawnParticle(EnumParticleTypes.HEART, this.theAnimal.posX + (double)(random.nextFloat() * this.theAnimal.width * 2.0F) - (double)this.theAnimal.width, this.theAnimal.posY + 0.5D + (double)(random.nextFloat() * this.theAnimal.height), this.theAnimal.posZ + (double)(random.nextFloat() * this.theAnimal.width * 2.0F) - (double)this.theAnimal.width, d0, d1, d2); } - if (this.theWorld.getGameRules().getGameRuleBooleanValue("doMobLoot")) + if (this.theWorld.getGameRules().getBoolean("doMobLoot")) { this.theWorld.spawnEntityInWorld(new EntityXPOrb(this.theWorld, this.theAnimal.posX, this.theAnimal.posY, this.theAnimal.posZ, random.nextInt(7) + 1)); } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIWatchPlayer.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIWatchPlayer.java index 469b37c..40eacab 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIWatchPlayer.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/ai/ChocoboAIWatchPlayer.java @@ -13,9 +13,9 @@ public class ChocoboAIWatchPlayer extends EntityAIBase protected Entity closestEntity; private float watchDistance; private int lookTime; - private Class watchedClass; + private Class watchedClass; - public ChocoboAIWatchPlayer(EntityLiving chocobo, Class entityClass, float distance) + public ChocoboAIWatchPlayer(EntityLiving chocobo, Class entityClass, float distance) { this.theWatcher = chocobo; this.watchedClass = entityClass; @@ -60,7 +60,7 @@ public boolean shouldExecute() @Override public boolean continueExecuting() { - return this.closestEntity.isEntityAlive() && theWatcher.riddenByEntity == null && (this.theWatcher.getDistanceSqToEntity(this.closestEntity) <= (double) (this.watchDistance * this.watchDistance) && this.lookTime > 0); + return this.closestEntity.isEntityAlive() && theWatcher.getControllingPassenger() == null && (this.theWatcher.getDistanceSqToEntity(this.closestEntity) <= (double) (this.watchDistance * this.watchDistance) && this.lookTime > 0); } /** diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/models/ModelBabyChocobo.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/models/ModelBabyChocobo.java index 0bb7439..088da80 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/models/ModelBabyChocobo.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/models/ModelBabyChocobo.java @@ -3,7 +3,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class ModelBabyChocobo extends ModelBase { diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/models/ModelChocobo.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/models/ModelChocobo.java index 40b4089..c8ede23 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/models/ModelChocobo.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/models/ModelChocobo.java @@ -3,7 +3,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; /** * Created by clienthax on 14/4/2015. diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/entities/renderer/ChocoboRenderer.java b/src/main/java/uk/co/haxyshideout/chococraft2/entities/renderer/ChocoboRenderer.java index f3b50de..ea79b57 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/entities/renderer/ChocoboRenderer.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/entities/renderer/ChocoboRenderer.java @@ -6,8 +6,8 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.MathHelper; import uk.co.haxyshideout.chococraft2.config.Constants; import uk.co.haxyshideout.chococraft2.entities.EntityChocobo; diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/events/EventHandler.java b/src/main/java/uk/co/haxyshideout/chococraft2/events/EventHandler.java index c456e4b..c4deb32 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/events/EventHandler.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/events/EventHandler.java @@ -1,18 +1,27 @@ package uk.co.haxyshideout.chococraft2.events; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import org.apache.commons.io.IOUtils; + import com.google.common.io.CharSource; +import com.mojang.realmsclient.gui.ChatFormatting; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreenBook; -import net.minecraft.event.ClickEvent; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.event.entity.player.BonemealEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -24,40 +33,41 @@ import net.minecraftforge.fml.relauncher.SideOnly; import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.hocon.HoconConfigurationLoader; -import org.apache.commons.io.IOUtils; import uk.co.haxyshideout.chococraft2.ChocoCraft2; import uk.co.haxyshideout.chococraft2.blocks.GysahlStemBlock; import uk.co.haxyshideout.chococraft2.config.Additions; import uk.co.haxyshideout.chococraft2.config.Constants; import uk.co.haxyshideout.haxylib.utils.FormattingHelper; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - /** * Created by clienthax on 13/4/2015. */ -public class EventHandler { +public class EventHandler +{ @SubscribeEvent @SideOnly(Side.CLIENT) - public void onConnect(PlayerEvent.PlayerLoggedInEvent event) { + public void onConnect(PlayerEvent.PlayerLoggedInEvent event) + { ForgeVersion.CheckResult checkResult = ForgeVersion.getResult(FMLCommonHandler.instance().findContainerFor(ChocoCraft2.instance)); - if (checkResult.status == ForgeVersion.Status.OUTDATED) { + if (checkResult.status == ForgeVersion.Status.OUTDATED) + { ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, checkResult.url); - ChatStyle clickableChatStyle = new ChatStyle().setChatClickEvent(clickEvent); - event.player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD+"Chococraft 2 Update available!, Click here to open website").setChatStyle(clickableChatStyle)); - event.player.addChatMessage(new ChatComponentText(checkResult.changes.get(checkResult.target)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA))); + Style clickableChatStyle = new Style().setChatClickEvent(clickEvent); + event.player.addChatMessage(new TextComponentString(ChatFormatting.GOLD + "Chococraft 2 Update available!, Click here to open website").setChatStyle(clickableChatStyle)); + event.player.addChatMessage(new TextComponentString(checkResult.changes.get(checkResult.target)).setChatStyle(new Style().setColor(TextFormatting.AQUA))); } } @SubscribeEvent @SideOnly(Side.CLIENT) - public void onRightClickChocopedia(PlayerInteractEvent event) throws IOException {//TODO this is a terrible way to do this - if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) { - if(event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() == Additions.chocopediaItem) { + public void onRightClickChocopedia(PlayerInteractEvent event) throws IOException + { + // TODO will prob explode + if (event instanceof PlayerInteractEvent.RightClickEmpty) + { + if (event.getEntityPlayer().getHeldItem(event.getHand()) != null && event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Additions.chocopediaItem) + { ItemStack book = new ItemStack(Items.written_book); NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setString("title", "Chocopedia"); @@ -67,9 +77,12 @@ public void onRightClickChocopedia(PlayerInteractEvent event) throws IOException String languageCode = Minecraft.getMinecraft().gameSettings.language; InputStream inputStream; - try { - inputStream = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(Constants.MODID, "lang/chocopedia/" + languageCode +".hocon")).getInputStream(); - } catch (FileNotFoundException e) { + try + { + inputStream = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(Constants.MODID, "lang/chocopedia/" + languageCode + ".hocon")).getInputStream(); + } + catch (FileNotFoundException e) + { inputStream = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(Constants.MODID, "lang/chocopedia/en_US.hocon")).getInputStream(); } @@ -78,33 +91,37 @@ public void onRightClickChocopedia(PlayerInteractEvent event) throws IOException ConfigurationNode configurationLoader = HoconConfigurationLoader.builder().setSource(CharSource.wrap(new String(data))).build().load(); List pages = configurationLoader.getNode("pages").getChildrenList(); - for(ConfigurationNode node : pages) { + for (ConfigurationNode node : pages) + { String pageText = ""; List lines = node.getChildrenList(); - for(ConfigurationNode line : lines) + for (ConfigurationNode line : lines) pageText += line.getString(); pageList.appendTag(new NBTTagString(FormattingHelper.convertFormattingCodes(pageText))); } tagCompound.setTag("pages", pageList); book.setTagCompound(tagCompound); - Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(event.entityPlayer, book, false)); + Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(event.getEntityPlayer(), book, false)); event.setCanceled(true); } } } @SubscribeEvent - public void onBoneMealUse(BonemealEvent event) { - if(event.block.getBlock() != Additions.gysahlStemBlock) + public void onBoneMealUse(BonemealEvent event) + { + if (event.getBlock().getBlock() != Additions.gysahlStemBlock) return; - //This tells forge we have processed the event + // This tells forge we have processed the event event.setResult(Event.Result.ALLOW); - //If the stage is below max, then set the growth to max stage, if its already fully grown, cancel the event (prevent the player from losing bonemeal) - if((Integer) event.block.getValue(GysahlStemBlock.STAGE) < GysahlStemBlock.MAXSTAGE) { - ((GysahlStemBlock) event.block.getBlock()).setGrowthStage(event.world, event.pos, event.block); - } else + // If the stage is below max, then set the growth to max stage, if its already fully grown, cancel the event (prevent the player from losing bonemeal) + if ((Integer) event.getBlock().getValue(GysahlStemBlock.STAGE) < GysahlStemBlock.MAXSTAGE) + { + ((GysahlStemBlock) event.getBlock().getBlock()).setGrowthStage(event.getWorld(), event.getPos(), event.getBlock()); + } + else event.setCanceled(true); } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/items/ChocoboWhistleItem.java b/src/main/java/uk/co/haxyshideout/chococraft2/items/ChocoboWhistleItem.java index fdd0617..f1dfc74 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/items/ChocoboWhistleItem.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/items/ChocoboWhistleItem.java @@ -1,46 +1,53 @@ package uk.co.haxyshideout.chococraft2.items; +import java.util.UUID; + import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; +import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; +import net.minecraftforge.fml.common.FMLCommonHandler; import uk.co.haxyshideout.chococraft2.entities.EntityChocobo; import uk.co.haxyshideout.haxylib.items.GenericItem; -import java.util.UUID; - -public class ChocoboWhistleItem extends GenericItem { +public class ChocoboWhistleItem extends GenericItem +{ @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { + public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer player, EnumHand hand) + { if (world.isRemote)// return if client - return itemstack; + return new ActionResult(EnumActionResult.PASS, itemstack); - itemstack = super.onItemRightClick(itemstack, world, player); + itemstack = super.onItemRightClick(itemstack, world, player, hand).getResult(); - if(!itemstack.hasTagCompound() || !itemstack.getTagCompound().hasKey("LinkedChocoboUUID")) - return itemstack; + if (!itemstack.hasTagCompound() || !itemstack.getTagCompound().hasKey("LinkedChocoboUUID")) + return new ActionResult(EnumActionResult.PASS, itemstack); UUID chocoboUUID = UUID.fromString(itemstack.getTagCompound().getString("LinkedChocoboUUID")); - Entity entity = MinecraftServer.getServer().getEntityFromUuid(chocoboUUID); - if(entity == null) { - player.addChatComponentMessage(new ChatComponentText("Unable to find linked chocobo")); - return itemstack; + Entity entity = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityFromUuid(chocoboUUID); + if (entity == null) + { + player.addChatComponentMessage(new TextComponentString("Unable to find linked chocobo")); + return new ActionResult(EnumActionResult.PASS, itemstack); } - if(entity instanceof EntityChocobo) { - if(entity.worldObj != player.worldObj) { - player.addChatComponentMessage(new ChatComponentText("The chocobo is not in the same world as you")); - return itemstack; - // MinecraftServer.getServer().getConfigurationManager().transferEntityToWorld(entity, entity.dimension, (WorldServer)entity.getEntityWorld(), (WorldServer)player.worldObj); + if (entity instanceof EntityChocobo) + { + if (entity.worldObj != player.worldObj) + { + player.addChatComponentMessage(new TextComponentString("The chocobo is not in the same world as you")); + return new ActionResult(EnumActionResult.PASS, itemstack); + // MinecraftServer.getServer().getConfigurationManager().transferEntityToWorld(entity, entity.dimension, (WorldServer)entity.getEntityWorld(), (WorldServer)player.worldObj); } entity.setLocationAndAngles(player.posX, player.posY, player.posZ, 0, 0); - player.addChatComponentMessage(new ChatComponentText("You called "+entity.getCommandSenderName()+" to you")); + player.addChatComponentMessage(new TextComponentString("You called " + entity.getName() + " to you")); } - return itemstack; + return new ActionResult(EnumActionResult.PASS, itemstack); } } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/items/SpawnEggItem.java b/src/main/java/uk/co/haxyshideout/chococraft2/items/SpawnEggItem.java index 01ceb36..74a56e8 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/items/SpawnEggItem.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/items/SpawnEggItem.java @@ -1,11 +1,16 @@ package uk.co.haxyshideout.chococraft2.items; -import uk.co.haxyshideout.chococraft2.entities.EntityChocobo.ChocoboColor; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; import net.minecraft.world.World; import uk.co.haxyshideout.chococraft2.entities.EntityChocobo; +import uk.co.haxyshideout.chococraft2.entities.EntityChocobo.ChocoboColor; import uk.co.haxyshideout.haxylib.items.GenericItem; import uk.co.haxyshideout.haxylib.utils.RandomHelper; @@ -24,19 +29,20 @@ public SpawnEggItem(ChocoboColor mobColor) } @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { + public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer player, EnumHand hand) + { if (!player.capabilities.isCreativeMode) itemstack.stackSize--; if (!player.worldObj.isRemote && !player.capabilities.isFlying) { - player.worldObj.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (RandomHelper.random.nextFloat() * 0.4f + 0.8f)); + player.worldObj.playSound(player, player.getPosition(), new SoundEvent(new ResourceLocation("random.bow")), SoundCategory.AMBIENT, 0.5F, 0.4F / (RandomHelper.random.nextFloat() * 0.4f + 0.8f)); EntityChocobo entity = new EntityChocobo(player.worldObj); entity.setColor(mobColor); entity.setLocationAndAngles(player.posX, player.posY, player.posZ, player.cameraYaw, player.cameraPitch); player.worldObj.spawnEntityInWorld(entity); } - return itemstack; + return new ActionResult(EnumActionResult.SUCCESS, itemstack); } } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/ChocopediaEditPacket.java b/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/ChocopediaEditPacket.java index 2e136e6..722effe 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/ChocopediaEditPacket.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/ChocopediaEditPacket.java @@ -1,11 +1,15 @@ package uk.co.haxyshideout.chococraft2.network.side.server; +import java.util.UUID; + import com.mojang.authlib.GameProfile; + import io.netty.buffer.ByteBuf; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ChatComponentText; +import net.minecraft.util.text.TextComponentString; +import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; @@ -13,21 +17,23 @@ import uk.co.haxyshideout.chococraft2.client.gui.ChocopediaGui; import uk.co.haxyshideout.chococraft2.entities.EntityChocobo; -import java.util.UUID; - /** * Created by clienthax on 5/5/2015. */ -public class ChocopediaEditPacket implements IMessage { +public class ChocopediaEditPacket implements IMessage +{ UUID entityID; String chocoboName; EntityChocobo.MovementType movementType; String ownerName; - public ChocopediaEditPacket() {} + public ChocopediaEditPacket() + { + } - public ChocopediaEditPacket(ChocopediaGui chocopediaGui) { + public ChocopediaEditPacket(ChocopediaGui chocopediaGui) + { entityID = chocopediaGui.chocobo.getUniqueID(); chocoboName = chocopediaGui.name; movementType = chocopediaGui.movementType; @@ -35,7 +41,8 @@ public ChocopediaEditPacket(ChocopediaGui chocopediaGui) { } @Override - public void fromBytes(ByteBuf buf) { + public void fromBytes(ByteBuf buf) + { entityID = UUID.fromString(ByteBufUtils.readUTF8String(buf)); chocoboName = ByteBufUtils.readUTF8String(buf); movementType = EntityChocobo.MovementType.values()[buf.readByte()]; @@ -43,29 +50,37 @@ public void fromBytes(ByteBuf buf) { } @Override - public void toBytes(ByteBuf buf) { + public void toBytes(ByteBuf buf) + { ByteBufUtils.writeUTF8String(buf, entityID.toString()); ByteBufUtils.writeUTF8String(buf, chocoboName); buf.writeByte(movementType.ordinal()); ByteBufUtils.writeUTF8String(buf, ownerName); } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler + { @Override - public IMessage onMessage(ChocopediaEditPacket message, MessageContext ctx) { - Entity entity = MinecraftServer.getServer().getEntityFromUuid(message.entityID); - if (entity != null && entity instanceof EntityChocobo) { + public IMessage onMessage(ChocopediaEditPacket message, MessageContext ctx) + { + Entity entity = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityFromUuid(message.entityID); + if (entity != null && entity instanceof EntityChocobo) + { EntityChocobo chocobo = (EntityChocobo) entity; EntityPlayerMP player = ctx.getServerHandler().playerEntity; - if (player == chocobo.getOwner()) {//Verify that the person who sent the packet is the owner of the chocobo + if (player == chocobo.getOwner()) + {// Verify that the person who sent the packet is the owner of the chocobo chocobo.setCustomNameTag(message.chocoboName); chocobo.setMovementType(message.movementType); - GameProfile ownerProfile = MinecraftServer.getServer().getPlayerProfileCache().getGameProfileForUsername(message.ownerName); - if(ownerProfile != null) { - chocobo.setOwnerId(ownerProfile.getId().toString()); - } else { - ctx.getServerHandler().playerEntity.addChatComponentMessage(new ChatComponentText("Unable to find owner by that name, not applying new owner!")); + GameProfile ownerProfile = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getGameProfileForUsername(message.ownerName); + if (ownerProfile != null) + { + chocobo.setOwnerId(ownerProfile.getId()); + } + else + { + ctx.getServerHandler().playerEntity.addChatComponentMessage(new TextComponentString("Unable to find owner by that name, not applying new owner!")); } } } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/DropGearPacket.java b/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/DropGearPacket.java index b18d708..c7655f3 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/DropGearPacket.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/DropGearPacket.java @@ -1,48 +1,58 @@ package uk.co.haxyshideout.chococraft2.network.side.server; +import java.util.UUID; + import io.netty.buffer.ByteBuf; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.server.MinecraftServer; +import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import uk.co.haxyshideout.chococraft2.entities.EntityChocobo; -import java.util.UUID; - /** * Created by clienthax on 5/5/2015. */ -public class DropGearPacket implements IMessage { +public class DropGearPacket implements IMessage +{ - public DropGearPacket(){} + public DropGearPacket() + { + } UUID entityID; - public DropGearPacket(EntityChocobo chocobo) { + public DropGearPacket(EntityChocobo chocobo) + { entityID = chocobo.getUniqueID(); } @Override - public void fromBytes(ByteBuf buf) { + public void fromBytes(ByteBuf buf) + { entityID = UUID.fromString(ByteBufUtils.readUTF8String(buf)); } @Override - public void toBytes(ByteBuf buf) { + public void toBytes(ByteBuf buf) + { ByteBufUtils.writeUTF8String(buf, entityID.toString()); } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler + { @Override - public IMessage onMessage(DropGearPacket message, MessageContext ctx) { - Entity entity = MinecraftServer.getServer().getEntityFromUuid(message.entityID); - if(entity != null && entity instanceof EntityChocobo) { + public IMessage onMessage(DropGearPacket message, MessageContext ctx) + { + Entity entity = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityFromUuid(message.entityID); + if (entity != null && entity instanceof EntityChocobo) + { EntityChocobo chocobo = (EntityChocobo) entity; EntityPlayerMP player = ctx.getServerHandler().playerEntity; - if(player == chocobo.getOwner()) {//Verify that the person who sent the packet is the owner of the chocobo + if (player == chocobo.getOwner()) + {// Verify that the person who sent the packet is the owner of the chocobo chocobo.dropGear(ctx.getServerHandler().playerEntity); } } @@ -52,5 +62,4 @@ public IMessage onMessage(DropGearPacket message, MessageContext ctx) { } - } diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/RiderStateUpdatePacket.java b/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/RiderStateUpdatePacket.java index ffb0f12..7e933e7 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/RiderStateUpdatePacket.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/network/side/server/RiderStateUpdatePacket.java @@ -37,7 +37,7 @@ public void toBytes(ByteBuf buf) { public static class Handler implements IMessageHandler { @Override public IMessage onMessage(RiderStateUpdatePacket message, MessageContext ctx) { - Entity entity = ctx.getServerHandler().playerEntity.ridingEntity; + Entity entity = ctx.getServerHandler().playerEntity.getRidingEntity(); if(!(entity instanceof EntityChocobo)) return null; diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/proxies/ClientProxy.java b/src/main/java/uk/co/haxyshideout/chococraft2/proxies/ClientProxy.java index 4359514..25188ef 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/proxies/ClientProxy.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/proxies/ClientProxy.java @@ -55,7 +55,7 @@ public void openChocopedia(EntityChocobo chocobo) @Override public void updateRiderState(EntityPlayer rider) { - EntityChocobo chocobo = (EntityChocobo) rider.ridingEntity; + EntityChocobo chocobo = (EntityChocobo) rider.getRidingEntity(); chocobo.getRiderState().updateState(getRiderState(rider)); if (chocobo.getRiderState().hasChanged()) { diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/proxies/ServerProxy.java b/src/main/java/uk/co/haxyshideout/chococraft2/proxies/ServerProxy.java index 379d840..5af9445 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/proxies/ServerProxy.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/proxies/ServerProxy.java @@ -34,7 +34,7 @@ public void registerEntities() ChococraftConfig config = ChocoCraft2.instance.getConfig(); List spawnBiomes = config.getSpawnBiomes(); EntityRegistry.addSpawn(EntityChocobo.class, config.getOverworldWeight(), config.getOverworldMinGroup(), config.getOverworldMaxGroup(), EnumCreatureType.CREATURE, spawnBiomes.toArray(new BiomeGenBase[spawnBiomes.size()])); - EntityRegistry.addSpawn(EntityChocobo.class, config.getNetherWeight(), config.getNetherMinGroup(), config.getNetherMaxGroup(), EnumCreatureType.CREATURE, BiomeGenBase.hell); + EntityRegistry.addSpawn(EntityChocobo.class, config.getNetherWeight(), config.getNetherMinGroup(), config.getNetherMaxGroup(), EnumCreatureType.CREATURE, BiomeGenBase.getBiome(8)); } public void registerWorldGenerators() diff --git a/src/main/java/uk/co/haxyshideout/chococraft2/worldgen/GysahlGen.java b/src/main/java/uk/co/haxyshideout/chococraft2/worldgen/GysahlGen.java index a8c0309..0b2c287 100644 --- a/src/main/java/uk/co/haxyshideout/chococraft2/worldgen/GysahlGen.java +++ b/src/main/java/uk/co/haxyshideout/chococraft2/worldgen/GysahlGen.java @@ -1,34 +1,36 @@ package uk.co.haxyshideout.chococraft2.worldgen; +import java.util.Random; + import net.minecraft.block.BlockBush; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.fml.common.IWorldGenerator; import uk.co.haxyshideout.chococraft2.blocks.GysahlStemBlock; import uk.co.haxyshideout.chococraft2.config.Additions; import uk.co.haxyshideout.haxylib.worldgen.BushGen; -import java.util.Random; - /** * Created by clienthax on 2/6/2015. */ -public class GysahlGen implements IWorldGenerator { - +public class GysahlGen implements IWorldGenerator +{ BushGen bushGen = new BushGen((BlockBush) Additions.gysahlStemBlock, Additions.gysahlStemBlock.getDefaultState().withProperty(GysahlStemBlock.STAGE, GysahlStemBlock.MAXSTAGE)); @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { - if(!world.provider.isSurfaceWorld())//Only spawn in the main world + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) + { + if (!world.provider.isSurfaceWorld())// Only spawn in the main world return; - if(!(random.nextInt(1000) < 100)) + if (!(random.nextInt(1000) < 100)) return; - int poxX = chunkX * 16 + random.nextInt(16);//gets us the world position of where to spawn the gysahls + int poxX = chunkX * 16 + random.nextInt(16);// gets us the world position of where to spawn the gysahls int posZ = chunkZ * 16 + random.nextInt(16); - BlockPos finalPosition = world.getTopSolidOrLiquidBlock(new BlockPos(poxX, 0, posZ));//Gets the top block - bushGen.generate(world, random, finalPosition);//Generate the blocks in world + BlockPos finalPosition = world.getTopSolidOrLiquidBlock(new BlockPos(poxX, 0, posZ));// Gets the top block + bushGen.generate(world, random, finalPosition);// Generate the blocks in world } } diff --git a/src/main/java/uk/co/haxyshideout/haxylib/blocks/GenericBlock.java b/src/main/java/uk/co/haxyshideout/haxylib/blocks/GenericBlock.java index 086cebb..efa0e16 100644 --- a/src/main/java/uk/co/haxyshideout/haxylib/blocks/GenericBlock.java +++ b/src/main/java/uk/co/haxyshideout/haxylib/blocks/GenericBlock.java @@ -2,42 +2,49 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; /** * Created by clienthax on 12/4/2015. */ -@SuppressWarnings("UnusedReturnValue") -public class GenericBlock extends Block { +public class GenericBlock extends Block +{ private boolean opaque = true; private boolean fullcube = true; - public GenericBlock(Material materialIn) { + public GenericBlock(Material materialIn) + { super(materialIn); } - public Block setFullCube(boolean fullcube) { + public Block setFullCube(boolean fullcube) + { this.fullcube = fullcube; return this; } @Override - public boolean isFullCube() { + public boolean isFullCube(IBlockState state) + { return fullcube; } - public Block setOpaque(boolean opaque) { + public Block setOpaque(boolean opaque) + { this.opaque = opaque; return this; } @Override - public boolean isOpaqueCube() { + public boolean isOpaqueCube(IBlockState state) + { return opaque; } @Override - public String getUnlocalizedName() { + public String getUnlocalizedName() + { return super.getUnlocalizedName().substring(5); } diff --git a/src/main/java/uk/co/haxyshideout/haxylib/debug/DebugHelper.java b/src/main/java/uk/co/haxyshideout/haxylib/debug/DebugHelper.java index 20f53b9..75f2ed6 100644 --- a/src/main/java/uk/co/haxyshideout/haxylib/debug/DebugHelper.java +++ b/src/main/java/uk/co/haxyshideout/haxylib/debug/DebugHelper.java @@ -3,54 +3,61 @@ import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; +import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fml.common.registry.GameData; import net.minecraftforge.fml.common.registry.GameRegistry; @SuppressWarnings("unchecked") -public class DebugHelper { +public class DebugHelper +{ - public static void langCheck(String modid) { + public static void langCheck(String modid) + { checkMissingBlockLangEntries(modid); checkMissingItemLangEntries(modid); } - private static void checkMissingItemLangEntries(String modID) { - for(Item item : (Iterable) GameData.getItemRegistry()) { - if(!GameRegistry.findUniqueIdentifierFor(item).modId.equals(modID))//ONly check items for pixelmon + private static void checkMissingItemLangEntries(String modID) + { + for (Item item : (Iterable) GameData.getItemRegistry()) + { + if (GameRegistry.findItem(modID, item.getUnlocalizedName()) != null)// ONly check items for pixelmon continue; String itemName = item.getItemStackDisplayName(new ItemStack(item, 1)); - if(itemName.contains(".")) + if (itemName.contains(".")) { - String translated = StatCollector.translateToLocal(itemName); - if(translated.equals(itemName)){ + String translated = I18n.translateToLocal(itemName); + if (translated.equals(itemName)) + { System.out.println("Item " + itemName + " Doesn't have a lang entry"); } } } } - private static void checkMissingBlockLangEntries(String modID) {//Check missing block lang entries - for(Block block : (Iterable) GameData.getBlockRegistry()) { - if(!GameRegistry.findUniqueIdentifierFor(block).modId.equals(modID))//Only check blocks for pixelmon + private static void checkMissingBlockLangEntries(String modID) + {// Check missing block lang entries + for (Block block : (Iterable) GameData.getBlockRegistry()) + { + if (GameRegistry.findBlock(modID, block.getUnlocalizedName()) != null)// Only check blocks for pixelmon continue; Item blockItem = Item.getItemFromBlock(block); - if(blockItem == null) + if (blockItem == null) continue; String blockName = blockItem.getItemStackDisplayName(new ItemStack(blockItem, 1)); - if(blockName.contains(".")) + if (blockName.contains(".")) { - String translated = StatCollector.translateToLocal(blockName); - if(translated.equals(blockName)) { - System.out.println("Block "+ blockName+" Doesn't have a lang entry"); + String translated = I18n.translateToLocal(blockName); + if (translated.equals(blockName)) + { + System.out.println("Block " + blockName + " Doesn't have a lang entry"); } } - } } diff --git a/src/main/java/uk/co/haxyshideout/haxylib/items/GenericArmor.java b/src/main/java/uk/co/haxyshideout/haxylib/items/GenericArmor.java index 24acddb..3d76de7 100644 --- a/src/main/java/uk/co/haxyshideout/haxylib/items/GenericArmor.java +++ b/src/main/java/uk/co/haxyshideout/haxylib/items/GenericArmor.java @@ -1,23 +1,26 @@ package uk.co.haxyshideout.haxylib.items; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArmor; -public class GenericArmor extends ItemArmor implements IJsonItem { - - public enum ArmorType {Helm,Plate,Legs,Boots} +public class GenericArmor extends ItemArmor implements IJsonItem +{ public boolean equippedSet = false; - public GenericArmor(ArmorMaterial material, int renderIndex, ArmorType armorType) { - super(material, renderIndex, armorType.ordinal()); + public GenericArmor(ItemArmor.ArmorMaterial material, int renderIndex, EntityEquipmentSlot armorType) + { + super(material, renderIndex, armorType); } @Override - public String getUnlocalizedName() { + public String getUnlocalizedName() + { return super.getUnlocalizedName().substring(5); } @Override - public String getTextureFolder() { + public String getTextureFolder() + { return "items/armor"; } -} \ No newline at end of file +} diff --git a/src/main/java/uk/co/haxyshideout/haxylib/utils/RegistryHelper.java b/src/main/java/uk/co/haxyshideout/haxylib/utils/RegistryHelper.java index 2e67f5d..8847563 100644 --- a/src/main/java/uk/co/haxyshideout/haxylib/utils/RegistryHelper.java +++ b/src/main/java/uk/co/haxyshideout/haxylib/utils/RegistryHelper.java @@ -1,7 +1,9 @@ package uk.co.haxyshideout.haxylib.utils; +import java.lang.reflect.Field; + import net.minecraft.block.Block; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.client.model.ModelLoader; @@ -9,8 +11,6 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.lang.reflect.Field; - /** * Created by clienthax on 12/4/2015. */ diff --git a/src/main/java/uk/co/haxyshideout/haxylib/utils/WorldHelper.java b/src/main/java/uk/co/haxyshideout/haxylib/utils/WorldHelper.java index db26b0d..fcec04a 100644 --- a/src/main/java/uk/co/haxyshideout/haxylib/utils/WorldHelper.java +++ b/src/main/java/uk/co/haxyshideout/haxylib/utils/WorldHelper.java @@ -1,20 +1,19 @@ package uk.co.haxyshideout.haxylib.utils; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldProviderHell; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - /** * Created by clienthax on 20/5/2015. */ -@SuppressWarnings("WhileLoopReplaceableByForEach") public class WorldHelper { public static boolean isHellWorld(World world) { @@ -22,7 +21,7 @@ public static boolean isHellWorld(World world) { } public static boolean isBlockAtPositionLiquid(World world, BlockPos pos) { - return world.getBlockState(pos).getBlock().getMaterial().isLiquid(); + return world.getBlockState(pos).getBlock().getMaterial(world.getBlockState(pos)).isLiquid(); } public static boolean isNormalCubesAround(World world, BlockPos pos) { @@ -34,13 +33,13 @@ public static boolean isNormalCubesAround(World world, BlockPos pos) { } private static boolean isNormalBlockAtPos(World world, BlockPos pos) { - return world.getBlockState(pos).getBlock().isNormalCube(); + return world.getBlockState(pos).getBlock().isNormalCube(world.getBlockState(pos)); } public static BlockPos getFirstSolidWithAirAbove(World world, BlockPos pos) {//TODO more efficient way of doing this for(int y = pos.getY(); y < world.getHeight(); y++) { pos = new BlockPos(pos.getX(), y, pos.getZ()); - if(world.getBlockState(pos).getBlock().isNormalCube() && world.isAirBlock(pos.up())) + if(world.getBlockState(pos).getBlock().isNormalCube(world.getBlockState(pos)) && world.isAirBlock(pos.up())) return pos; } return null; diff --git a/src/main/java/uk/co/haxyshideout/haxylib/worldgen/BushGen.java b/src/main/java/uk/co/haxyshideout/haxylib/worldgen/BushGen.java index 3793440..9002f5e 100644 --- a/src/main/java/uk/co/haxyshideout/haxylib/worldgen/BushGen.java +++ b/src/main/java/uk/co/haxyshideout/haxylib/worldgen/BushGen.java @@ -1,12 +1,12 @@ package uk.co.haxyshideout.haxylib.worldgen; +import java.util.Random; + import net.minecraft.block.BlockBush; import net.minecraft.block.state.IBlockState; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.Random; - /** * Created by clienthax on 2/6/2015. * Like WorldGenFlowers, but for bushs