Everything posted by Brickfix
-
[1.8] Totem Mod - keeping nasty monsters out of your base!
hm ... the totems are basically a retextured command block, with some changes so it does not need a redstone input etc. They should not act as chunkloaders Unfortunatly I don't have the time to update anytime soon, sorry about that
-
[1.8] Brickfix WorldGen - Adding new Structures to the game :)
Hi I haven't had the chance to code for quite a while, and no update will turn up anytime soon. But actually I thought I had it balanced out quite well... What where the coords of the beacon you found? If any value is smaller +/- 1000, I recommend to use the newest version
-
[1.8] Brickfix WorldGen - Adding new Structures to the game :)
jup, that's how you do it. I can't really upload any source right now, as I am constantly trying and changing things, even though there has not been any update for a while. Also, up to now there is nothing really complicated I have done, you can ask me how certain things in my mod work any time
-
A mob that acts as a collective consciousness?
I am not too expirienced with this, but I am currently tinkering around with AIs so maybe this could be some way: Look at the targeting AI, you could copy some things, and save all targeted entities (targeted by your robot mobs) into a list, and than create a method to choose which entity to target in the overall list.
-
[1.8] Custom mob - armor not always rendering
Sorry, here they are: Registration, registered under the FMLPreInitialisationEvent in the main modclass, package com.brickfix.roleplaymod.entity; import com.brickfix.roleplaymod.RoleplayMod; import net.minecraft.entity.EntityList; import net.minecraftforge.fml.common.registry.EntityRegistry; public class RPEntities { public static void mainRegistry() { registerEntity(); } public static void registerEntity() { createEntity(EntityTestMob.class, "TestMob", 0xE80C0C, 0x0CE876); } public static void createEntity(Class entityClass, String entityName, int solidColour, int spotColour) { int randomId = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId); EntityRegistry.registerModEntity(entityClass, entityName, randomId, RoleplayMod.instance, 32, 1, true); createEgg(randomId, solidColour, spotColour); } private static void createEgg(int randomId, int solidColour, int spotColour) { EntityList.entityEggs.put(Integer.valueOf(randomId), new EntityList.EntityEggInfo(randomId, solidColour, spotColour)); } } The Entity class: package com.brickfix.roleplaymod.entity; import java.util.Random; import com.brickfix.roleplaymod.ExtendedPlayerData; import com.brickfix.roleplaymod.RoleplayMod; import com.brickfix.roleplaymod.container.ContainerNPC; import com.brickfix.roleplaymod.util.SpeechFactory; import com.google.common.base.Predicate; import net.minecraft.block.BlockAnvil; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIArrowAttack; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIAvoidEntity; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; 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.monster.EntityCaveSpider; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityOcelot; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.inventory.AnimalChest; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.DamageSource; import net.minecraft.util.IChatComponent; import net.minecraft.util.MathHelper; import net.minecraft.world.IInteractionObject; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; public class EntityTestMob extends EntityAgeable { public EntityTestMob(World worldIn) { super(worldIn); this.setSize(1.0F, 2.0F); this.setEntityToolsAndArmor(); this.tasks.addTask(0, new EntityAIWander(this, 0.5D)); this.tasks.addTask(2, new EntityAILookIdle(this)); this.tasks.addTask(3, new EntityAISwimming(this)); this.tasks.addTask(4, new EntityAITempt(this, 0.6D, Items.apple, false)); this.tasks.addTask(5, new EntityAIAvoidEntity(this, new Predicate() { public boolean shallAvoid(Entity entity) { return entity instanceof EntityCreeper; } public boolean apply(Object entityObject) { return this.shallAvoid((Entity)entityObject); } }, 6.0F, 1.0D, 1.2D)); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityZombie.class, 1.0D, true)); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntitySkeleton.class, 1.0D, true)); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntitySpider.class, 1.0D, true)); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityCaveSpider.class, 1.0D, true)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityZombie.class, true)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntitySkeleton.class, true)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntitySpider.class, true)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityCaveSpider.class, true)); this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false, new Class[0])); } @Override protected void entityInit() { super.entityInit(); Random rnd = new Random(); byte b = (byte)(rnd.nextInt(2)); this.dataWatcher.addObject(13, new Byte((byte)b)); } @Override public boolean canDespawn() { return false; } public boolean isAIEnabled() { return true; } public boolean interact(EntityPlayer player) { ItemStack item = player.inventory.getCurrentItem(); boolean flag = item != null && item.getItem() == Items.spawn_egg; if (!flag && !this.worldObj.isRemote) { if (player.isSneaking()) player.openGui(RoleplayMod.instance, 0, worldObj, this.getEntityId(), 0, 0); else { ChatComponentText message = new SpeechFactory().createNewMessage(this, player); //ChatComponentText message2 = new ChatComponentText("Your current popularity is " + ExtendedPlayerData.get(player).getAlignment()); player.addChatMessage(message); //player.addChatMessage(message2); //if (this.getNPCType() == 1) this.setNPCType(0); //else this.setNPCType(1); } return true; } else return super.interact(player); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D);; this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(2.0D); } @Override public EntityAgeable createChild(EntityAgeable ageable) { return new EntityTestMob(worldObj); } protected void setEntityToolsAndArmor() { Random rnd = new Random(); int k=0; int ran1 = rnd.nextInt(5); int ran2; ItemStack item = null; do { ran2=rnd.nextInt(3); switch(k) { case 0: if (ran2 == 0) item = new ItemStack(Items.stone_pickaxe); else if (ran2==1) item = new ItemStack(Items.stone_sword); else if (ran2==2) item = new ItemStack(Items.stone_axe); break; case 4: if (ran2==0) item = new ItemStack(Items.leather_boots); else if (ran2==1) item = new ItemStack(Items.iron_boots); else if (ran2==2) item = new ItemStack(Items.chainmail_boots); break; case 3: if (ran2==0) item = new ItemStack(Items.leather_leggings); else if (ran2==2) item = new ItemStack(Items.chainmail_leggings); break; case 2: if (ran2==0) item = new ItemStack(Items.leather_chestplate); else if (ran2==2) item = new ItemStack(Items.chainmail_chestplate); break; case 1: if (ran2==0) item = new ItemStack(Items.chainmail_helmet); } this.setCurrentItemOrArmor(k, item); k++; } while (k<ran1); } @Override public boolean attackEntityAsMob(Entity entity) { float f = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); int i = 0; if (entity instanceof EntityLivingBase) { f += EnchantmentHelper.func_152377_a(this.getHeldItem(), ((EntityLivingBase)entity).getCreatureAttribute()); i += EnchantmentHelper.getKnockbackModifier(this); } boolean flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), f); if (flag) { if (i > 0) { entity.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F)); this.motionX *= 0.6D; this.motionZ *= 0.6D; } int j = EnchantmentHelper.getFireAspectModifier(this); if (j > 0) { entity.setFire(j * 4); } this.func_174815_a(this, entity); } return flag; } public void setNPCType(int i) { this.dataWatcher.updateObject(13, Byte.valueOf((byte)i)); } public int getNPCType() { return this.dataWatcher.getWatchableObjectByte(13); } @Override public void writeEntityToNBT(NBTTagCompound tag) { super.writeEntityToNBT(tag); tag.setByte("NPCType", (byte)this.getNPCType()); } @Override public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); if (tag.hasKey("NPCType")) { byte b0 = tag.getByte("NPCType"); this.setNPCType(b0); System.out.println("The type of the NPC is " + b0); } } } And the render class: package com.brickfix.roleplaymod.rendering; import com.brickfix.roleplaymod.entity.EntityTestMob; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.layers.LayerBipedArmor; import net.minecraft.client.renderer.entity.layers.LayerCustomHead; import net.minecraft.client.renderer.entity.layers.LayerHeldItem; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class TestMobRenderer extends RenderLiving { private static final ResourceLocation civilianTexture = new ResourceLocation("roleplaymod:textures/entities/rpgnpcs/testmob.png"); private static final ResourceLocation guardianTexture = new ResourceLocation("roleplaymod:textures/entities/rpgnpcs/NPCWarrior.png"); public ModelBiped modelBipedMain; public TestMobRenderer(RenderManager renderManager, ModelBase model, float f) { super(renderManager, model, f); this.addLayer(new LayerHeldItem(this)); LayerBipedArmor layerbipedarmor = new LayerBipedArmor(this) { protected void noClueWhatThisDoes() { this.field_177186_d = new ModelBiped(1.0F); this.field_177189_c = new ModelBiped(0.5F); } }; this.addLayer(layerbipedarmor); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return this.getEntityTextureFromType((EntityTestMob) entity); } protected ResourceLocation getEntityTextureFromType(EntityTestMob entity) { return entity.getNPCType() == 1 ? this.guardianTexture : this.civilianTexture; } } Thanks again for any help (:
-
[1.8] Custom mob - armor not always rendering
Hi, As said above, the Entity seems to not render the armor all the times. Sometimes it is just one single piece of armor, sometimes everything. I compared all my code to the minecraft code (for example all for the Zombie entities), but the problem persists. Any ideas? Thanks for the help in advance (:
-
[1.8] [SOLVED]Display GUI when interacting with an entity
Ok thanks, I figured it out
-
[1.8] [SOLVED]Display GUI when interacting with an entity
So I am trying this, but without any success... I implemented IInteractionObject in the NPCs class, created the GUI, the Container, a GuiHandler, registered it in the modfile, and so on. But unfortunatly my GUI still doesn't open. Could somebody look over my code? Possible problems could be the GuiHandler, or the @Override functions that came with the implementation of IInteractionObject into the NPCs class, I might have done something wrong... This is my NPCs class: This is my GuiContainer This is my Gui This is my GuiHandler Thanks for any help again (:
-
[1.8] [SOLVED]Display GUI when interacting with an entity
Wups, I just see my explanation wasn't the best I have a custom Entity, an NPC. When rightclicked, I want it to display a GUI and add a way to communicate with the NPC, get Quests etc. . The only problem is that, other than with blocks, most GUIs seem to be hardcoded when it comes to players: player.displayGUIHorse() player.displayGUIBook() player.disiplayGUIChest() Those functions above are very specific and don't give me what I would like to do. The two functions I consider tapping into are either: player.displayGUI() player.displayVillageTraderGUI() The first one requires IInteractionObject as parameter, the second one the IMerchant interface implemented in my Entity. I wonder, which was is easier to do? Or is there one of the two ways not even possible? Thanks again for any response (:
-
[1.8] [SOLVED]Display GUI when interacting with an entity
Hi, I am trying to make a GUI for Entities, so the GUI shall display when I interact with the NPC. My question is, what would be the simplest way to do this? Should I let my use the Interface IMerchant for my villager or rather the IInteractionObject? Or does forge come with an even easier method? Thanks in advance
-
[1.8] [Solved] Adding custom Mob to the entities a Zombie will attack
thanks, that was even easier than I expected
-
[1.8] [Solved] Adding custom Mob to the entities a Zombie will attack
Hi, now that I have a mob that attacks Zombies, I would like the Zombies to have a chance to fight back. I have no idea how to do this, and I think it might be impossible, but is there a way to influence the AI of Zombie entities to attack my custom mob? Thanks for any help (:
-
[1.8] [SOLVED] Custom Mob AI problems
THANKS! That was the problem! Now it works fine, thanks alot (: BTW, your tutorial is really easy to understand and well structured, thanks for the effort And thanks Awesome_Spider for trying to help as well
-
[1.8] [SOLVED] Custom Mob AI problems
I changed it - still the same issue. I made sure by selecting the mob to be attacked to be EntityPlayer - the same with the target AI. So, they all come running when they see me, but they do not attack in any way.
-
[1.8] [SOLVED] Custom Mob AI problems
I didn't override onUptade(), but I did so now as you sad @Override public void onUpdate() { super.onUpdate(); } The problem persists, they still only follow the Zomiey (which looks funny enough), but they do not attack it. The only damage the Zombie is taking is from the sunlight. But thanks for the explanation about the AI, now that I look at it it does make sense
-
[1.8] [SOLVED] Custom Mob AI problems
Hi, I have a custom entity that shall attack Zombies. But I only can make it run to the next Zombie, but not to attack it. This is my Entity Constructor: public EntityTestMob(World worldIn) { super(worldIn); this.setSize(1.0F, 2.0F); this.setEntityToolsAndArmor(); this.tasks.addTask(0, new EntityAIWander(this, 0.5D)); //this.tasks.addTask(1, new EntityAIPanic(this, 0.9D)); this.tasks.addTask(2, new EntityAILookIdle(this)); this.tasks.addTask(3, new EntityAISwimming(this)); this.tasks.addTask(4, new EntityAITempt(this, 0.6D, Items.apple, false)); this.tasks.addTask(5, new EntityAIAvoidEntity(this, new Predicate() { public boolean shallAvoid(Entity entity) { return entity instanceof EntityCreeper; } public boolean apply(Object entityObject) { return this.shallAvoid((Entity)entityObject); } }, 6.0F, 1.0D, 1.2D)); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityZombie.class, 1.0D, true)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityZombie.class, true)); this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false, new Class[0])); } BTW, I noticed that a lot of minecraft Mobs have several tasks assigned with the same value, e.g. this.tasks.addTask(2, new EntityAILookIdle(this)); this.tasks.addTask(2, new EntityAISwimming(this)) Is the integer (the '2' in this case) a unique ranking or a propability value? Thanks for any response (:
-
[1.8] [SOLVED]Custom mob - how to use a RenderManager
Thanks, that was rather simple But now I still have a box as an entity, but I think as I put new ModelBiped() in the argument I should get an entity looking simiular to the player ... Where is my mistake now? EDIT: Neverminde, I just found out I forgot to reference one thing. Stupid me EDIT2: I think this belongs into another thread, but I will ask it here: How do I add a chat message when the player rightclicked the mob? I know it would go into the interact method of the entity, but how do I sent chatmessages in general? Thanks again in advance EDIT3: And again I found it out by myself
-
[1.8] [SOLVED]Custom mob - how to use a RenderManager
Hi, I am trying to create a custom mob, and I want to know how to use a RenderManager or what this even is. I have only found tutorials and sourcecode from 1.7.10, and apperantly a RenderManager is something added in 1.8 Here is my ClientProxy: package com.brickfix.roleplaymod; import com.brickfix.roleplaymod.entity.EntityTestMob; import com.brickfix.roleplaymod.rendering.TestMobRenderer; import net.minecraft.client.model.ModelBiped; import net.minecraftforge.fml.client.registry.RenderingRegistry; public class ClientProxy extends CommonProxy { @Override public void registerRenderThings() { RenderingRegistry.registerEntityRenderingHandler(EntityTestMob.class,[u] new TestMobRenderer[/u](new ModelBiped(), 0)); } } Here is my TestMobRenderer package com.brickfix.roleplaymod.rendering; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class TestMobRenderer extends RenderLiving { private static final ResourceLocation testMobTextures = new ResourceLocation("textures/entity/testmob/testmob.png"); protected TestMobRenderer(RenderManager renderManager, ModelBase model, float f) { super(renderManager, model, f); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return this.testMobTextures; } } I want to use ModelBiped for the mob. I have underlined the error in the client proxy, and I know that I would have to add the RenderManager her. I just don't know what a RenderManager is, what is supposed to do and so on and so forth. Thanks for any help (:
-
[1.8][SOLVED] Ore Generation
It's only a small thing, that can make a big difference: But the GameRegistry.registerWorldGenerator(new SixPointOhGenerator(), 0); in the Init Event (FMLInitializationEvent), you put it in PreInit.
-
[1.8][Solved] Clay-like Generation
Small thing that might fix it: (new FireClayGen()).generate(world, random, new BlockPos(x1, y, z1)); Note the () around new FireClayGen() I think that should be it
-
[1.8] terrain generator how to spawn in thesurface ??
Hi, this is fairly simple. first of all, you can use this to get the position right on the surface BlockPos pos = new BlockPos(chunkX*16, 0, chunkZ*16); pos = world.getHorizon(pos); Now lets say, you want to have little pillar out of cobblestone, lets create a small class: public class CobblePillar extends WorldGenerator { @Override public boolean generate(World world, Random random, BlockPos pos) { for (int i=0; i<=5; i++) { world.setBlockState(pos.add(0, i, 0), Blocks.cobblestone.getDefaultState(), 2); } return true; } } Now, lets call the code in your generator class: CobblePillar pillar = new CobblePillar(); pillar.generate(world, random, pos); This would be it, have fun
-
[1.8] Tile Entity check if entity is on top of block
Thanks, the aabb was the problem. I had to set it to pos.add(1,2,1) and it works without a problem. Thanks for pointing it out
-
[1.8] Tile Entity check if entity is on top of block
Jup, I did so. It always returned null as an entity, and the listsize was always 0
-
[1.8] Tile Entity check if entity is on top of block
Hi, as the title says, I am looking for a way to get an entity on top of a block during the TileEntity update function, but the method I got here is returning null all the time. I copied out of the world class and modified it a bit, did I do something wrong? I want to know if there is a chicken on top of the block, and do something according to this ... public Entity getEntityAboveBlock() { AxisAlignedBB aabb = new AxisAlignedBB(this.pos, this.pos.add(0, 1, 0)); List list = this.worldObj.getEntitiesWithinAABB(EntityChicken.class, aabb); Entity entity1 = null; double d0 = Double.MAX_VALUE; for (int i = 0; i < list.size(); ++i) { Entity entity2 = (Entity)list.get(i); if ( IEntitySelector.NOT_SPECTATING.apply(entity2)) { double d1 = this.pos.distanceSq(entity2.posX, entity2.posY, entity2.posZ); if (d1 <= d0) { entity1 = entity2; d0 = d1; } } } return entity1; } I would need the same to check for items, but I got no clue on how to do this Thanks for any help (:
-
[1.8] Totem Mod - keeping nasty monsters out of your base!
Ok, I think I got what you are looking for: The corrupted totem has a slightly changed texture, and is set up almost the same way the normal totem is. Only that the counterpart to the offering block is not required, but optional. The lvl 1 difficulty block will spawn monsters with leather and chainmail armor, carrying a stone sword, the lvl 2 mobs will carry iron gear and a diamond chestplate. The 3.0 version can now be downloaded, a more detailed description and screenshots will be added later. Have fun
IPS spam blocked by CleanTalk.