2
1
Fork 1
mirror of https://github.com/ACGaming/Spackenmobs synced 2024-06-11 15:08:56 +02:00

Re-add old creeper code to please tilera

This commit is contained in:
ACGaming 2020-10-15 21:15:53 +02:00
parent 3677969083
commit e22ee7dafb
8 changed files with 278 additions and 38 deletions

View file

@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
version = "RC5" version = "RC6"
group = "mod.acgaming.spackenmobs" // http://maven.apache.org/guides/mini/guide-naming-conventions.html group = "mod.acgaming.spackenmobs" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Spackenmobs-1.12.2" archivesBaseName = "Spackenmobs-1.12.2"

View file

@ -11,11 +11,11 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@Mod(modid = "spackenmobs", version = "RC5", acceptedMinecraftVersions = "[1.12.2]") @Mod(modid = "spackenmobs", version = "RC6", acceptedMinecraftVersions = "[1.12.2]")
public class Spackenmobs public class Spackenmobs
{ {
public static final String MODID = "spackenmobs"; public static final String MODID = "spackenmobs";
public static final String VERSION = "RC5"; public static final String VERSION = "RC6";
public static final CreativeTabs SPACKENMOBS_TAB = new SpackenmobsTab(); public static final CreativeTabs SPACKENMOBS_TAB = new SpackenmobsTab();

View file

@ -1,25 +1,216 @@
package mod.acgaming.spackenmobs.entities; package mod.acgaming.spackenmobs.entities;
import mod.acgaming.spackenmobs.misc.ModSoundEvents; import mod.acgaming.spackenmobs.misc.ModSoundEvents;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAreaEffectCloud;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.Collection;
public class EntityBakaMitaiCreeper extends EntityCreeper public class EntityBakaMitaiCreeper extends EntityCreeper
{ {
private static final DataParameter<Integer> STATE = EntityDataManager.createKey(EntityBakaMitaiCreeper.class, DataSerializers.VARINT);
private static final DataParameter<Boolean> POWERED = EntityDataManager.createKey(EntityBakaMitaiCreeper.class, DataSerializers.BOOLEAN);
private static final DataParameter<Boolean> IGNITED = EntityDataManager.createKey(EntityBakaMitaiCreeper.class, DataSerializers.BOOLEAN);
private int lastActiveTime; private int lastActiveTime;
private int timeSinceIgnited; private int timeSinceIgnited;
private int fuseTime; private int fuseTime = 100;
private int explosionRadius; private int explosionRadius = 12;
private int droppedSkulls;
public EntityBakaMitaiCreeper(World worldIn) public EntityBakaMitaiCreeper(World worldIn)
{ {
super(worldIn); super(worldIn);
this.setSize(0.6F, 1.7F); this.setSize(0.6F, 1.7F);
this.fuseTime = 100; }
this.explosionRadius = 12;
@Override
public boolean ableToCauseSkullDrop()
{
return this.droppedSkulls < 1 && this.world.getGameRules().getBoolean("doMobLoot");
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
}
@Override
public boolean attackEntityAsMob(Entity entityIn)
{
return true;
}
@Override
protected void entityInit()
{
super.entityInit();
this.dataManager.register(STATE, -1);
this.dataManager.register(POWERED, false);
this.dataManager.register(IGNITED, false);
}
private void explode()
{
if (!this.world.isRemote)
{
boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this);
float f = this.getPowered() ? 2.0F : 1.0F;
this.dead = true;
this.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_BAKAMITAICREEPER_BLOW, getSoundCategory(), 1.0F, 1.0F);
this.world.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius * f, flag);
this.setDead();
this.spawnLingeringCloud();
}
}
@Override
public void fall(float distance, float damageMultiplier)
{
super.fall(distance, damageMultiplier);
this.timeSinceIgnited = (int) (this.timeSinceIgnited + distance * 1.5F);
if (this.timeSinceIgnited > this.fuseTime - 5)
{
this.timeSinceIgnited = this.fuseTime - 5;
}
}
@Override
@SideOnly(Side.CLIENT)
public float getCreeperFlashIntensity(float p_70831_1_)
{
return (this.lastActiveTime + (this.timeSinceIgnited - this.lastActiveTime) * p_70831_1_) / (this.fuseTime - 2);
}
@Override
public int getCreeperState()
{
return this.dataManager.get(STATE);
}
@Override
public void setCreeperState(int state)
{
this.dataManager.set(STATE, state);
}
@Override
protected SoundEvent getDeathSound()
{
return SoundEvents.ENTITY_CREEPER_DEATH;
}
@Override
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
{
return SoundEvents.ENTITY_CREEPER_HURT;
}
@Override
@Nullable
protected ResourceLocation getLootTable()
{
return LootTableList.ENTITIES_CREEPER;
}
@Override
public int getMaxFallHeight()
{
return this.getAttackTarget() == null ? 3 : 3 + (int) (this.getHealth() - 1.0F);
}
@Override
public boolean getPowered()
{
return this.dataManager.get(POWERED);
}
@Override
public boolean hasIgnited()
{
return this.dataManager.get(IGNITED);
}
@Override
public void ignite()
{
this.dataManager.set(IGNITED, true);
}
@Override
public void incrementDroppedSkulls()
{
++this.droppedSkulls;
}
@Override
protected void initEntityAI()
{
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAICreeperSwell(this));
this.tasks.addTask(3, new EntityAIAvoidEntity<>(this, EntityOcelot.class, 6.0F, 1.0D, 1.2D));
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 0.8D));
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(6, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
}
@Override
public void onDeath(DamageSource cause)
{
super.onDeath(cause);
if (this.world.getGameRules().getBoolean("doMobLoot"))
{
if (cause.getTrueSource() instanceof EntitySkeleton)
{
int i = Item.getIdFromItem(Items.RECORD_13);
int j = Item.getIdFromItem(Items.RECORD_WAIT);
int k = i + this.rand.nextInt(j - i + 1);
this.dropItem(Item.getItemById(k), 1);
} else if (cause.getTrueSource() instanceof EntityBakaMitaiCreeper && cause.getTrueSource() != this && ((EntityBakaMitaiCreeper) cause.getTrueSource()).getPowered()
&& ((EntityBakaMitaiCreeper) cause.getTrueSource()).ableToCauseSkullDrop())
{
((EntityBakaMitaiCreeper) cause.getTrueSource()).incrementDroppedSkulls();
this.entityDropItem(new ItemStack(Items.SKULL, 1, 4), 0.0F);
}
}
}
@Override
public void onStruckByLightning(EntityLightningBolt lightningBolt)
{
super.onStruckByLightning(lightningBolt);
this.dataManager.set(POWERED, true);
} }
@Override @Override
@ -58,28 +249,83 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
super.onUpdate(); super.onUpdate();
} }
private void explode() @Override
protected boolean processInteract(EntityPlayer player, EnumHand hand)
{ {
if (!this.world.isRemote) ItemStack itemstack = player.getHeldItem(hand);
if (itemstack.getItem() == Items.FLINT_AND_STEEL)
{ {
boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this); this.world.playSound(player, this.posX, this.posY, this.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
float f = this.getPowered() ? 2.0F : 1.0F; player.swingArm(hand);
this.dead = true;
this.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_BAKAMITAICREEPER_BLOW, getSoundCategory(), 1.0F, 1.0F); if (!this.world.isRemote)
this.world.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius * f, flag); {
this.setDead(); this.ignite();
itemstack.damageItem(1, player);
return true;
}
}
return super.processInteract(player, hand);
}
@Override
public void readEntityFromNBT(NBTTagCompound compound)
{
super.readEntityFromNBT(compound);
this.dataManager.set(POWERED, compound.getBoolean("powered"));
if (compound.hasKey("Fuse", 99))
{
this.fuseTime = compound.getShort("Fuse");
}
if (compound.hasKey("ExplosionRadius", 99))
{
this.explosionRadius = compound.getByte("ExplosionRadius");
}
if (compound.getBoolean("ignited"))
{
this.ignite();
}
}
private void spawnLingeringCloud()
{
Collection<PotionEffect> collection = this.getActivePotionEffects();
if (!collection.isEmpty())
{
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ);
entityareaeffectcloud.setRadius(2.5F);
entityareaeffectcloud.setRadiusOnUse(-0.5F);
entityareaeffectcloud.setWaitTime(10);
entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration() / 2);
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / entityareaeffectcloud.getDuration());
for (PotionEffect potioneffect : collection)
{
entityareaeffectcloud.addEffect(new PotionEffect(potioneffect));
}
this.world.spawnEntity(entityareaeffectcloud);
} }
} }
@Override @Override
protected SoundEvent getDeathSound() public void writeEntityToNBT(NBTTagCompound compound)
{ {
return SoundEvents.ENTITY_CREEPER_DEATH; super.writeEntityToNBT(compound);
}
@Override if (this.dataManager.get(POWERED))
protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
{ compound.setBoolean("powered", true);
return SoundEvents.ENTITY_CREEPER_HURT; }
compound.setShort("Fuse", (short) this.fuseTime);
compound.setByte("ExplosionRadius", (byte) this.explosionRadius);
compound.setBoolean("ignited", this.hasIgnited());
} }
} }

View file

@ -8,17 +8,15 @@ import net.minecraft.world.World;
public class EntityIslamist extends EntityCreeper public class EntityIslamist extends EntityCreeper
{ {
private final int fuseTime = 30;
private final int explosionRadius = 6;
private int lastActiveTime; private int lastActiveTime;
private int timeSinceIgnited; private int timeSinceIgnited;
private int fuseTime;
private int explosionRadius;
public EntityIslamist(World worldIn) public EntityIslamist(World worldIn)
{ {
super(worldIn); super(worldIn);
this.setSize(0.6F, 1.7F); this.setSize(0.6F, 1.7F);
this.fuseTime = 30;
this.explosionRadius = 6;
} }
@Override @Override

View file

@ -9,18 +9,16 @@ import net.minecraft.world.World;
public class EntitySmavaCreeper extends EntityCreeper public class EntitySmavaCreeper extends EntityCreeper
{ {
private final int fuseTime = 20;
private final int explosionRadius = 6;
private int lastActiveTime; private int lastActiveTime;
private int timeSinceIgnited; private int timeSinceIgnited;
private int fuseTime;
private int explosionRadius;
public EntitySmavaCreeper(World worldIn) public EntitySmavaCreeper(World worldIn)
{ {
super(worldIn); super(worldIn);
this.setSize(0.6F, 1.7F); setSize(0.6F, 1.7F);
this.fuseTime = 20; getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D);
this.explosionRadius = 6;
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D);
} }
@Override @Override

View file

@ -43,11 +43,11 @@ public class ModConfigs
@Name("ApoRed max group size:") @Name("ApoRed max group size:")
public static int ApoRed_max = 4; public static int ApoRed_max = 4;
@Name("Baka Mitai Creeper spawn probability:") @Name("Baka Mitai Creeper spawn probability:")
public static int BakaMitaiCreeper_weight = 0; public static int BakaMitaiCreeper_weight = 10;
@Name("Baka Mitai Creeper min group size:") @Name("Baka Mitai Creeper min group size:")
public static int BakaMitaiCreeper_min = 0; public static int BakaMitaiCreeper_min = 1;
@Name("Baka Mitai Creeper max group size:") @Name("Baka Mitai Creeper max group size:")
public static int BakaMitaiCreeper_max = 0; public static int BakaMitaiCreeper_max = 2;
@Name("Drachenlord spawn probability:") @Name("Drachenlord spawn probability:")
public static int Drachenlord_weight = 20; public static int Drachenlord_weight = 20;
@Name("Drachenlord min group size:") @Name("Drachenlord min group size:")

View file

@ -3,7 +3,7 @@
"modid": "spackenmobs", "modid": "spackenmobs",
"name": "Spackenmobs", "name": "Spackenmobs",
"description": "The most important mobs in the history of Minecraft! [citation needed]", "description": "The most important mobs in the history of Minecraft! [citation needed]",
"version": "RC5", "version": "RC6",
"mcversion": "1.12.2", "mcversion": "1.12.2",
"url": "https://github.com/ACGaming/Spackenmobs", "url": "https://github.com/ACGaming/Spackenmobs",
"updateUrl": "", "updateUrl": "",

View file

@ -1,2 +0,0 @@
public net.minecraft.entity.monster.EntityCreeper field_82225_f # fuseTime
public net.minecraft.entity.monster.EntityCreeper field_82226_g # explosionRadius