diff --git a/java/werty/hardcoreexpanded/main/BlockAltar.java b/java/werty/hardcoreexpanded/main/BlockAltar.java index 5446c9d..7247add 100644 --- a/java/werty/hardcoreexpanded/main/BlockAltar.java +++ b/java/werty/hardcoreexpanded/main/BlockAltar.java @@ -6,11 +6,19 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumBlockRenderType; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import javax.annotation.Nullable; public class BlockAltar extends Block { @@ -20,26 +28,44 @@ public BlockAltar(Material materialIn) } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(playerIn); - if(nbt.getBoolean("ghost") == true) + if(nbt.getBoolean("ghost")) { - worldIn.addWeatherEffect(new EntityLightningBolt(worldIn, pos.getX(), pos.getY(), pos.getZ())); + worldIn.addWeatherEffect(new EntityLightningBolt(worldIn, pos.getX(), pos.getY(), pos.getZ(), false)); worldIn.destroyBlock(pos, false); nbt.setBoolean("ghost", false); - playerIn.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(Config.healthStarting); + playerIn.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(Config.healthStarting); nbt.setDouble("health", playerIn.getMaxHealth()); - playerIn.addChatMessage(new ChatComponentText("You feel the altar pull you back from the dead!")); + playerIn.addChatMessage(new TextComponentString("You feel the altar pull you back from the dead!")); } else { - playerIn.addChatMessage(new ChatComponentText("you can feel a strange presence")); + playerIn.addChatMessage(new TextComponentString("you can feel a strange presence")); } } return true; } + + @SideOnly(Side.CLIENT) + public BlockRenderLayer getBlockLayer() {return BlockRenderLayer.CUTOUT;} + + @Override + public boolean isOpaqueCube(IBlockState iBlockState) { + return false; + } + + @Override + public boolean isFullCube(IBlockState iBlockState) { + return false; + } + + @Override + public EnumBlockRenderType getRenderType(IBlockState iBlockState) { + return EnumBlockRenderType.MODEL; + } } diff --git a/java/werty/hardcoreexpanded/main/Config.java b/java/werty/hardcoreexpanded/main/Config.java index 810907c..4790c6c 100644 --- a/java/werty/hardcoreexpanded/main/Config.java +++ b/java/werty/hardcoreexpanded/main/Config.java @@ -1,10 +1,7 @@ package werty.hardcoreexpanded.main; import java.io.File; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.block.Block; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @@ -25,7 +22,7 @@ public class Config public static boolean ghostMode; public static boolean checkForUpdates; public static boolean healthEffects; - public static boolean fiilEffects; + public static boolean fillEffects; public static boolean ghostInvisibility; public static boolean ghostFillHeart; public static boolean genGhostAltar; @@ -35,7 +32,7 @@ public class Config public static String interactableBlocks; public static String breakableBlocks; public static String usableItems; - + public static void configInit(FMLPreInitializationEvent event) { Configuration config = new Configuration(new File("config/SofterHardcore.cfg")); @@ -43,25 +40,25 @@ public static void configInit(FMLPreInitializationEvent event) healthStarting = config.get("Mechanics", "StartingHealth", 20D, "Starting health. Vanilla is 20").getDouble(); healthMax = config.get("Mechanics", "MaxHealth", 20D, "Max health. Vanilla is 20").getDouble(); sicknessTicks = config.get("Mechanics", "SicknessTicks", 12000, "How long the sickness will last 12000 = 10 minutes").getInt(); - deathAmount = config.get("Mechanics", "DeathAmount", 2D, "Amount of healh taken on death").getDouble(); + deathAmount = config.get("Mechanics", "DeathAmount", 2D, "Amount of health taken on death").getDouble(); damageBoost = config.get("Mechanics", "DamageBoost", 2, "Damage boost added to monsters").getInt(); healthXP = config.get("Mechanics", "ExperienceForHeart", 10, "Experience level needed to fill a heart").getInt(); ghostMode = config.get("Mechanics", "GhostMode", true, "If player will spawn with debuffs").getBoolean(); - fiilEffects = config.get("Mechanics", "HeartFillEffects", true, "If player suffer temp. Debuff on filling up a heart").getBoolean(); + fillEffects = config.get("Mechanics", "HeartFillEffects", true, "If player suffer temp. Debuff on filling up a heart").getBoolean(); ghostInvisibility = config.get("Mechanics", "GhostInvisibility", true, "Gain Invisibility as a ghost").getBoolean(); checkForUpdates = config.get("Mechanics", "CheckForUpdates", true, "Should mod check for updates?").getBoolean(); ghostFillHeart = config.get("Mechanics", "GhostHeartFill", false, "Can ghost players fill hearts?").getBoolean(); healthEffects = config.get("Mechanics", "HealthEffects", true, "Debuffs on thresholds at 1/2 and 1/3 health and a damage boost at full health").getBoolean(); woodenToolDamage = config.get("Mechanics", "WoodenToolDamage", false, "Should wooden tools do damage").getBoolean(); - interactableBlocks = config.get("Ghost", "GhostInteractableBlocks", "modid:blockid", "Blocks ghost players can interact with using right click. Add blocks seperated with a , and using ModID:BlockID").getString(); - breakableBlocks = config.get("Ghost", "GhostBreakableBlocks", "modid:blockid", "Blocks ghost players can break with. Add blocks seperated with a , and using ModID:BlockID").getString(); - usableItems = config.get("Ghost", "GhostUsableItems", "modid:itemid", "Items ghost players can pick up and use. Add items seperated with a , and using ModID:itemID").getString(); + interactableBlocks = config.get("Ghost", "GhostInteractableBlocks", "modid:blockid", "Blocks ghost players can interact with using right click. Add blocks separated with a , and using ModID:BlockID").getString(); + breakableBlocks = config.get("Ghost", "GhostBreakableBlocks", "modid:blockid", "Blocks ghost players can break with. Add blocks separated with a , and using ModID:BlockID").getString(); + usableItems = config.get("Ghost", "GhostUsableItems", "modid:itemid", "Items ghost players can pick up and use. Add items separated with a , and using ModID:itemID").getString(); genGhostAltar = config.get("World", "GenGhostAltar", true, "Should ghost altars generate?").getBoolean(); - altarGenChance = config.get("World", "GhostAltarChance", 5, "Ghost altar generation chance").getInt(); + altarGenChance = config.get("World", "GhostAltarChance", 10, "Ghost altar generation chance").getInt(); - mobEffects = config.get("Mobs", "MobEffects", true, "Should mobs have a chance to cause debuffs? Set to fale to disable all effects under mobs").getBoolean(); + mobEffects = config.get("Mobs", "MobEffects", true, "Should mobs have a chance to cause debuffs? Set to false to disable all effects under mobs").getBoolean(); zombiePoisonChance = config.get("Mobs", "ZombiePoisonChance", 20, "Zombie poison chance. Set to 0 to disable").getInt(); fallStunChance = config.get("Mobs", "FallStunChance", 15, "Chance to be stunned on fall damage. Set to 0 to disable").getInt(); config.save(); diff --git a/java/werty/hardcoreexpanded/main/HEBlocks.java b/java/werty/hardcoreexpanded/main/HEBlocks.java index 4730dab..d0cfb72 100644 --- a/java/werty/hardcoreexpanded/main/HEBlocks.java +++ b/java/werty/hardcoreexpanded/main/HEBlocks.java @@ -3,7 +3,7 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -14,7 +14,7 @@ public class HEBlocks public static void init() { - ghostAltar = new BlockAltar(Material.rock).setBlockUnbreakable().setUnlocalizedName("ghost_altar").setCreativeTab(CreativeTabs.tabMisc); + ghostAltar = new BlockAltar(Material.ROCK).setBlockUnbreakable().setUnlocalizedName("ghost_altar").setCreativeTab(CreativeTabs.MISC); register(ghostAltar); } diff --git a/java/werty/hardcoreexpanded/main/HEEventHandler.java b/java/werty/hardcoreexpanded/main/HEEventHandler.java index e53ec46..11e8e89 100644 --- a/java/werty/hardcoreexpanded/main/HEEventHandler.java +++ b/java/werty/hardcoreexpanded/main/HEEventHandler.java @@ -1,21 +1,17 @@ package werty.hardcoreexpanded.main; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - import net.minecraft.block.Block; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.init.MobEffects; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumHand; +import net.minecraft.util.text.TextComponentString; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -23,10 +19,13 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + public class HEEventHandler { @@ -37,14 +36,14 @@ public class HEEventHandler public static void loadAllowedBlocksandItems() { - interactableBlocks.add(Blocks.acacia_door); - interactableBlocks.add(Blocks.oak_door); - interactableBlocks.add(Blocks.birch_door); - interactableBlocks.add(Blocks.spruce_door); - interactableBlocks.add(Blocks.dark_oak_door); - interactableBlocks.add(Blocks.lever); - interactableBlocks.add(Blocks.wooden_button); - interactableBlocks.add(Blocks.stone_button); + interactableBlocks.add(Blocks.ACACIA_DOOR); + interactableBlocks.add(Blocks.OAK_DOOR); + interactableBlocks.add(Blocks.BIRCH_DOOR); + interactableBlocks.add(Blocks.SPRUCE_DOOR); + interactableBlocks.add(Blocks.DARK_OAK_DOOR); + interactableBlocks.add(Blocks.LEVER); + interactableBlocks.add(Blocks.WOODEN_BUTTON); + interactableBlocks.add(Blocks.STONE_BUTTON); interactableBlocks.add(HEBlocks.ghostAltar); for(String s : Config.interactableBlocks.split(",")) @@ -82,44 +81,44 @@ public static void loadAllowedBlocksandItems() public void onPlayerJoin(EntityJoinWorldEvent event) { VersionChecker check = new VersionChecker(References.VERSION, "https://raw.githubusercontent.com/werty1124/SofterHardcore/master/version.txt", References.NAME); - if (event.entity instanceof EntityPlayer) + if (event.getEntity() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; + EntityPlayer player = (EntityPlayer) event.getEntity(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); - if(!event.world.isRemote) + if(!event.getWorld().isRemote) { if(player.worldObj.getWorldInfo().isHardcoreModeEnabled()) { - event.entity.addChatMessage(new ChatComponentText("SofterHardcore is meant to be played in survival. It will NOT prevent the deletion of worlds!")); + event.getEntity().addChatMessage(new TextComponentString("SofterHardcore is meant to be played in survival. It will NOT prevent the deletion of worlds!")); } if(Config.checkForUpdates && !HardcoreExpanded.hasCheckedVersion) { check.run(); - event.entity.addChatMessage(VersionChecker.uptoDate); + event.getEntity().addChatMessage(VersionChecker.uptoDate); HardcoreExpanded.hasCheckedVersion = true; } } - if(nbt.hasKey("ghost") && nbt.getBoolean("ghost") == true) + if(nbt.hasKey("ghost") && nbt.getBoolean("ghost")) { - if(!event.world.isRemote) + if(!event.getWorld().isRemote) { - event.entity.addChatMessage(new ChatComponentText("You have exhausted all of your lives and can no longer interact with the world")); + event.getEntity().addChatMessage(new TextComponentString("You have exhausted all of your lives and can no longer interact with the world")); } } else { - player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(Config.healthStarting); + player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(Config.healthStarting); if(nbt.hasKey("health")) { - player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(nbt.getDouble("health")); + player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(nbt.getDouble("health")); } } - if(Config.ghostMode == false && player.getMaxHealth() <= 0) + if(!Config.ghostMode && player.getMaxHealth() <= 0) { addDebuffs(player); - player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(Config.healthStarting/2); + player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(Config.healthStarting/2); nbt.setDouble("health", player.getMaxHealth()); } } @@ -127,20 +126,20 @@ public void onPlayerJoin(EntityJoinWorldEvent event) public void addDebuffs(EntityPlayer player) { - player.addPotionEffect(new PotionEffect(Potion.weakness.id, Config.sicknessTicks, 0, false, false)); - player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, Config.sicknessTicks, 0, false, false)); - player.addPotionEffect(new PotionEffect(Potion.blindness.id, Config.sicknessTicks/4, 0, false, false)); - player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, Config.sicknessTicks, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, Config.sicknessTicks, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.MINING_FATIGUE, Config.sicknessTicks, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, Config.sicknessTicks/4, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Config.sicknessTicks, 0, false, false)); } @SubscribeEvent public void onPlayerDeath(LivingDeathEvent event) { - if(event.entity instanceof EntityPlayer) + if(event.getEntity() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; + EntityPlayer player = (EntityPlayer) event.getEntity(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); - player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() - 2D); + player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(player.getMaxHealth() - 2D); nbt.setDouble("health", player.getMaxHealth()); if(player.getMaxHealth() <= 0) { @@ -155,20 +154,20 @@ public void onPlayerDeath(LivingDeathEvent event) @SubscribeEvent public void onUpdate(LivingUpdateEvent event) { - if(event.entity instanceof EntityPlayer) + if(event.getEntity()instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; + EntityPlayer player = (EntityPlayer) event.getEntity(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); - if(nbt.getBoolean("ghost") == true) + if(nbt.getBoolean("ghost")) { if(player.getFoodStats().getFoodLevel() < 20) { player.getFoodStats().setFoodLevel(20); } - if(Config.ghostInvisibility == true) + if(Config.ghostInvisibility) { - player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 5, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 5, 0, false, false)); } } @@ -176,15 +175,15 @@ public void onUpdate(LivingUpdateEvent event) { if(player.getHealth() == player.getMaxHealth()) { - player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 5, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 5, 0, false, false)); } if(player.getHealth() < player.getMaxHealth()/3) { - player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 50, 0, false, false)); } if(player.getHealth() < player.getMaxHealth()/2) { - player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 50, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 50, 0, false, false)); } } } @@ -193,13 +192,13 @@ public void onUpdate(LivingUpdateEvent event) @SubscribeEvent public void onItemPickup(EntityItemPickupEvent event) { - if(event.entity instanceof EntityPlayer) + if(event.getEntity() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; + EntityPlayer player = (EntityPlayer) event.getEntity(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); - Item item = event.item.getEntityItem().getItem(); - if(nbt.getBoolean("ghost") == true && usableItems.contains(item) == false) + Item item = event.getItem().getEntityItem().getItem(); + if(nbt.getBoolean("ghost") && !usableItems.contains(item)) { event.setCanceled(true); } @@ -209,50 +208,50 @@ public void onItemPickup(EntityItemPickupEvent event) @SubscribeEvent public void onEntityHurt(LivingHurtEvent event) { - if(event.entity instanceof EntityPlayer && event.source.getEntity() != null) + if(event.getEntity() instanceof EntityPlayer && event.getSource().getEntity() != null) { - EntityPlayer player = (EntityPlayer) event.entity; + EntityPlayer player = (EntityPlayer) event.getEntity(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); - if(!(event.source.getEntity() instanceof EntityPlayer)) + if(!(event.getSource().getEntity() instanceof EntityPlayer)) { - event.ammount += Config.damageBoost; + event.setAmount(event.getAmount() + Config.damageBoost); } - if(nbt.getBoolean("ghost") == true) + if(nbt.getBoolean("ghost")) { event.setCanceled(true); } } - if(event.entity instanceof EntityPlayer) + if(event.getEntity() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; + EntityPlayer player = (EntityPlayer) event.getEntity(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); - if(nbt.getBoolean("ghost") == true) + if(nbt.getBoolean("ghost")) { event.setCanceled(true); } } - if(event.source.getEntity() instanceof EntityPlayer) + if(event.getSource().getEntity() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); + EntityPlayer player = (EntityPlayer) event.getSource().getEntity(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); Item item = null; - if(player.getHeldItem() != null) + if(player.getHeldItem(EnumHand.MAIN_HAND) != null) { - item = player.getHeldItem().getItem(); + item = player.getHeldItem(EnumHand.MAIN_HAND).getItem(); } - if(item != null && (item == Items.wooden_axe || item == Items.wooden_sword || item == Items.wooden_shovel || item == Items.wooden_pickaxe || item == Items.wooden_hoe) && Config.woodenToolDamage == false) + if(item != null && (item == Items.WOODEN_AXE || item == Items.WOODEN_SWORD || item == Items.WOODEN_SHOVEL || item == Items.WOODEN_PICKAXE || item == Items.WOODEN_HOE) && !Config.woodenToolDamage) { - event.ammount = 0; + event.setAmount(0); } } } @@ -260,37 +259,37 @@ public void onEntityHurt(LivingHurtEvent event) @SubscribeEvent public void onPlayerAttack(LivingAttackEvent event) { - if(event.source.getEntity() instanceof EntityPlayer && event.source.getEntity() != null) + if(event.getSource().getEntity() instanceof EntityPlayer && event.getSource().getEntity() != null) { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); + EntityPlayer player = (EntityPlayer) event.getSource().getEntity(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); - if(nbt.getBoolean("ghost") == true) + if(nbt.getBoolean("ghost")) { event.setCanceled(true); } } - if(event.entityLiving instanceof EntityPlayer && Config.mobEffects == true) + if(event.getEntityLiving()instanceof EntityPlayer && Config.mobEffects) { - EntityPlayer player = (EntityPlayer) event.entityLiving; + EntityPlayer player = (EntityPlayer) event.getEntityLiving(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); Random rand = new Random(); - if(event.source.getEntity() instanceof EntityZombie && event.source.getEntity() != null) + if(event.getSource().getEntity() instanceof EntityZombie && event.getSource().getEntity() != null) { if(rand.nextInt(100) < Config.zombiePoisonChance) { - player.addPotionEffect(new PotionEffect(Potion.poison.id, 150, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.POISON, 150, 0, false, false)); } } - if("fall".equals(event.source.damageType)) + if("fall".equals(event.getSource().damageType)) { if(rand.nextInt(100) < Config.fallStunChance) { - player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 150, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 150, 0, false, false)); } } } @@ -298,30 +297,36 @@ public void onPlayerAttack(LivingAttackEvent event) } @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) + public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) { - EntityPlayer player = (EntityPlayer) event.entity; + EntityPlayer player = (EntityPlayer) event.getEntity(); NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); - if(nbt.getBoolean("ghost") == true) + if(nbt.getBoolean("ghost")) { - Block block = player.worldObj.getBlockState(event.pos).getBlock(); - if(event.action == Action.RIGHT_CLICK_BLOCK && interactableBlocks.contains(block)) + Block block = player.worldObj.getBlockState(event.getPos()).getBlock(); + if(!interactableBlocks.contains(block)) { - - } - else if(event.action == Action.LEFT_CLICK_BLOCK && breakableBlocks.contains(block)) - { - + event.setCanceled(true); } - else + } + } + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent.LeftClickBlock event) + { + EntityPlayer player = (EntityPlayer) event.getEntity(); + NBTTagCompound nbt = NBTHelper.getPersistedPlayerTag(player); + + if(nbt.getBoolean("ghost")) + { + Block block = player.worldObj.getBlockState(event.getPos()).getBlock(); + if(!breakableBlocks.contains(block)) { event.setCanceled(true); - } - - if(event.action != Action.LEFT_CLICK_BLOCK && player.getHeldItem() != null) + } + if(player.getHeldItem(EnumHand.MAIN_HAND) != null) { - if(usableItems.contains(player.getHeldItem().getItem())) + if(usableItems.contains(player.getHeldItem(EnumHand.MAIN_HAND).getItem())) { event.setCanceled(false); } diff --git a/java/werty/hardcoreexpanded/main/HEItems.java b/java/werty/hardcoreexpanded/main/HEItems.java index 94102f5..89f38b2 100644 --- a/java/werty/hardcoreexpanded/main/HEItems.java +++ b/java/werty/hardcoreexpanded/main/HEItems.java @@ -1,7 +1,7 @@ package werty.hardcoreexpanded.main; import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -13,16 +13,16 @@ public class HEItems { public static Item heart_empty; public static Item heart_full; - + public static void init() { - heart_empty = new ItemHeartEmpty().setUnlocalizedName("heart_empty").setCreativeTab(CreativeTabs.tabMisc); - heart_full = new ItemHeartFull().setUnlocalizedName("heart_full").setCreativeTab(CreativeTabs.tabMisc); + heart_empty = new ItemHeartEmpty().setUnlocalizedName("heart_empty").setCreativeTab(CreativeTabs.MISC); + heart_full = new ItemHeartFull().setUnlocalizedName("heart_full").setCreativeTab(CreativeTabs.MISC); register(heart_empty); register(heart_full); - GameRegistry.addRecipe(new ItemStack(heart_empty, 1), new Object[] {"D D", "DBD", " D ", 'D', Items.diamond, 'B', Blocks.diamond_block}); + GameRegistry.addRecipe(new ItemStack(heart_empty, 1), new Object[] {"D D", "DBD", " D ", 'D', Items.DIAMOND, 'B', Blocks.DIAMOND_BLOCK}); } public static void register(Item item) diff --git a/java/werty/hardcoreexpanded/main/HEWorldGenHandler.java b/java/werty/hardcoreexpanded/main/HEWorldGenHandler.java index c89391c..78578a0 100644 --- a/java/werty/hardcoreexpanded/main/HEWorldGenHandler.java +++ b/java/werty/hardcoreexpanded/main/HEWorldGenHandler.java @@ -1,60 +1,32 @@ package werty.hardcoreexpanded.main; -import java.util.Random; - -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.biome.WorldChunkManager; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.ChunkProviderGenerate; +import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.IWorldGenerator; -import net.minecraftforge.fml.common.registry.GameRegistry; +import org.apache.logging.log4j.Level; + +import java.util.Random; + +public class HEWorldGenHandler implements IWorldGenerator { + private void generateAltar(World world, BlockPos pos) { + final BlockPos newPos = world.getTopSolidOrLiquidBlock(pos); -public class HEWorldGenHandler implements IWorldGenerator -{ - public static void load() - { - GameRegistry.registerWorldGenerator(new HEWorldGenHandler(), 0); - } + world.setBlockState(newPos, HEBlocks.ghostAltar.getDefaultState()); + } - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) - { - if (chunkGenerator instanceof ChunkProviderGenerate) - { - this.generateOverworld(world, random, chunkX, chunkZ); - } - } - - public void generateOverworld(World world, Random rand, int x, int z) - { - int x1 = x; - int y1 = 0; - int z1 = z; - BlockPos pos = new BlockPos(x1 * 16, 0, z1 * 16); - Chunk chunk = world.getChunkFromBlockCoords(pos); - WorldChunkManager chunkManager = world.getWorldChunkManager(); - BiomeGenBase biome = chunk.getBiome(pos, chunkManager); - - if(Config.genGhostAltar == true) - { - this.generateAltar(world, rand, x1, z1); - } - } - - private void generateAltar(World world, Random rand, int chunkX, int chunkZ) - { - WorldGenAltar gen = new WorldGenAltar(); - for (int i = 0; i < 1; i++) - { - int xRand = chunkX * 16 + rand.nextInt(16); - int yRand = rand.nextInt(100); - int zRand = chunkZ * 16 + rand.nextInt(16); - BlockPos position = new BlockPos(xRand, yRand, zRand); - gen.generate(world, rand, position); - } - } - + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { + if (world.provider.isSurfaceWorld() && Config.genGhostAltar) { + final BlockPos basePos = new BlockPos(chunkX * 16 + random.nextInt(16), 0, chunkZ * 16 + random.nextInt(16)); + if (random.nextInt(Config.altarGenChance * 100) == 0) { + BlockPos finalPos = basePos.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8)); + generateAltar(world, finalPos); + FMLLog.getLogger().log(Level.INFO, "New shrine at: (" + finalPos.getX() + " " + finalPos.getY() + " " + finalPos.getZ() + ")"); + } + } + } } + diff --git a/java/werty/hardcoreexpanded/main/HardcoreExpanded.java b/java/werty/hardcoreexpanded/main/HardcoreExpanded.java index 941491b..4236be9 100644 --- a/java/werty/hardcoreexpanded/main/HardcoreExpanded.java +++ b/java/werty/hardcoreexpanded/main/HardcoreExpanded.java @@ -9,6 +9,7 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.registry.GameRegistry; @Mod(modid = References.MODID, name = References.NAME, version = References.VERSION) public class HardcoreExpanded @@ -37,7 +38,7 @@ public void init(FMLInitializationEvent event) proxy.registerRenders(); proxy.init(event); HEEventHandler.loadAllowedBlocksandItems(); - HEWorldGenHandler.load(); + GameRegistry.registerWorldGenerator(new HEWorldGenHandler(), 0); } @EventHandler diff --git a/java/werty/hardcoreexpanded/main/ItemHeartEmpty.java b/java/werty/hardcoreexpanded/main/ItemHeartEmpty.java index 3c7a48b..5dc62d9 100644 --- a/java/werty/hardcoreexpanded/main/ItemHeartEmpty.java +++ b/java/werty/hardcoreexpanded/main/ItemHeartEmpty.java @@ -1,12 +1,14 @@ package werty.hardcoreexpanded.main; -import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -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; public class ItemHeartEmpty extends Item @@ -15,12 +17,12 @@ public ItemHeartEmpty() { this.setMaxStackSize(1); } - - public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) + + public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { if(NBTHelper.getPersistedPlayerTag(playerIn).getBoolean("ghost") == true && Config.ghostFillHeart == false) { - return itemStackIn; + return new ActionResult(EnumActionResult.FAIL, itemStackIn); } else { @@ -28,18 +30,18 @@ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPl { playerIn.experienceLevel -= Config.healthXP; --itemStackIn.stackSize; - if(Config.fiilEffects) + if(Config.fillEffects) { if(!worldIn.isRemote) { - playerIn.addChatMessage(new ChatComponentText("You feel weak after transfering energy to the crystal")); + playerIn.addChatMessage(new TextComponentString("You feel weak after transfering energy to the crystal")); } - playerIn.addPotionEffect(new PotionEffect(Potion.weakness.id, Config.sicknessTicks, 0, false, false)); + playerIn.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, Config.sicknessTicks, 1, false, false));//weakness } - return new ItemStack(HEItems.heart_full); + return new ActionResult(EnumActionResult.SUCCESS, new ItemStack(HEItems.heart_full)); } } - return itemStackIn; + return new ActionResult(EnumActionResult.FAIL, itemStackIn); } } diff --git a/java/werty/hardcoreexpanded/main/ItemHeartFull.java b/java/werty/hardcoreexpanded/main/ItemHeartFull.java index 4ff2b87..41a1a1d 100644 --- a/java/werty/hardcoreexpanded/main/ItemHeartFull.java +++ b/java/werty/hardcoreexpanded/main/ItemHeartFull.java @@ -4,7 +4,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -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; public class ItemHeartFull extends Item @@ -13,25 +16,26 @@ public ItemHeartFull() { this.maxStackSize = 1; } - - public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) + + @Override + public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { --itemStackIn.stackSize; if(NBTHelper.getPersistedPlayerTag(playerIn).hasKey("ghost") && NBTHelper.getPersistedPlayerTag(playerIn).getBoolean("ghost")) { NBTHelper.getPersistedPlayerTag(playerIn).setBoolean("ghost", false); - playerIn.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(Config.healthStarting); + playerIn.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(Config.healthStarting); NBTHelper.getPersistedPlayerTag(playerIn).setDouble("health", playerIn.getMaxHealth()); - playerIn.addChatMessage(new ChatComponentText("You have been brought back from the dead!")); + playerIn.addChatMessage(new TextComponentString("You have been brought back from the dead!")); } else { if(playerIn.getMaxHealth() < Config.healthMax) { - playerIn.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(playerIn.getMaxHealth() + 2D); + playerIn.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(playerIn.getMaxHealth() + 2D); NBTHelper.getPersistedPlayerTag(playerIn).setDouble("health", playerIn.getMaxHealth()); } } - return itemStackIn; + return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); } } diff --git a/java/werty/hardcoreexpanded/main/References.java b/java/werty/hardcoreexpanded/main/References.java index 3f8707e..3af416b 100644 --- a/java/werty/hardcoreexpanded/main/References.java +++ b/java/werty/hardcoreexpanded/main/References.java @@ -7,9 +7,9 @@ public class References { public static final String MODID = "hardcoreexpanded"; public static final String NAME = "Hardcore Expanded"; - public static final String VERSION = "1.8.0-1.1.0"; + public static final String VERSION = "1.10.2-1.1.0"; - public static final List AUTHORS = Arrays.asList("TheWerty1124"); + public static final List AUTHORS = Arrays.asList("TheWerty1124", "actioninja"); public static final String CLIENT_PROXY_CLASS = "werty.hardcoreexpanded.main.ClientProxy"; public static final String SERVER_PROXY_CLASS = "werty.hardcoreexpanded.main.CommonProxy"; diff --git a/java/werty/hardcoreexpanded/main/VersionChecker.java b/java/werty/hardcoreexpanded/main/VersionChecker.java index 6ca1380..d79d7ec 100644 --- a/java/werty/hardcoreexpanded/main/VersionChecker.java +++ b/java/werty/hardcoreexpanded/main/VersionChecker.java @@ -1,12 +1,12 @@ package werty.hardcoreexpanded.main; +import net.minecraft.util.text.TextComponentString; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; -import net.minecraft.util.ChatComponentText; - public class VersionChecker implements Runnable { private String versionToCheck; @@ -15,7 +15,7 @@ public class VersionChecker implements Runnable public static boolean hasChecked = false; - public static ChatComponentText uptoDate; + public static TextComponentString uptoDate; public VersionChecker(String versionToCheck, String url, String name) { @@ -42,12 +42,12 @@ private boolean checkIfCurrent(String versiontocheck, String urlToCheck) if (version.equals(versiontocheck)) { upToDate = true; - uptoDate = new ChatComponentText("§2"+ name + " is the current version"); + uptoDate = new TextComponentString(name + " is the current version"); } else { upToDate = false; - uptoDate = new ChatComponentText("§cA newer version of " + name +" is available: " + version); + uptoDate = new TextComponentString("A newer version of " + name +" is available: " + version); } } } @@ -56,7 +56,7 @@ private boolean checkIfCurrent(String versiontocheck, String urlToCheck) catch (IOException e) { System.err.println("Version file not found at: " + urlToCheck); - uptoDate = new ChatComponentText("§c"+ name +" cannont find the latest version."); + uptoDate = new TextComponentString(name +" cannont find the latest version."); } return upToDate; } diff --git a/java/werty/hardcoreexpanded/main/WorldGenAltar.java b/java/werty/hardcoreexpanded/main/WorldGenAltar.java index 7d00500..9ef07c6 100644 --- a/java/werty/hardcoreexpanded/main/WorldGenAltar.java +++ b/java/werty/hardcoreexpanded/main/WorldGenAltar.java @@ -1,14 +1,12 @@ package werty.hardcoreexpanded.main; -import java.util.Random; - -import net.minecraft.block.BlockPumpkin; import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; +import java.util.Random; + public class WorldGenAltar extends WorldGenerator { @Override @@ -18,7 +16,7 @@ public boolean generate(World worldIn, Random rand, BlockPos pos) { BlockPos blockpos1 = pos.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); - if (worldIn.isAirBlock(blockpos1) && worldIn.getBlockState(blockpos1.down()).getBlock() == Blocks.grass) + if (worldIn.isAirBlock(blockpos1) && worldIn.getBlockState(blockpos1.down()).getBlock() == Blocks.GRASS) { worldIn.setBlockState(blockpos1, HEBlocks.ghostAltar.getDefaultState(), 2); } diff --git a/resources/assets/hardcoreexpanded/lang/en_US.lang b/resources/assets/hardcoreexpanded/lang/en_US.lang index 5469bab..d443d4d 100644 --- a/resources/assets/hardcoreexpanded/lang/en_US.lang +++ b/resources/assets/hardcoreexpanded/lang/en_US.lang @@ -1,2 +1,3 @@ item.heart_empty.name=Empty Heart -item.heart_full.name=Heart \ No newline at end of file +item.heart_full.name=Heart +tile.ghost_altar.name=Ghost Altar \ No newline at end of file diff --git a/resources/mcmod.info b/resources/mcmod.info index 6a3b450..bd3e22d 100644 --- a/resources/mcmod.info +++ b/resources/mcmod.info @@ -7,7 +7,7 @@ "mcversion": "${mcversion}", "url": "", "updateUrl": "", - "authorList": ["TheWerty1124"], + "authorList": ["TheWerty1124", "actioninja"], "credits": "Based partially on the mods by RebelKeithy and Phineas", "logoFile": "", "screenshots": [], diff --git a/version.txt b/version.txt index e6ddcc4..f53535b 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -version=1.8.0-1.1.0 +version=1.10.0-1.1.0