Skip to content

Commit

Permalink
Various Patches
Browse files Browse the repository at this point in the history
Fixed Issues with spawning dictionary
Fixed Tile entities not saving correctly
Refactored spawning code
  • Loading branch information
DoctorWiggles authored Nov 11, 2016
2 parents e13be4e + d43072b commit 7d7194a
Show file tree
Hide file tree
Showing 40 changed files with 1,526 additions and 1,084 deletions.
7 changes: 7 additions & 0 deletions src/main/java/gaia/ConfigGaia.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,12 @@ public class ConfigGaia {
public static int Tier2attackDamage = 100;
public static int Tier3maxHealth = 100;
public static int Tier3attackDamage = 100;

public static boolean BaseDamage = true;
public static boolean ShieldsBlockPiercing = true;
public static boolean HardmodeArchers = true;

public static boolean Spawn_Debug_Mode = false;
public static boolean Debug_Commands = true;
public static boolean Biome_Tweaks = true;
}
43 changes: 29 additions & 14 deletions src/main/java/gaia/Gaia.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package gaia;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import gaia.entity.EntityMobAssist;
import gaia.entity.EntityMobBase;
import gaia.init.Aspects_Entity;
import gaia.init.Aspects_Items;
import gaia.init.GaiaBlock;
Expand All @@ -12,19 +11,14 @@
import gaia.init.GaiaSpawning;
import gaia.init.Sounds;
import gaia.items.GaiaItemHandlerFuel;
import gaia.items.ItemGaiaSpawnEgg;
import gaia.proxy.ClientProxy;
import gaia.proxy.CommonProxy;
import gaia.util.Gaia_Commands;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
Expand All @@ -33,9 +27,13 @@
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Mod(
modid = GaiaReference.MOD_ID,
name = GaiaReference.MOD_NAME,
Expand Down Expand Up @@ -99,8 +97,6 @@ public void load(FMLInitializationEvent event) {

logger.info("Registering Entities");
GaiaEntity.register();
GaiaSpawning.register();
//TEMP_Spawning.register_spawn();

if(isThaumcraftEnabled){
logger.info("Registering Aspects");
Expand All @@ -112,6 +108,9 @@ public void load(FMLInitializationEvent event) {
proxy.registerRenders();

MinecraftForge.EVENT_BUS.register(this);

if(ConfigGaia.Biome_Tweaks)GaiaSpawning.Biome_Tweaks();

}

@EventHandler
Expand All @@ -125,7 +124,23 @@ public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
if (eventArgs.getModID().equals(GaiaReference.MOD_ID))
GaiaConfigGeneration.syncConfig();
}

/** Prevents vanilla mobs from spawning for testing **/
@SubscribeEvent
public void Gaia_Spawn_Debug(CheckSpawn e){
if(ConfigGaia.Spawn_Debug_Mode){
if(e.getEntity() instanceof EntityMobAssist ||
e.getEntity() instanceof EntityMobBase){
e.setResult(Event.Result.ALLOW);
}
else{
e.setResult(Event.Result.DENY);
}
}
}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {}
public void postInit(FMLPostInitializationEvent event) {
//Moved Spawning registry to last since forge doesn't auto-generate sub "M' biomes until late
GaiaSpawning.register();
}
}
2 changes: 1 addition & 1 deletion src/main/java/gaia/GaiaReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class GaiaReference {
public static final String MOD_ID = "grimoireofgaia";
public static final String MOD_NAME = "Grimoire of Gaia 3";
public static final String VERSION = "1.0.0";
public static final String VERSION = "1.4.2B";
public static final String CLIENT_PROXY_CLASS = "gaia.proxy.ClientProxy";
public static final String SERVER_PROXY_CLASS = "gaia.proxy.CommonProxy";
public static final String guiFactory = "gaia.init.Config_GuiFactory";
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/gaia/block/BlockBustSphinx.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

Expand Down Expand Up @@ -61,6 +63,9 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity
TileEntityBustSphinx tile = (TileEntityBustSphinx)world.getTileEntity(pos);
tile.direction = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
}
int thing = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
String thingy = "" + thing;
entity.addChatMessage(new TextComponentTranslation(TextFormatting.RED + thingy));
}

public Block setBlockTextureName(String string) {
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/gaia/entity/EntityMobAssistBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.math.MathHelper;
Expand All @@ -18,10 +21,21 @@ public EntityMobAssistBase(World par1World) {
super(par1World);
}

public boolean attackEntityAsMob(Entity par1Entity) {
if (super.attackEntityAsMob(par1Entity)) {
public boolean attackEntityAsMob(Entity entity) {
if (super.attackEntityAsMob(entity)) {
if (ConfigGaia.BaseDamage) {
((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 2, 0));

//TODO Rebalance tweaking for shields
//Shields aren't so fun when they can't block most of the damage
if(entity instanceof EntityPlayer && ConfigGaia.ShieldsBlockPiercing){
EntityPlayer player = (EntityPlayer) entity;
ItemStack itemstack = player.isHandActive() ? player.getActiveItemStack() : null;
if(itemstack != null && itemstack.getItem() == Items.SHIELD){
return true;
}
}

((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 2, 0));
}
return true;
} else {
Expand All @@ -36,7 +50,7 @@ public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1iEntityLivingData)
/**
* Used to adjust the motionY when a mob is hit.
*/
public void knockBack(Entity par1Entity, float par2, double par3, double par5, double par6) {
public void knockBack(Entity entity, float par2, double par3, double par5, double par6) {
if (this.rand.nextDouble() >= this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).getAttributeValue()) {
this.isAirBorne = true;
float f1 = MathHelper.sqrt_double(par3 * par3 + par5 * par5);
Expand Down
26 changes: 19 additions & 7 deletions src/main/java/gaia/entity/EntityMobBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.math.MathHelper;
Expand All @@ -18,10 +21,19 @@ public EntityMobBase(World par1World) {
super(par1World);
}

public boolean attackEntityAsMob(Entity par1Entity) {
if (super.attackEntityAsMob(par1Entity)) {
public boolean attackEntityAsMob(Entity entity) {
if (super.attackEntityAsMob(entity)) {
//TODO Rebalance tweaking for shields
//Shields aren't so fun when they can't block most of the damage
if (ConfigGaia.BaseDamage) {
((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 2, 0));
if(entity instanceof EntityPlayer && ConfigGaia.ShieldsBlockPiercing){
EntityPlayer player = (EntityPlayer) entity;
ItemStack itemstack = player.isHandActive() ? player.getActiveItemStack() : null;
if(itemstack != null && itemstack.getItem() == Items.SHIELD){
return true;
}
}
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 2, 0));
}
return true;
} else {
Expand All @@ -36,7 +48,7 @@ public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1iEntityLivingData)
/**
* Used to adjust the motionY when a mob is hit.
*/
public void knockBack(Entity par1Entity, float par2, double par3, double par5, double par6) {
public void knockBack(Entity entity, float par2, double par3, double par5, double par6) {
if (this.rand.nextDouble() >= this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).getAttributeValue()) {
this.isAirBorne = true;
float f1 = MathHelper.sqrt_double(par3 * par3 + par5 * par5);
Expand All @@ -55,10 +67,10 @@ public void knockBack(Entity par1Entity, float par2, double par3, double par5, d

//TODO Custom Damage Source which includes the name of the monster
/*
public boolean attackEntityAsMob(Entity par1Entity) {
if (super.attackEntityAsMob(par1Entity)) {
public boolean attackEntityAsMob(Entity entity) {
if (super.attackEntityAsMob(entity)) {
if (ConfigGaia.BaseDamage) {
((EntityLivingBase)par1Entity).attackEntityFrom(CustomDamageSource.pierce, 2.0F);
((EntityLivingBase)entity).attackEntityFrom(CustomDamageSource.pierce, 2.0F);
}
return true;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gaia.entity.ai;

import gaia.ConfigGaia;
import gaia.entity.projectile.EntityGaiaProjectileSmallFireball;

import java.util.Random;
Expand All @@ -24,7 +25,7 @@
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.World;

public class ArrowGen {
public class Archers {

/**Shortcut Method for Entities attacking with bows,
* Grafted from skeleton codebase
Expand Down Expand Up @@ -52,7 +53,7 @@ public static void RangedAttack(EntityLivingBase target, EntityLivingBase host,
//TODO buffs to archers
//Gaia archers have always been a tad weak, and with shields they're almost trivial foes
//This will of course need delicate tweaking and balance
if(host.worldObj.getDifficulty().getDifficultyId()==3){
if(host.worldObj.getDifficulty().getDifficultyId()==3 && ConfigGaia.HardmodeArchers){
entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 20, 1));
entitytippedarrow.addEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 1, 0));
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/gaia/entity/monster/EntityGaiaAnubis.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLi
this.setEnchantmentBasedOnDifficulty(difficulty);
return livingdata;
}

//TODO check itemstackslot

public void setItemStackToSlot(EntityEquipmentSlot par1, ItemStack par2ItemStack) {
super.setItemStackToSlot(par1, par2ItemStack);
if (!this.worldObj.isRemote && par1.getIndex() == 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gaia/entity/monster/EntityGaiaBaphomet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import gaia.entity.EntityAttributes;
import gaia.entity.EntityMobBase;
import gaia.entity.ai.ArrowGen;
import gaia.entity.ai.Archers;
import gaia.entity.ai.EntityAIGaiaAttackOnCollide;
import gaia.init.GaiaItem;
import gaia.init.Sounds;
Expand Down Expand Up @@ -71,7 +71,7 @@ public int getTotalArmorValue() {
}

public void attackEntityWithRangedAttack(EntityLivingBase target, float par2) {
ArrowGen.fireball(target, this, par2);
Archers.fireball(target, this, par2);
}

public boolean attackEntityAsMob(Entity par1Entity) {
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/gaia/entity/monster/EntityGaiaCentaur.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import gaia.entity.EntityAttributes;
import gaia.entity.EntityMobAssistDay;
import gaia.entity.ai.ArrowGen;
import gaia.entity.ai.Archers;
import gaia.init.GaiaItem;
import gaia.init.Sounds;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -72,7 +72,7 @@ public int getTotalArmorValue() {
}
/**TODO Arrow attacks may need to be completely redone **/
public void attackEntityWithRangedAttack(EntityLivingBase target, float par2) {
ArrowGen.RangedAttack(target, this, par2);
Archers.RangedAttack(target, this, par2);
}

@Override
Expand Down Expand Up @@ -166,14 +166,7 @@ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLi
this.setEnchantmentBasedOnDifficulty(difficulty);
return livingdata;
}
/** TODO check setcurrentItemorArmor Lines
public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) {
super.setCurrentItemOrArmor(par1, par2ItemStack);
if (!this.worldObj.isRemote && par1 == 0) {
this.setCombatTask();
}
}
**/

public void setItemStackToSlot(EntityEquipmentSlot par1, ItemStack par2ItemStack) {
super.setItemStackToSlot(par1, par2ItemStack);
if (!this.worldObj.isRemote && par1.getIndex() == 0) {
Expand Down
39 changes: 12 additions & 27 deletions src/main/java/gaia/entity/monster/EntityGaiaCobbleGolem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gaia.entity.monster;

import gaia.ConfigGaia;
import gaia.entity.EntityAttributes;
import gaia.entity.EntityMobAssistDay;
import gaia.entity.EntityMobDay;
Expand All @@ -20,6 +21,8 @@
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.potion.Potion;
Expand Down Expand Up @@ -95,39 +98,21 @@ public int getHoldRoseTick() {
return this.holdRoseTick;
}

public boolean attackEntityFrom(DamageSource par1DamageSource, float damage) {
//TODO Re-look golem pickaxe bonus damage
Entity entity = par1DamageSource.getEntity();
public boolean attackEntityFrom(DamageSource DamageSource, float inputDamage) {
float input = inputDamage;
Entity entity = DamageSource.getEntity();

if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
ItemStack itemstack = player.getActiveItemStack();
ItemStack itemstack = player.getHeldItem(getActiveHand());
if (itemstack != null) {
Item item = itemstack.getItem();
if (item != null) {
if (item == Items.WOODEN_PICKAXE) {
damage = 6.0F;
}

if (item == Items.STONE_PICKAXE) {
damage = 7.0F;
}

if (item == Items.IRON_PICKAXE) {
damage = 8.0F;
}

if (item == Items.GOLDEN_PICKAXE) {
damage = 6.0F;
}

if (item == Items.DIAMOND_PICKAXE) {
damage = 9.0F;
}

if (itemstack.getItem() instanceof ItemPickaxe) {
inputDamage = input+5;
}
}
}

return super.attackEntityFrom(par1DamageSource, damage);
return super.attackEntityFrom(DamageSource, (float) inputDamage);
}

public boolean isAIEnabled() {
Expand Down
Loading

0 comments on commit 7d7194a

Please sign in to comment.