Added the initial body of the Corrupted sheep, as well as the rendering. Moved most of the aspected demon stuff to a new base class.
This commit is contained in:
parent
f900fef846
commit
7b55293a40
|
@ -0,0 +1,15 @@
|
|||
package WayofTime.bloodmagic.client.render.entity;
|
||||
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
|
||||
public class CorruptedSheepRenderFactory implements IRenderFactory<EntityCorruptedSheep>
|
||||
{
|
||||
@Override
|
||||
public Render<? super EntityCorruptedSheep> createRenderFor(RenderManager manager)
|
||||
{
|
||||
return new RenderCorruptedSheep(manager);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package WayofTime.bloodmagic.client.render.entity;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.client.render.entity.layer.LayerCorruptedSheepWool;
|
||||
import WayofTime.bloodmagic.client.render.entity.layer.LayerWill;
|
||||
import WayofTime.bloodmagic.client.render.model.ModelCorruptedSheep;
|
||||
import WayofTime.bloodmagic.client.render.model.ModelCorruptedSheep2;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderCorruptedSheep extends RenderLiving<EntityCorruptedSheep>
|
||||
{
|
||||
private static final ResourceLocation SHEARED_SHEEP_TEXTURES = new ResourceLocation("textures/entity/sheep/sheep.png");
|
||||
|
||||
public RenderCorruptedSheep(RenderManager renderManagerIn)
|
||||
{
|
||||
super(renderManagerIn, new ModelCorruptedSheep2(0), 0.7F);
|
||||
this.addLayer(new LayerCorruptedSheepWool(this));
|
||||
this.addLayer(new LayerWill<EntityCorruptedSheep>(this, new ModelCorruptedSheep(1.1f)));
|
||||
this.addLayer(new LayerWill<EntityCorruptedSheep>(this, new ModelCorruptedSheep2(1.1f)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntityCorruptedSheep entity)
|
||||
{
|
||||
return SHEARED_SHEEP_TEXTURES;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package WayofTime.bloodmagic.client.render.entity;
|
||||
|
||||
import net.minecraft.client.model.ModelCreeper;
|
||||
import net.minecraft.client.model.ModelZombie;
|
||||
import net.minecraft.client.model.ModelZombieVillager;
|
||||
import net.minecraft.client.renderer.entity.RenderBiped;
|
||||
|
@ -18,7 +17,7 @@ import WayofTime.bloodmagic.entity.mob.EntityCorruptedZombie;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class RenderCorruptedZombie extends RenderBiped<EntityCorruptedZombie>
|
||||
{
|
||||
private static final ResourceLocation ZOMBIE_TEXTURES = new ResourceLocation("bloodmagic", "textures/entities/zombie_raw.png");
|
||||
private static final ResourceLocation ZOMBIE_TEXTURES = new ResourceLocation("textures/entity/zombie/zombie.png");
|
||||
private final ModelZombieVillager zombieVillagerModel;
|
||||
|
||||
public RenderCorruptedZombie(RenderManager renderManagerIn)
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package WayofTime.bloodmagic.client.render.entity.layer;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.client.render.entity.RenderCorruptedSheep;
|
||||
import WayofTime.bloodmagic.client.render.model.ModelCorruptedSheep;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class LayerCorruptedSheepWool implements LayerRenderer<EntityCorruptedSheep>
|
||||
{
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("textures/entity/sheep/sheep_fur.png");
|
||||
private final RenderCorruptedSheep sheepRenderer;
|
||||
private final ModelCorruptedSheep sheepModel = new ModelCorruptedSheep(1);
|
||||
|
||||
public LayerCorruptedSheepWool(RenderCorruptedSheep renderCorruptedSheep)
|
||||
{
|
||||
this.sheepRenderer = renderCorruptedSheep;
|
||||
}
|
||||
|
||||
public void doRenderLayer(EntityCorruptedSheep entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
|
||||
{
|
||||
if (!entitylivingbaseIn.getSheared() && !entitylivingbaseIn.isInvisible())
|
||||
{
|
||||
this.sheepRenderer.bindTexture(TEXTURE);
|
||||
|
||||
if (entitylivingbaseIn.hasCustomName() && "jeb_".equals(entitylivingbaseIn.getCustomNameTag()))
|
||||
{
|
||||
int i1 = 25;
|
||||
int i = entitylivingbaseIn.ticksExisted / 25 + entitylivingbaseIn.getEntityId();
|
||||
int j = EnumDyeColor.values().length;
|
||||
int k = i % j;
|
||||
int l = (i + 1) % j;
|
||||
float f = ((float) (entitylivingbaseIn.ticksExisted % 25) + partialTicks) / 25.0F;
|
||||
float[] afloat1 = EntityCorruptedSheep.getDyeRgb(EnumDyeColor.byMetadata(k));
|
||||
float[] afloat2 = EntityCorruptedSheep.getDyeRgb(EnumDyeColor.byMetadata(l));
|
||||
GlStateManager.color(afloat1[0] * (1.0F - f) + afloat2[0] * f, afloat1[1] * (1.0F - f) + afloat2[1] * f, afloat1[2] * (1.0F - f) + afloat2[2] * f);
|
||||
} else
|
||||
{
|
||||
float[] afloat = EntityCorruptedSheep.getDyeRgb(entitylivingbaseIn.getFleeceColor());
|
||||
GlStateManager.color(afloat[0], afloat[1], afloat[2]);
|
||||
}
|
||||
|
||||
this.sheepModel.setModelAttributes(this.sheepRenderer.getMainModel());
|
||||
this.sheepModel.setLivingAnimations(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks);
|
||||
this.sheepModel.render(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldCombineTextures()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ package WayofTime.bloodmagic.client.render.entity.layer;
|
|||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerCreeperCharge;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -13,7 +12,7 @@ import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class LayerWill<T extends EntityDemonBase> implements LayerRenderer<T>
|
||||
{
|
||||
private static final ResourceLocation LIGHTNING_TEXTURE = new ResourceLocation("bloodmagic", "textures/entities/overlay/overlay_raw.png");
|
||||
private static final ResourceLocation RAW_TEXTURE = new ResourceLocation("bloodmagic", "textures/entities/overlay/overlay_raw.png");
|
||||
private final RenderLiving<T> renderer;
|
||||
private final ModelBase model;
|
||||
|
||||
|
@ -24,34 +23,34 @@ public class LayerWill<T extends EntityDemonBase> implements LayerRenderer<T>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doRenderLayer(EntityDemonBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
|
||||
public void doRenderLayer(EntityDemonBase demon, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
|
||||
{
|
||||
// if (entitylivingbaseIn.getPowered())
|
||||
{
|
||||
boolean flag = entitylivingbaseIn.isInvisible();
|
||||
GlStateManager.depthMask(!flag);
|
||||
this.renderer.bindTexture(LIGHTNING_TEXTURE);
|
||||
GlStateManager.matrixMode(5890);
|
||||
GlStateManager.loadIdentity();
|
||||
float f = (float) entitylivingbaseIn.ticksExisted + partialTicks;
|
||||
GlStateManager.translate(f * 0.01F, f * 0.01F, 0.0F);
|
||||
GlStateManager.matrixMode(5888);
|
||||
GlStateManager.enableBlend();
|
||||
float f1 = 0.5F;
|
||||
GlStateManager.color(0.5F, 0.5F, 0.5F, 1.0F);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
|
||||
this.model.setModelAttributes(this.renderer.getMainModel());
|
||||
this.model.render(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
||||
GlStateManager.matrixMode(5890);
|
||||
GlStateManager.loadIdentity();
|
||||
GlStateManager.matrixMode(5888);
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.depthMask(flag);
|
||||
}
|
||||
// if (demon.getPowered())
|
||||
|
||||
boolean flag = demon.isInvisible();
|
||||
GlStateManager.depthMask(!flag);
|
||||
this.renderer.bindTexture(RAW_TEXTURE);
|
||||
GlStateManager.matrixMode(5890);
|
||||
GlStateManager.loadIdentity();
|
||||
float f = (float) demon.ticksExisted + partialTicks;
|
||||
GlStateManager.translate(f * 0.01F, f * 0.01F, 0.0F);
|
||||
GlStateManager.matrixMode(5888);
|
||||
GlStateManager.enableBlend();
|
||||
float f1 = 0.5F;
|
||||
GlStateManager.color(f1, f1, f1, 1.0F);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
|
||||
this.model.setModelAttributes(this.renderer.getMainModel());
|
||||
this.model.render(demon, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
||||
GlStateManager.matrixMode(5890);
|
||||
GlStateManager.loadIdentity();
|
||||
GlStateManager.matrixMode(5888);
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.depthMask(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombineTextures()
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package WayofTime.bloodmagic.client.render.model;
|
||||
|
||||
import net.minecraft.client.model.ModelQuadruped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelCorruptedSheep extends ModelQuadruped
|
||||
{
|
||||
private float headRotationAngleX;
|
||||
|
||||
public ModelCorruptedSheep(float scale)
|
||||
{
|
||||
super(12, scale);
|
||||
this.head = new ModelRenderer(this, 0, 0);
|
||||
this.head.addBox(-3.0F, -4.0F, -4.0F, 6, 6, 6, 0.6F * scale);
|
||||
this.head.setRotationPoint(0.0F, 6.0F, -8.0F);
|
||||
this.body = new ModelRenderer(this, 28, 8);
|
||||
this.body.addBox(-4.0F, -10.0F, -7.0F, 8, 16, 6, 1.75F * scale);
|
||||
this.body.setRotationPoint(0.0F, 5.0F, 2.0F);
|
||||
float f = 0.5F;
|
||||
this.leg1 = new ModelRenderer(this, 0, 16);
|
||||
this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F * scale);
|
||||
this.leg1.setRotationPoint(-3.0F, 12.0F, 7.0F);
|
||||
this.leg2 = new ModelRenderer(this, 0, 16);
|
||||
this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F * scale);
|
||||
this.leg2.setRotationPoint(3.0F, 12.0F, 7.0F);
|
||||
this.leg3 = new ModelRenderer(this, 0, 16);
|
||||
this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F * scale);
|
||||
this.leg3.setRotationPoint(-3.0F, 12.0F, -5.0F);
|
||||
this.leg4 = new ModelRenderer(this, 0, 16);
|
||||
this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F * scale);
|
||||
this.leg4.setRotationPoint(3.0F, 12.0F, -5.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for easily adding entity-dependent animations. The second and third
|
||||
* float params here are the same second and third as in the
|
||||
* setRotationAngles method.
|
||||
*/
|
||||
public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime)
|
||||
{
|
||||
super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime);
|
||||
this.head.rotationPointY = 6.0F + ((EntityCorruptedSheep) entitylivingbaseIn).getHeadRotationPointY(partialTickTime) * 9.0F;
|
||||
this.headRotationAngleX = ((EntityCorruptedSheep) entitylivingbaseIn).getHeadRotationAngleX(partialTickTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the model's various rotation angles. For bipeds, par1 and par2 are
|
||||
* used for animating the movement of arms and legs, where par1 represents
|
||||
* the time(so that arms and legs swing back and forth) and par2 represents
|
||||
* how "far" arms and legs can swing at most.
|
||||
*/
|
||||
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
|
||||
{
|
||||
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
|
||||
this.head.rotateAngleX = this.headRotationAngleX;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package WayofTime.bloodmagic.client.render.model;
|
||||
|
||||
import net.minecraft.client.model.ModelQuadruped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelCorruptedSheep2 extends ModelQuadruped
|
||||
{
|
||||
private float headRotationAngleX;
|
||||
|
||||
public ModelCorruptedSheep2(float scale)
|
||||
{
|
||||
super(12, scale);
|
||||
this.head = new ModelRenderer(this, 0, 0);
|
||||
this.head.addBox(-3.0F, -4.0F, -6.0F, 6, 6, 8, scale);
|
||||
this.head.setRotationPoint(0.0F, 6.0F, -8.0F);
|
||||
this.body = new ModelRenderer(this, 28, 8);
|
||||
this.body.addBox(-4.0F, -10.0F, -7.0F, 8, 16, 6, scale);
|
||||
this.body.setRotationPoint(0.0F, 5.0F, 2.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for easily adding entity-dependent animations. The second and third
|
||||
* float params here are the same second and third as in the
|
||||
* setRotationAngles method.
|
||||
*/
|
||||
public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime)
|
||||
{
|
||||
super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime);
|
||||
this.head.rotationPointY = 6.0F + ((EntityCorruptedSheep) entitylivingbaseIn).getHeadRotationPointY(partialTickTime) * 9.0F;
|
||||
this.headRotationAngleX = ((EntityCorruptedSheep) entitylivingbaseIn).getHeadRotationAngleX(partialTickTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the model's various rotation angles. For bipeds, par1 and par2 are
|
||||
* used for animating the movement of arms and legs, where par1 represents
|
||||
* the time(so that arms and legs swing back and forth) and par2 represents
|
||||
* how "far" arms and legs can swing at most.
|
||||
*/
|
||||
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
|
||||
{
|
||||
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
|
||||
this.head.rotateAngleX = this.headRotationAngleX;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package WayofTime.bloodmagic.entity.mob;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.gson.Serializers;
|
||||
|
||||
public class EntityAspectedDemonBase extends EntityDemonBase
|
||||
{
|
||||
protected static final DataParameter<EnumDemonWillType> TYPE = EntityDataManager.<EnumDemonWillType>createKey(EntityAspectedDemonBase.class, Serializers.WILL_TYPE_SERIALIZER);
|
||||
|
||||
public EntityAspectedDemonBase(World worldIn)
|
||||
{
|
||||
super(worldIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit()
|
||||
{
|
||||
super.entityInit();
|
||||
this.dataManager.register(TYPE, EnumDemonWillType.DEFAULT);
|
||||
}
|
||||
|
||||
public EnumDemonWillType getType()
|
||||
{
|
||||
return this.dataManager.get(TYPE);
|
||||
}
|
||||
|
||||
public void setType(EnumDemonWillType type)
|
||||
{
|
||||
this.dataManager.set(TYPE, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeEntityToNBT(tag);
|
||||
|
||||
tag.setString(Constants.NBT.WILL_TYPE, this.getType().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readEntityFromNBT(tag);
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
setType(EnumDemonWillType.DEFAULT);
|
||||
} else
|
||||
{
|
||||
setType(EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,313 @@
|
|||
package WayofTime.bloodmagic.entity.mob;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.IEntityLivingData;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.EntityAIEatGrass;
|
||||
import net.minecraft.entity.ai.EntityAILookIdle;
|
||||
import net.minecraft.entity.ai.EntityAIPanic;
|
||||
import net.minecraft.entity.ai.EntityAISwimming;
|
||||
import net.minecraft.entity.ai.EntityAITempt;
|
||||
import net.minecraft.entity.ai.EntityAIWander;
|
||||
import net.minecraft.entity.ai.EntityAIWatchClosest;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
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.util.EnumHand;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public class EntityCorruptedSheep extends EntityAspectedDemonBase implements IShearable
|
||||
{
|
||||
private static final DataParameter<Byte> DYE_COLOR = EntityDataManager.<Byte>createKey(EntityCorruptedSheep.class, DataSerializers.BYTE);
|
||||
|
||||
private static final Map<EnumDyeColor, float[]> DYE_TO_RGB = Maps.newEnumMap(EnumDyeColor.class);
|
||||
/**
|
||||
* Used to control movement as well as wool regrowth. Set to 40 on
|
||||
* handleHealthUpdate and counts down with each tick.
|
||||
*/
|
||||
private int sheepTimer;
|
||||
private EntityAIEatGrass entityAIEatGrass; //TODO: Change to a new AI
|
||||
|
||||
public static float[] getDyeRgb(EnumDyeColor dyeColor)
|
||||
{
|
||||
return (float[]) DYE_TO_RGB.get(dyeColor);
|
||||
}
|
||||
|
||||
public EntityCorruptedSheep(World worldIn)
|
||||
{
|
||||
super(worldIn);
|
||||
this.setSize(0.9F, 1.3F);
|
||||
}
|
||||
|
||||
protected void initEntityAI()
|
||||
{
|
||||
this.entityAIEatGrass = new EntityAIEatGrass(this);
|
||||
this.tasks.addTask(0, new EntityAISwimming(this));
|
||||
this.tasks.addTask(1, new EntityAIPanic(this, 1.25D));
|
||||
this.tasks.addTask(3, new EntityAITempt(this, 1.1D, Items.WHEAT, false));
|
||||
this.tasks.addTask(5, this.entityAIEatGrass);
|
||||
this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
|
||||
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
|
||||
this.tasks.addTask(8, new EntityAILookIdle(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateAITasks()
|
||||
{
|
||||
this.sheepTimer = this.entityAIEatGrass.getEatingGrassTimer();
|
||||
super.updateAITasks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLivingUpdate()
|
||||
{
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
this.sheepTimer = Math.max(0, this.sheepTimer - 1);
|
||||
}
|
||||
|
||||
super.onLivingUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyEntityAttributes()
|
||||
{
|
||||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(8.0D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit()
|
||||
{
|
||||
super.entityInit();
|
||||
this.dataManager.register(DYE_COLOR, Byte.valueOf((byte) 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleStatusUpdate(byte id)
|
||||
{
|
||||
if (id == 10)
|
||||
{
|
||||
this.sheepTimer = 40;
|
||||
} else
|
||||
{
|
||||
super.handleStatusUpdate(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
//TODO: Add fun stuff for when interacted with - explode?
|
||||
public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack)
|
||||
{
|
||||
return super.processInteract(player, hand, stack);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getHeadRotationPointY(float partialTick)
|
||||
{
|
||||
return this.sheepTimer <= 0 ? 0.0F : (this.sheepTimer >= 4 && this.sheepTimer <= 36 ? 1.0F : (this.sheepTimer < 4 ? ((float) this.sheepTimer - partialTick) / 4.0F : -((float) (this.sheepTimer - 40) - partialTick) / 4.0F));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getHeadRotationAngleX(float partialTick)
|
||||
{
|
||||
if (this.sheepTimer > 4 && this.sheepTimer <= 36)
|
||||
{
|
||||
float f = ((float) (this.sheepTimer - 4) - partialTick) / 32.0F;
|
||||
return ((float) Math.PI / 5F) + ((float) Math.PI * 7F / 100F) * MathHelper.sin(f * 28.7F);
|
||||
} else
|
||||
{
|
||||
return this.sheepTimer > 0 ? ((float) Math.PI / 5F) : this.rotationPitch * 0.017453292F;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.writeEntityToNBT(compound);
|
||||
compound.setBoolean("Sheared", this.getSheared());
|
||||
compound.setByte("Color", (byte) this.getFleeceColor().getMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.readEntityFromNBT(compound);
|
||||
this.setSheared(compound.getBoolean("Sheared"));
|
||||
this.setFleeceColor(EnumDyeColor.byMetadata(compound.getByte("Color")));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getAmbientSound()
|
||||
{
|
||||
return SoundEvents.ENTITY_SHEEP_AMBIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getHurtSound()
|
||||
{
|
||||
return SoundEvents.ENTITY_SHEEP_HURT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getDeathSound()
|
||||
{
|
||||
return SoundEvents.ENTITY_SHEEP_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void playStepSound(BlockPos pos, Block blockIn)
|
||||
{
|
||||
this.playSound(SoundEvents.ENTITY_SHEEP_STEP, 0.15F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the wool color of this sheep.
|
||||
*/
|
||||
public EnumDyeColor getFleeceColor()
|
||||
{
|
||||
return EnumDyeColor.byMetadata(((Byte) this.dataManager.get(DYE_COLOR)).byteValue() & 15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the wool color of this sheep
|
||||
*/
|
||||
public void setFleeceColor(EnumDyeColor color)
|
||||
{
|
||||
byte b0 = ((Byte) this.dataManager.get(DYE_COLOR)).byteValue();
|
||||
this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 & 240 | color.getMetadata() & 15)));
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if a sheeps wool has been sheared
|
||||
*/
|
||||
public boolean getSheared()
|
||||
{
|
||||
return (((Byte) this.dataManager.get(DYE_COLOR)).byteValue() & 16) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* make a sheep sheared if set to true
|
||||
*/
|
||||
public void setSheared(boolean sheared)
|
||||
{
|
||||
byte b0 = ((Byte) this.dataManager.get(DYE_COLOR)).byteValue();
|
||||
|
||||
if (sheared)
|
||||
{
|
||||
this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 | 16)));
|
||||
} else
|
||||
{
|
||||
this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 & -17)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Chooses a "vanilla" sheep color based on the provided random.
|
||||
*/
|
||||
public static EnumDyeColor getRandomSheepColor(Random random)
|
||||
{
|
||||
int i = random.nextInt(100);
|
||||
return i < 5 ? EnumDyeColor.BLACK : (i < 10 ? EnumDyeColor.GRAY : (i < 15 ? EnumDyeColor.SILVER : (i < 18 ? EnumDyeColor.BROWN : (random.nextInt(500) == 0 ? EnumDyeColor.PINK : EnumDyeColor.WHITE))));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function applies the benefits of growing back wool and faster
|
||||
* growing up to the acting entity. (This function is used in the
|
||||
* AIEatGrass)
|
||||
*/
|
||||
@Override
|
||||
public void eatGrassBonus()
|
||||
{
|
||||
this.setSheared(false);
|
||||
|
||||
if (this.isChild())
|
||||
{
|
||||
//TODO: Heal
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called only once on an entity when first time spawned, via egg, mob
|
||||
* spawner, natural spawning etc, but not called when entity is reloaded
|
||||
* from nbt. Mainly used for initializing attributes and inventory
|
||||
*/
|
||||
@Override
|
||||
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
|
||||
{
|
||||
livingdata = super.onInitialSpawn(difficulty, livingdata);
|
||||
this.setFleeceColor(getRandomSheepColor(this.worldObj.rand));
|
||||
return livingdata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEyeHeight()
|
||||
{
|
||||
return 0.95F * this.height;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
DYE_TO_RGB.put(EnumDyeColor.WHITE, new float[] { 1.0F, 1.0F, 1.0F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.ORANGE, new float[] { 0.85F, 0.5F, 0.2F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.MAGENTA, new float[] { 0.7F, 0.3F, 0.85F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.LIGHT_BLUE, new float[] { 0.4F, 0.6F, 0.85F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.YELLOW, new float[] { 0.9F, 0.9F, 0.2F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.LIME, new float[] { 0.5F, 0.8F, 0.1F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.PINK, new float[] { 0.95F, 0.5F, 0.65F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.GRAY, new float[] { 0.3F, 0.3F, 0.3F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.SILVER, new float[] { 0.6F, 0.6F, 0.6F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.CYAN, new float[] { 0.3F, 0.5F, 0.6F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.PURPLE, new float[] { 0.5F, 0.25F, 0.7F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.BLUE, new float[] { 0.2F, 0.3F, 0.7F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.BROWN, new float[] { 0.4F, 0.3F, 0.2F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.GREEN, new float[] { 0.4F, 0.5F, 0.2F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.RED, new float[] { 0.6F, 0.2F, 0.2F });
|
||||
DYE_TO_RGB.put(EnumDyeColor.BLACK, new float[] { 0.1F, 0.1F, 0.1F });
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
return !this.getSheared() && !this.isChild();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
|
||||
{
|
||||
this.setSheared(true);
|
||||
int i = 1 + this.rand.nextInt(3);
|
||||
|
||||
java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
|
||||
for (int j = 0; j < i; ++j)
|
||||
ret.add(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, this.getFleeceColor().getMetadata()));
|
||||
|
||||
this.playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F);
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -1,34 +1,37 @@
|
|||
package WayofTime.bloodmagic.entity.mob;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.EntityAIAttackMelee;
|
||||
import net.minecraft.entity.ai.EntityAIHurtByTarget;
|
||||
import net.minecraft.entity.ai.EntityAILookIdle;
|
||||
import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
|
||||
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
|
||||
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
|
||||
import net.minecraft.entity.ai.EntityAISwimming;
|
||||
import net.minecraft.entity.ai.EntityAIWander;
|
||||
import net.minecraft.entity.ai.EntityAIWatchClosest;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntityIronGolem;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemBow;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow;
|
||||
|
||||
public class EntityCorruptedZombie extends EntityDemonBase
|
||||
public class EntityCorruptedZombie extends EntityAspectedDemonBase
|
||||
{
|
||||
@Getter
|
||||
@Setter
|
||||
protected EnumDemonWillType type = EnumDemonWillType.DEFAULT;
|
||||
|
||||
private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F);
|
||||
private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false);
|
||||
|
||||
|
@ -39,6 +42,18 @@ public class EntityCorruptedZombie extends EntityDemonBase
|
|||
super(worldIn);
|
||||
this.setSize(0.6F, 1.95F);
|
||||
// ((PathNavigateGround) getNavigator()).setCanSwim(false);
|
||||
this.tasks.addTask(0, new EntityAISwimming(this));
|
||||
this.tasks.addTask(attackPriority, aiAttackOnCollide);
|
||||
this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
|
||||
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
|
||||
this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
||||
this.tasks.addTask(8, new EntityAILookIdle(this));
|
||||
|
||||
this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
|
||||
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[] { EntityPigZombie.class }));
|
||||
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
|
||||
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityVillager.class, false));
|
||||
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));
|
||||
|
||||
this.setCombatTask();
|
||||
// this.targetTasks.addTask(8, new EntityAINearestAttackableTarget<EntityMob>(this, EntityMob.class, 10, true, false, new TargetPredicate(this)));
|
||||
|
@ -48,9 +63,11 @@ public class EntityCorruptedZombie extends EntityDemonBase
|
|||
protected void applyEntityAttributes()
|
||||
{
|
||||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D);
|
||||
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0D);
|
||||
getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D);
|
||||
getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.27D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(2.0D);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,30 +172,6 @@ public class EntityCorruptedZombie extends EntityDemonBase
|
|||
super.onUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeEntityToNBT(tag);
|
||||
|
||||
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readEntityFromNBT(tag);
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
type = EnumDemonWillType.DEFAULT;
|
||||
} else
|
||||
{
|
||||
type = EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE));
|
||||
}
|
||||
|
||||
this.setCombatTask();
|
||||
}
|
||||
|
||||
//TODO: Change to fit the given AI
|
||||
@Override
|
||||
public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner)
|
||||
|
@ -192,28 +185,34 @@ public class EntityCorruptedZombie extends EntityDemonBase
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getSoundPitch()
|
||||
{
|
||||
return super.getSoundPitch() * 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getAmbientSound()
|
||||
{
|
||||
return SoundEvents.ENTITY_COW_AMBIENT;
|
||||
return SoundEvents.ENTITY_ZOMBIE_AMBIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getHurtSound()
|
||||
{
|
||||
return SoundEvents.ENTITY_COW_HURT;
|
||||
return SoundEvents.ENTITY_ZOMBIE_HURT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getDeathSound()
|
||||
{
|
||||
return SoundEvents.ENTITY_COW_DEATH;
|
||||
return SoundEvents.ENTITY_ZOMBIE_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void playStepSound(BlockPos pos, Block block)
|
||||
{
|
||||
this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F);
|
||||
this.playSound(SoundEvents.ENTITY_ZOMBIE_STEP, 0.15F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.minecraft.entity.monster.EntityCreeper;
|
|||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
|
@ -40,8 +39,8 @@ import com.google.common.base.Predicate;
|
|||
|
||||
public class EntityDemonBase extends EntityCreature implements IEntityOwnable
|
||||
{
|
||||
protected static final DataParameter<Byte> TAMED = EntityDataManager.<Byte>createKey(EntityTameable.class, DataSerializers.BYTE);
|
||||
protected static final DataParameter<Optional<UUID>> OWNER_UNIQUE_ID = EntityDataManager.<Optional<UUID>>createKey(EntityTameable.class, DataSerializers.OPTIONAL_UNIQUE_ID);
|
||||
protected static final DataParameter<Byte> TAMED = EntityDataManager.<Byte>createKey(EntityDemonBase.class, DataSerializers.BYTE);
|
||||
protected static final DataParameter<Optional<UUID>> OWNER_UNIQUE_ID = EntityDataManager.<Optional<UUID>>createKey(EntityDemonBase.class, DataSerializers.OPTIONAL_UNIQUE_ID);
|
||||
|
||||
public EntityDemonBase(World worldIn)
|
||||
{
|
||||
|
|
|
@ -1,15 +1,49 @@
|
|||
package WayofTime.bloodmagic.gson;
|
||||
|
||||
import com.google.gson.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializer;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
|
||||
public class Serializers
|
||||
{
|
||||
// Data serializers
|
||||
public static final DataSerializer<EnumDemonWillType> WILL_TYPE_SERIALIZER = new DataSerializer<EnumDemonWillType>()
|
||||
{
|
||||
@Override
|
||||
public void write(PacketBuffer buf, EnumDemonWillType value)
|
||||
{
|
||||
buf.writeEnumValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType read(PacketBuffer buf)
|
||||
{
|
||||
return (EnumDemonWillType) buf.readEnumValue(EnumDemonWillType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataParameter<EnumDemonWillType> createKey(int id)
|
||||
{
|
||||
return new DataParameter<EnumDemonWillType>(id, this);
|
||||
}
|
||||
};
|
||||
|
||||
// Serializers
|
||||
public static final SerializerBase<EnumFacing> FACING_SERIALIZER = new SerializerBase<EnumFacing>()
|
||||
{
|
||||
|
@ -50,21 +84,25 @@ public class Serializers
|
|||
return object;
|
||||
}
|
||||
};
|
||||
public static final SerializerBase<ItemStack> ITEMMETA_SERIALIZER = new SerializerBase<ItemStack>() {
|
||||
public static final SerializerBase<ItemStack> ITEMMETA_SERIALIZER = new SerializerBase<ItemStack>()
|
||||
{
|
||||
@Override
|
||||
public Class<ItemStack> getType() {
|
||||
public Class<ItemStack> getType()
|
||||
{
|
||||
return ItemStack.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
ResourceLocation registryName = context.deserialize(json.getAsJsonObject().get("registryName").getAsJsonObject(), ResourceLocation.class);
|
||||
int meta = json.getAsJsonObject().get("meta").getAsInt();
|
||||
return new ItemStack(ForgeRegistries.ITEMS.getValue(registryName), 1, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context)
|
||||
{
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.add("registryName", context.serialize(src.getItem().getRegistryName()));
|
||||
jsonObject.addProperty("meta", src.getItemDamage());
|
||||
|
@ -72,12 +110,10 @@ public class Serializers
|
|||
}
|
||||
};
|
||||
|
||||
public static final Gson GSON = new GsonBuilder()
|
||||
.serializeNulls()
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.registerTypeAdapter(FACING_SERIALIZER.getType(), FACING_SERIALIZER)
|
||||
.registerTypeAdapter(RESOURCELOCATION_SERIALIZER.getType(), RESOURCELOCATION_SERIALIZER)
|
||||
.registerTypeAdapter(ITEMMETA_SERIALIZER.getType(), ITEMMETA_SERIALIZER)
|
||||
.create();
|
||||
public static final Gson GSON = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().registerTypeAdapter(FACING_SERIALIZER.getType(), FACING_SERIALIZER).registerTypeAdapter(RESOURCELOCATION_SERIALIZER.getType(), RESOURCELOCATION_SERIALIZER).registerTypeAdapter(ITEMMETA_SERIALIZER.getType(), ITEMMETA_SERIALIZER).create();
|
||||
|
||||
static
|
||||
{
|
||||
DataSerializers.registerSerializer(WILL_TYPE_SERIALIZER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
|||
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
import WayofTime.bloodmagic.tile.TileIncenseAltar;
|
||||
import WayofTime.bloodmagic.tile.TileInversionPillar;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
|
@ -39,12 +40,12 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
|
|||
// DungeonTester.testDungeonElementWithOutput((WorldServer) world, player.getPosition());
|
||||
// }
|
||||
|
||||
// if (!world.isRemote)
|
||||
// {
|
||||
// EntityCorruptedZombie fred = new EntityCorruptedZombie(world);
|
||||
// fred.setPosition(player.posX, player.posY, player.posZ);
|
||||
// world.spawnEntityInWorld(fred);
|
||||
// }
|
||||
if (!world.isRemote)
|
||||
{
|
||||
EntityCorruptedSheep fred = new EntityCorruptedSheep(world);
|
||||
fred.setPosition(player.posX, player.posY, player.posZ);
|
||||
world.spawnEntityInWorld(fred);
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
|
|
|
@ -40,12 +40,14 @@ import WayofTime.bloodmagic.client.render.RenderDemonCrucible;
|
|||
import WayofTime.bloodmagic.client.render.RenderItemRoutingNode;
|
||||
import WayofTime.bloodmagic.client.render.block.RenderMimic;
|
||||
import WayofTime.bloodmagic.client.render.entity.BloodLightRenderFactory;
|
||||
import WayofTime.bloodmagic.client.render.entity.CorruptedSheepRenderFactory;
|
||||
import WayofTime.bloodmagic.client.render.entity.CorruptedZombieRenderFactory;
|
||||
import WayofTime.bloodmagic.client.render.entity.MeteorRenderFactory;
|
||||
import WayofTime.bloodmagic.client.render.entity.MimicRenderFactory;
|
||||
import WayofTime.bloodmagic.client.render.entity.SentientArrowRenderFactory;
|
||||
import WayofTime.bloodmagic.client.render.entity.SentientSpecterRenderFactory;
|
||||
import WayofTime.bloodmagic.client.render.entity.SoulSnareRenderFactory;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedZombie;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityMimic;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
|
@ -124,6 +126,7 @@ public class ClientProxy extends CommonProxy
|
|||
RenderingRegistry.registerEntityRenderingHandler(EntitySentientSpecter.class, new SentientSpecterRenderFactory());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityMimic.class, new MimicRenderFactory());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedZombie.class, new CorruptedZombieRenderFactory());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedSheep.class, new CorruptedSheepRenderFactory());
|
||||
|
||||
ShaderHelper.init();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.registry;
|
|||
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedZombie;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityMimic;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
|
@ -23,5 +24,6 @@ public class ModEntities
|
|||
EntityRegistry.registerModEntity(EntitySentientSpecter.class, "SentientSpecter", id++, BloodMagic.instance, 64, 1, true);
|
||||
EntityRegistry.registerModEntity(EntityMimic.class, "Mimic", id++, BloodMagic.instance, 64, 1, true);
|
||||
EntityRegistry.registerModEntity(EntityCorruptedZombie.class, "CorruptedZombie", id++, BloodMagic.instance, 64, 1, true);
|
||||
EntityRegistry.registerModEntity(EntityCorruptedSheep.class, "CorruptedSheep", id++, BloodMagic.instance, 64, 1, true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue