
gerg
Members-
Posts
6 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
Personal Text
I am new!
gerg's Achievements

Tree Puncher (2/8)
1
Reputation
-
Thanks for the heads up.
-
Oh man I can't believe I didn't remember that one thanks! I changed the param to 2 and that is so much nicer, do you happen to know what MC uses for vanilla? Also any ideas as to why no other AI class is working other than tempt? EDIT: Nevermind I think the issue is with me altering AI in between different mod builds, the old AI seems to stop working and I must spawn a new one to see changes. I'm so dumb.
-
[Solved] Planting crops on other blocks besides farmland (1.8.9)
gerg replied to Ronaldi2001's topic in Modder Support
I'm looking in net.minecraft.item.ItemSeeds#onItemUse right now and there's this if statement: /** * Called when a Block is right-clicked with this Item */ public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (side != EnumFacing.UP) { return false; } else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack)) { return false; } else if (worldIn.getBlockState(pos).getBlock().canSustainPlant(worldIn, pos, EnumFacing.UP, this) && worldIn.isAirBlock(pos.up())) { worldIn.setBlockState(pos.up(), this.crops.getDefaultState()); --stack.stackSize; return true; } else { return false; } } So short of creating a coremod and altering the diamond block's canSustainPlant function, you should make an item that alters the diamond block, eg turns it into a custom diamond block which overrides this method and returns true. My advice would be to take a look at net.minecraft.block.Block#canSustainPlant and net.minecraft.block.Block#canHarvestBlock methods. I may just be talking out of my ass though, someone with more knowledge can and should correct me if I am. -
Hi guys I'm trying to get my custom entity to move smoothly throughout the world like all vanilla mobs. However the movement seems choppy at best. Here is a video I just made to demonstrate it. As you can see the movement is quite choppy compared to normal mobs. What vanilla classes should I look at to check how MC handles smooth movement? Here is my BaseEntity file that my mob extends (no extra functionality in the subclass): package com.gerg.catology.entity; import com.gerg.catology.items.CatologyItems; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.ai.EntityAIFollowParent; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; 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.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.pathfinding.PathNavigateGround; import net.minecraft.world.World; public class BaseEntity extends EntityTameable { public BaseEntity(World worldIn) { super(worldIn); //sets up the ai for lil kitty cats //setupAI(); ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIPanic(this, 1.25D)); this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); this.tasks.addTask(3, new EntityAITempt(this, 1.1D, Items.wheat, false)); this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D)); //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)); //this.inventoryCrafting.setInventorySlotContents(0, new ItemStack(Items.dye, 1, 0)); //this.inventoryCrafting.setInventorySlotContents(1, new ItemStack(Items.dye, 1, 0)); } protected void clearAITasks(){ tasks.taskEntries.clear(); targetTasks.taskEntries.clear(); } protected void setupAI() { clearAITasks(); } @Override public EntityAgeable createChild(EntityAgeable ageable) { // TODO Auto-generated method stub return null; } } Those tasks were copied directly from EntitySheep.class and I commented some out that I couldn't use directly, but those shouldn't matter. Also note that for some reason the only task that seems to work is the EntityAITempt one, when I hit my mob it doesn't run around crazy like normal ones do. Nor does it wander when nothing else is happening.
-
Oh okay thanks for the suggestion Draco18s, I also fixed my texture offset issue by just using the ModelRenderer constructor that takes the the offset as params. I was originally calling new ModelRenderer(this) then addBox -> setRotationPoint -> setTextureSize -> setTextureOffset. I guess that's not the correct way to go.
-
Hi guys I'm new to MC modding and I've been dicking around with forge modding (11.15.1.1722) for a few days. I'm having 2 issues with my custom entity. In game when I press F3+B to view the bounding box, it seems as if my entities bb is just a square on the ground, meaning I can't hit it unless I punch it's feet. How can I change the bbox to match my entity in game? The other issue is texture offsets. I can't really get a feel to how this works but I created my model in Techne then using a couple of tutorials on the internet tried to recreate the model using a child hierarchy where everything is parented to the torso in code only. I did not export the Techne model as java and use that. I did however generate the texture file with Techne by exporting as a texture and drawing/reimporting etc. However when I set the texture offsets in my BaseModelCat class (copying them from the texture offsets in Techne) they don't turn out correctly at all. Here is the model in Techne, the model in game, the texture image, and the BaseModelCat class: package com.gerg.catology.client.model; import org.lwjgl.opengl.GL11; import com.gerg.catology.entity.passive.BaseCatEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; //all cats look the same just different textures. //just extend this class to make a new cat. @SideOnly(Side.CLIENT) public class BaseModelCat extends ModelBase { public ModelRenderer head; public ModelRenderer torso; public ModelRenderer brleg; public ModelRenderer blleg; public ModelRenderer flleg; public ModelRenderer frleg; public ModelRenderer nose; public ModelRenderer tail1; public ModelRenderer tail2; public ModelRenderer tail3; public ModelRenderer tail4; public ModelRenderer tail5; public ModelRenderer rear; public ModelRenderer lear; public int texture_width = 64; public int texture_height = 32; public double distanceMovedTotal = 0.0D; //cycles of animation per block moved protected static final double CYCLES_PER_BLOCK = 3.0D; public BaseModelCat() { torso = new ModelRenderer(this); torso.addBox(-3F, -3F, -8F, 6, 6, 16); torso.setRotationPoint(0F, 15F, 0F); torso.setTextureSize(texture_width, texture_height); torso.setTextureOffset(0, 0); head = new ModelRenderer(this); head.addBox(-4F, -3F, -6F, 8, 6, 6); head.setRotationPoint(0F, 13F, -8F); head.setTextureSize(texture_width, texture_height); head.setTextureOffset(30, 0); nose = new ModelRenderer(this); nose.addBox(-2F, -2F, -1F, 4, 3, 1); nose.setRotationPoint(0F, 15F, -14F); nose.setTextureSize(texture_width, texture_height); nose.setTextureOffset(1, 28); lear = new ModelRenderer(this); lear.addBox(-1F, -1F, -0.5F, 2, 2, 1); lear.setRotationPoint(-2F, 10F, -9.5F); lear.setTextureSize(texture_width, texture_height); lear.setTextureOffset(0, 0); lear.rotateAngleZ = 45F; rear = new ModelRenderer(this); rear.addBox(-1F, -1F, -0.5F, 2, 2, 1); rear.setRotationPoint(2F, 10F, -9.5F); rear.setTextureSize(texture_width, texture_height); rear.setTextureOffset(0, 0); rear.rotateAngleZ = 45F; flleg = new ModelRenderer(this); flleg.addBox(-1.5F, 0F, -1.5F, 3, 10, 3); flleg.setRotationPoint(-3F, 14f, -5.5F); flleg.setTextureSize(texture_width, texture_height); flleg.setTextureOffset(52, 19); frleg = new ModelRenderer(this); frleg.addBox(-1.5F, 0F, -1.5F, 3, 10, 3); frleg.setRotationPoint(3F, 14f, -5.5F); frleg.setTextureSize(texture_width, texture_height); frleg.setTextureOffset(52, 19); blleg = new ModelRenderer(this); blleg.addBox(-1.5F, 0F, -1.5F, 3, 10, 3); blleg.setRotationPoint(-2.5F, 14F, 4.5F); blleg.setTextureSize(texture_width, texture_height); blleg.setTextureOffset(52, 19); brleg = new ModelRenderer(this); brleg.addBox(-1.5F, 0F, -1.5F, 3, 10, 3); brleg.setRotationPoint(2.5F, 14F, 4.5F); brleg.setTextureSize(texture_width, texture_height); brleg.setTextureOffset(52, 19); tail1 = new ModelRenderer(this); tail1.addBox(-1F, -0.5F, 0F, 2, 1, 4); tail1.setRotationPoint(0F, 12.5F, 8F); tail1.setTextureSize(texture_width, texture_height); tail1.setTextureOffset(22, 27); tail2 = new ModelRenderer(this); tail2.addBox(-1F, -0.5F, 0F, 2, 1, 4); tail2.setRotationPoint(0F, 12.5F, 11F); tail2.setTextureSize(texture_width, texture_height); tail2.setTextureOffset(22, 27); tail3 = new ModelRenderer(this); tail3.addBox(-1F, -0.5F, 0F, 2, 1, 4); tail3.setRotationPoint(0F, 12.5F, 14F); tail3.setTextureSize(texture_width, texture_height); tail3.setTextureOffset(22, 27); tail4 = new ModelRenderer(this); tail4.addBox(-1F, -0.5F, 0F, 2, 1, 4); tail4.setRotationPoint(0F, 12.5F, 17F); tail4.setTextureSize(texture_width, texture_height); tail4.setTextureOffset(22, 27); tail5 = new ModelRenderer(this); tail5.addBox(-1F, -0.5F, 0F, 2, 1, 4); tail5.setRotationPoint(0F, 12.5F, 20F); tail5.setTextureSize(texture_width, texture_height); tail5.setTextureOffset(37, 27); //start parenting things to the torso starting with //extremities and working inwards convertToChild(tail4, tail5); convertToChild(tail3, tail4); convertToChild(tail2, tail3); convertToChild(tail1, tail2); convertToChild(torso, tail1); convertToChild(torso, flleg); convertToChild(torso, frleg); convertToChild(torso, blleg); convertToChild(torso, brleg); convertToChild(head, nose); convertToChild(head, lear); convertToChild(head, rear); convertToChild(torso, head); } //basically just used to cast from Entity to BaseCatEntity //that way you can access fields from the BaseCatEntity in renderCat @Override public void render(Entity parEntity, float parTime, float parSwingSuppress, float par4, float parHeadAngleY, float parHeadAngleX, float par7){ renderCat((BaseCatEntity)parEntity, parTime, parSwingSuppress, par4, parHeadAngleY, parHeadAngleX, par7); } public void renderCat(BaseCatEntity parEntity, float parTime, float parSwingSuppress, float par4, float parHeadAngleY, float parHeadAngleX, float par7) { setRotationAngles(parTime, parSwingSuppress, par4, parHeadAngleY, parHeadAngleX, par7, parEntity); //scale the whole thing for big or small entities GL11.glPushMatrix(); float scale_factor = parEntity.getScaleFactor(); GL11.glScalef(scale_factor, scale_factor, scale_factor); //if the animal is still a wee baby /*if (this.isChild) { } else { }*/ torso.render(par7); GL11.glPopMatrix(); } @Override public void setRotationAngles(float parTime, float parSwingSuppress, float par3, float parHeadAngleY, float parHeadAngleX, float par6, Entity parEntity){ //animate if moving updateDistanceMovedTotal(parEntity); } protected void updateDistanceMovedTotal(Entity parEntity) { distanceMovedTotal += parEntity.getDistance(parEntity.prevPosX, parEntity.prevPosY, parEntity.prevPosZ); } protected double getDistanceMovedTotal(Entity parEntity) { return distanceMovedTotal; } protected float degToRad(float degrees) { return degrees * (float)Math.PI / 180F; } //useful for converting from techne models to the hierarchical models //that are built here. make sure to always convert extremeties to children //first and work your way through to the main parent part (torso for basecat) protected void convertToChild(ModelRenderer parParent, ModelRenderer parChild) { // move child rotation point to be relative to parent parChild.rotationPointX -= parParent.rotationPointX; parChild.rotationPointY -= parParent.rotationPointY; parChild.rotationPointZ -= parParent.rotationPointZ; // make rotations relative to parent parChild.rotateAngleX -= parParent.rotateAngleX; parChild.rotateAngleY -= parParent.rotateAngleY; parChild.rotateAngleZ -= parParent.rotateAngleZ; // create relationship parParent.addChild(parChild); } }