Jump to content

DaryBob

Members
  • Posts

    70
  • Joined

  • Last visited

Everything posted by DaryBob

  1. If I delete doRender, the wolfs are invisible, so it must be the doRender method?
  2. private final Render renderCat = new RenderOcelot(Minecraft.getMinecraft().getRenderManager(), new ModelOcelot(), 0.5F); @SubscribeEvent public void onRenderLiving(RenderLivingEvent.Pre event) { if(Minecraft.getMinecraft().thePlayer.isPotionActive(BLFeatures.fungiPotion)) { if(event.entity instanceof EntityWolf) { //System.out.println("Is this correct?"); event.setCanceled(true); renderCat.doRender(event.entity, 0F, 0F, 0F, 0F, 0F); } } }
  3. The doRender method for rendering the cat fails lol
  4. So instead checking the renderer, I checked the entity (event.entity instanceof EntityWolf), and I changed it to .Pre. It obviously spammed the line into the console log, but Minecraft crashed. Here is the log:
  5. Nice public class BLEventHandler { private final Render renderCat = new RenderOcelot(Minecraft.getMinecraft().getRenderManager(), new ModelOcelot(), 0.5F); @SubscribeEvent public void onRenderLiving(RenderLivingEvent event) { System.out.println("does this work"); //if(event.entityLiving.isPotionActive(BLFeatures.fungiPotion)) { if(event.renderer instanceof RenderWolf) { System.out.println("Is this correct?"); event.setCanceled(true); renderCat.doRender(event.entity, 0F, 0F, 0F, 0F, 0F); } //} } } I have this but it doesnt trigger the event idk why. ClientProxy: @Override public void preInit(FMLPreInitializationEvent e) { super.preInit(e); BLEventHandler event = new BLEventHandler(); MinecraftForge.EVENT_BUS.register(event); FMLCommonHandler.instance().bus().register(event); BlockRenderRegister.preInit(); ItemRenderRegister.preInit(); } Main @EventHandler public void init(FMLInitializationEvent event) { this.proxy.init(event); MinecraftForge.EVENT_BUS.register(new BLEventHandler()); }
  6. Sorry for my stupidity. I use RenderLivingEvent now.
  7. So, I made a custom potion. In the LivingUpdateEvent, it checks if this potion is active, and if yes, it checks for dogs.
  8. Can I use the LivingUpdateEvent instead onFoodEaten? Since it needs to check dog entities.
  9. Oh yeah, the class 'RenderLivingEvent" exists.
  10. So theres the method onFoodEaten in my item class. Can I trigger the effect here? Can I check for entities with the class World?
  11. At the moment I can't really update it. Would be nice if you still could help me though!
  12. Hey guys! I have a question on how to switch models. There is an item in my mod, called the psychedelic shroom. Now, I want to make dogs look like cats if that shroom was eaten. After a while, the effects reset and dogs look like cats again. However, I just want them to render like a cat, their entity stays the same. Where can I switch the models (in clientside, since others who didn't eat the shroom look everything normally)? How do I access the render classes? Thanks for some ideas!
  13. Ok, so you mean if(!world.isRemote)?
  14. Hi guy's, today I made a mob. If I spawn him, he has like two textures, very weird. I also wanted him to wear an armor and an item. I thought about it, and removed the armor code. But he still was there two times.. Could you please take a look into ma' code? Thanks, Dary EntityCreator.java package netcrafter.mods.aoto.util; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.projectile.EntityEgg; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.registry.EntityRegistry; import netcrafter.mods.aoto.Main; public class EntityCreator { public static final void createEntity(Class entityClass, Render renderer, String name, EnumCreatureType type, boolean doesSpawn, int probability, int minSpawn, int maxSpawn, BiomeGenBase[] biomes, int solidColor, int spotColor, boolean hasSpawnEgg) { int id = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(entityClass, name, id); EntityRegistry.registerModEntity(entityClass, name, id, Main.instance, 64, 1, true); RenderingRegistry.registerEntityRenderingHandler(entityClass, renderer); if(doesSpawn) { EntityRegistry.addSpawn(name, probability, minSpawn, maxSpawn, type, biomes); } if(hasSpawnEgg) { EntityList.entityEggs.put(Integer.valueOf(id), new EntityList.EntityEggInfo(id, solidColor, spotColor)); } } public static final void createEntityItem(Class entityClass, Render renderer, String name) { int id = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(entityClass, name, id); EntityRegistry.registerModEntity(entityClass, name, id, Main.instance, 64, 1, true); RenderingRegistry.registerEntityRenderingHandler(entityClass, renderer); } } CommonProxy.java package netcrafter.mods.aoto.proxy; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import netcrafter.mods.aoto.Main; import netcrafter.mods.aoto.crafting.AOTOCrafting; import netcrafter.mods.aoto.entity.boss.EntityForestGuardian; import netcrafter.mods.aoto.entity.boss.EntityKingSteve; import netcrafter.mods.aoto.entity.mob.EntityTreeMinion; import netcrafter.mods.aoto.entity.projectile.EntityTreeRoot; import netcrafter.mods.aoto.init.AOTOBlocks; import netcrafter.mods.aoto.init.AOTOItems; import netcrafter.mods.aoto.render.entity.RenderForestGuardian; import netcrafter.mods.aoto.render.entity.RenderKingSteve; import netcrafter.mods.aoto.render.entity.RenderTreeMinion; import netcrafter.mods.aoto.util.EntityCreator; import netcrafter.mods.aoto.util.WorldGenRegister; import netcrafter.mods.aoto.world.gen.feature.ForestGen; public class CommonProxy { public void preInit(FMLPreInitializationEvent e) { //Creating and registering items and blocks AOTOItems.createItems(); AOTOBlocks.createBlocks(); } public void init(FMLInitializationEvent e) { //Register crafting recipes AOTOCrafting.initCrafting(); //Create and register entities EntityCreator.createEntityItem(EntityTreeRoot.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), AOTOItems.tree_root, Minecraft.getMinecraft().getRenderItem()), "TreeRoot"); EntityCreator.createEntity(EntityKingSteve.class, new RenderKingSteve(), "KingSteve", EnumCreatureType.MONSTER, false, 0, 0, 0, null, 0xF2FF00, 0x020B12, true); EntityCreator.createEntity(EntityForestGuardian.class, new RenderForestGuardian(), "ForestGuardian", EnumCreatureType.MONSTER, false, 0, 0, 0, null, 0xC219A3, 0x19C238, true); EntityCreator.createEntity(EntityTreeMinion.class, new RenderTreeMinion(), "TreeMinion", EnumCreatureType.MONSTER, false, 0, 0, 0, null, 0xA85236, 0x6E260E, true); //Register world generators WorldGenRegister.registerGenerators(); } public void postInit(FMLPostInitializationEvent e) { } public void registerRenders() { } } EntityKingSteve.java package netcrafter.mods.aoto.entity.boss; import java.util.Random; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIArrowAttack; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveTowardsTarget; 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.boss.IBossDisplayData; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.monster.EntityGuardian; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.World; import netcrafter.mods.aoto.Reference; import netcrafter.mods.aoto.entity.mob.EntityTreeMinion; import netcrafter.mods.aoto.entity.projectile.EntityTreeRoot; import netcrafter.mods.aoto.init.AOTOItems; public class EntityKingSteve extends EntityMob implements IBossDisplayData { private int attackCounter = 0; private int deathTicks = 0; private int regenTime = 0; public EntityKingSteve(World worldIn) { super(worldIn); this.setSize(1.5F, 7.0F); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, 2.0D, true)); this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 1.0D, (float) 2.0D)); this.tasks.addTask(3, new EntityAIWander(this, 1.0D)); this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(5, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(360.0F); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(35.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.26D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(15.0D); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(2.0D); } protected void func_180481_a(DifficultyInstance p_180481_1_) { super.func_180481_a(p_180481_1_); this.setCurrentItemOrArmor(0, new ItemStack(AOTOItems.long_diamond_sword)); this.setCurrentItemOrArmor(1, new ItemStack(AOTOItems.beard)); } @Override protected String getLivingSound() { return Reference.MOD_ID + ":mob.forestguardian.living"; } @Override protected String getHurtSound() { return Reference.MOD_ID + ":mob.forestguardian.hurt"; } @Override protected String getDeathSound() { return Reference.MOD_ID + ":mob.forestguardian.death"; } /** Calls this method if the mob is dead */ @SuppressWarnings("unchecked") @Override protected void onDeathUpdate() { //Increments deathTicks every tick ++this.deathTicks; //Creates a huge explosion if the value of deathTicks is between 180 and 200 if (this.deathTicks >= 180 && this.deathTicks <= 200) { final float f = (this.rand.nextFloat() - 0.5F) * 1.5F; final float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F; final float f2 = (this.rand.nextFloat() - 0.5F) * 1.5F; //Spawns the explosion into the world this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + f, this.posY + 2.0D + f1, this.posZ + f2, 0.0D, 0.0D, 0.0D); } int i; int j; if (!this.worldObj.isRemote) { if (this.deathTicks > 150 && this.deathTicks % 5 == 0) { i = 30; while (i > 0) { j = EntityXPOrb.getXPSplit(i); i -= j; //Spawns xp orbs while i is bigger than zero this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); } } } //Rotates the mob this.moveEntity(0.0D, 0.10000000149011612D, 0.0D); this.renderYawOffset = this.rotationYaw += 20.0F; //Checks if the death ticks reached 200 if (this.deathTicks == 200 && !this.worldObj.isRemote) { i = 20; while (i > 0) { j = EntityXPOrb.getXPSplit(i); i -= j; //Spawns xp orbs while i is bigger than 0 this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); } //Drops an item this.entityDropItem(new ItemStack(AOTOItems.gem, 1, 1), 0.5F); //Spawns a lighting bolt into the world this.worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, this.posX + 6, this.posY + 6, this.posZ)); //Sets this mob dead super.setDead(); } } @Override protected void dropFewItems(boolean par1, int par2) { final ItemStack var2 = new ItemStack(AOTOItems.crown); EnchantmentHelper.addRandomEnchantment(this.rand, var2, 5); this.entityDropItem(var2, 0.0F); } @Override public EntityItem entityDropItem(ItemStack par1ItemStack, float par2) { final EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY + par2, this.posZ, par1ItemStack); entityitem.motionY = -2.0D; entityitem.setPickupDelay(60); if (this.captureDrops) { this.capturedDrops.add(entityitem); }else{ this.worldObj.spawnEntityInWorld(entityitem); } return entityitem; } @Override public void onLivingUpdate() { if(regenTime++ > 10) { regenTime = 0; this.heal(4); } super.onLivingUpdate(); } } RenderKingSteve.java package netcrafter.mods.aoto.render.entity; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.layers.LayerBipedArmor; import net.minecraft.client.renderer.entity.layers.LayerHeldItem; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.boss.BossStatus; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.util.ResourceLocation; import netcrafter.mods.aoto.Reference; import netcrafter.mods.aoto.entity.boss.EntityKingSteve; import netcrafter.mods.aoto.entity.mob.EntityTreeMinion; import netcrafter.mods.aoto.model.ModelKingSteve; import netcrafter.mods.aoto.model.ModelTreeMinion; public class RenderKingSteve extends RenderBiped { public RenderKingSteve() { super(Minecraft.getMinecraft().getRenderManager(), new ModelKingSteve(), 0); this.addLayer(new LayerHeldItem(this)); LayerBipedArmor layerbipedarmor = new LayerBipedArmor(this) { protected void func_177177_a() { this.field_177186_d = new ModelBiped(1.0F); this.field_177189_c = new ModelBiped(0.5F); } }; this.addLayer(layerbipedarmor); } @Override protected ResourceLocation getEntityTexture(Entity par1Entity) { return new ResourceLocation(Reference.MOD_ID, "textures/models/king_steve.png"); } private void renderEntity(EntityKingSteve entity, double x, double y, double z, float yaw, float partialTickTime) { super.doRender(entity, x, y, z, yaw, partialTickTime); } @Override public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { BossStatus.setBossStatus((IBossDisplayData) par1EntityLiving, false); super.doRender(par1EntityLiving, par2, par4, par6, par8, par9); } } ModelKingSteve.java package netcrafter.mods.aoto.model; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelKingSteve extends ModelBiped { ModelRenderer head; ModelRenderer body; ModelRenderer rightarm; ModelRenderer leftarm; ModelRenderer rightleg; ModelRenderer leftleg; public ModelKingSteve() { textureWidth = 64; textureHeight = 32; head = new ModelRenderer(this, 0, 0); head.addBox(-4F, -8F, -4F, 8, 8, ; head.setRotationPoint(0F, 0F, 0F); head.setTextureSize(64, 32); head.mirror = true; setRotation(head, 0F, 0F, 0F); body = new ModelRenderer(this, 16, 16); body.addBox(-4F, 0F, -2F, 8, 12, 4); body.setRotationPoint(0F, 0F, 0F); body.setTextureSize(64, 32); body.mirror = true; setRotation(body, 0F, 0F, 0F); rightarm = new ModelRenderer(this, 40, 16); rightarm.addBox(-3F, -2F, -2F, 4, 12, 4); rightarm.setRotationPoint(-5F, 2F, 0F); rightarm.setTextureSize(64, 32); rightarm.mirror = true; setRotation(rightarm, 0F, 0F, 0F); leftarm = new ModelRenderer(this, 40, 16); leftarm.addBox(-1F, -2F, -2F, 4, 12, 4); leftarm.setRotationPoint(5F, 2F, 0F); leftarm.setTextureSize(64, 32); leftarm.mirror = true; setRotation(leftarm, 0F, 0F, 0F); rightleg = new ModelRenderer(this, 0, 16); rightleg.addBox(-2F, 0F, -2F, 4, 12, 4); rightleg.setRotationPoint(-2F, 12F, 0F); rightleg.setTextureSize(64, 32); rightleg.mirror = true; setRotation(rightleg, 0F, 0F, 0F); leftleg = new ModelRenderer(this, 0, 16); leftleg.addBox(-2F, 0F, -2F, 4, 12, 4); leftleg.setRotationPoint(2F, 12F, 0F); leftleg.setTextureSize(64, 32); leftleg.mirror = true; setRotation(leftleg, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); head.render(f5); body.render(f5); rightarm.render(f5); leftarm.render(f5); rightleg.render(f5); leftleg.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } } Well now, that I pasted the model, maybe it renders it two times, because it is already a modelbiped?
  15. Hi I made a dimension, which has a room in every chunk. Every portal block has an id. It will teleport you to that room which has the same id as the portal. It works with players, but if I teleport a mob, it disappears, becuz its far and the chunk was not loaded. If I go in there first, then the mobs, they will teleport to that far chunk. So is there any method to force load the chunk, so that if an entity travels far it doesnt get removed?
  16. Im sure in onLivingUpdate() you need to call the super method first.
  17. I was thinking 'bout it. Does it even check my codes? Because it somehow still overrides trees, dirt even though I am checking first if the location is clear. It spawns on coal ore's, even though I am checking if the ground is dirt, stone or grass. Is it really checking all that stuff? It's strange.. GeneratorUtils.java package netcrafter.mods.aoto.util; import net.minecraft.block.Block; import net.minecraft.block.BlockChest; import net.minecraft.block.BlockMobSpawner; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import netcrafter.mods.aoto.init.AOTOBlocks; public class GeneratorUtils { //STRUCTURES -------------------------------------------------------------------------------------------------------------------------- public static boolean isStructureLocationValid(World world, int x, int y, int z, int blocksLength, int blocksHeight, int blocksWidth) { for (int i = x; i <= blocksLength; i++) { for (int j = y; j <= blocksHeight; j++) { for (int k = z; k <= blocksWidth; k++) { if(!isBlockValid(world, i, j, k)) { return false; } } } } for(int a = x; a <= blocksLength; a++) { for(int c = z; c <= blocksWidth; c++) { if(!isGroundValid(world, a, y, c)) { return false; } } } return true; } public static boolean isBlockValid(World world, int x, int y, int z) { Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); Block blockBelow = world.getBlockState(new BlockPos(x, y - 1, z)).getBlock(); if(block.getMaterial() == Material.plants && isValidBlock(blockBelow, world, x, y, z)) { return true; }if(block.isAir(world, new BlockPos(x, y, z))) { return true; }if (block == Blocks.snow_layer && isValidBlock(blockBelow, world, x, y, z)) { return true; }if (block == Blocks.water || blockBelow == Blocks.water) { return false; } return false; } public static boolean meldStructure(Block airBlock, World world, int x, int y, int z) { if(!airBlock.isAir(world, new BlockPos(x, y, z))) { return true; } return false; } public static boolean isGroundValid(World world, int x, int y, int z) { Block groundBlock = world.getBlockState(new BlockPos(x, y - 1, z)).getBlock(); if(isValidBlock(groundBlock, world, x, y, z)) { return true; } return false; } public static boolean isValidBlock(Block block, World world, int x, int y, int z) { block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); if(block == Blocks.dirt || block == Blocks.grass || block == Blocks.stone) { return true; } return false; } public static boolean isBlockChestOrSpawner(World world, int x, int y, int z, int blocksLength, int blocksHeight, int blocksWidth) { Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); for (int i = x; i <= blocksLength; i++) { for (int j = y; j <= blocksHeight; j++) { for (int k = z; k <= blocksWidth; k++) { if(block instanceof BlockMobSpawner) { setSpawner(world, i, j, k); return true; } if(block instanceof BlockChest) { return true; } } } } return false; } public static void setSpawner(World world, int x, int y, int z) { world.setBlockState(new BlockPos(x, y, z), AOTOBlocks.forest_guard_spawner.getDefaultState()); } public static void fillChest() { } } ForestGen.java package netcrafter.mods.aoto.world.gen.feature; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.fml.common.IWorldGenerator; import netcrafter.mods.aoto.util.GeneratorUtils; import netcrafter.mods.aoto.util.Schematic; public class ForestGen implements IWorldGenerator { static final int strWidth = 18; static final int strHeight = 8; static final int strDepth = 17; private Schematic schematic; public ForestGen(Schematic schematic) { this.schematic = schematic; } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if(random.nextInt(200) == 0) { int x = chunkX * 16 + random.nextInt(16); int z = chunkZ * 16 + random.nextInt(16); int y = getWorldHeightAt(world, x, z); if(GeneratorUtils.isStructureLocationValid(world, x, y, z, strWidth, strHeight, strDepth)) { if(world.getBiomeGenForCoords(new BlockPos(x, y, z)) == BiomeGenBase.forest) { schematic.generate(world, x, y, z); System.out.println("FOREST DUNGEON GENERATED!"); if(GeneratorUtils.isBlockChestOrSpawner(world, x, y, z, strWidth + 4, strHeight + 4, strDepth + 4)) { } } } } } private static int getWorldHeightAt(World world, int x, int z) { int height = 0; for(int i = 0; i < 255; i++) { if(world.getBlockState(new BlockPos(x, i, z)).getBlock().isSolidFullCube()) { height = i; } } return height; } }
  18. Well, just put this to your main class. It will run the renderer and will render the item. If you don't understand Java, please learn before copy-pasting. And after you know the basics, try to understand the example code I send you. It's the best way to learn how to mod/code and customize your mod however you want. MinecraftForgeClient.registerItemRenderer(Main.evilStaff, (IItemRenderer)new RenderEvilStaff()); Make sure you put this code in the init section.
  19. You need to make a model and render it.. Some examples: Put this method @SideOnly(Side.CLIENT) public boolean isFull3D() { return true; } to your Item class. public class RenderEvilStaff implements IItemRenderer { public static ResourceLocation tex = new ResourceLocation(Main.MODID, "textures/models/evilstafftexture.png"); private ModelEvilStaff staff; public RenderEvilStaff() { staff = new ModelEvilStaff(); } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { switch(type) { case EQUIPPED: return true; case EQUIPPED_FIRST_PERSON: return true; default: return false; } } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return false; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch(type) { case EQUIPPED: { GL11.glPushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(tex); GL11.glScalef(1.4F, 1.0F, 1.4F); GL11.glRotatef(90, 0F, 1F, 0F); GL11.glRotatef(100, 1F, 0F, 0F); GL11.glRotatef(10, 1F, 0F, 1F); GL11.glTranslatef(0.06F, -1.1F, -0.45F); this.staff.renderModel(0.0625F); GL11.glPopMatrix(); } case EQUIPPED_FIRST_PERSON: { GL11.glPushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(tex); GL11.glScalef(1.4F, 1.0F, 1.4F); GL11.glRotatef(90, 0F, 1F, 0F); GL11.glRotatef(100, 1F, 0F, 0F); GL11.glRotatef(10, 1F, 0F, 1F); boolean isFirstPerson = false; if(data[1] != null && data[1] instanceof EntityPlayer) { if(!((EntityPlayer)data[1] == Minecraft.getMinecraft().renderViewEntity && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0 && !((Minecraft.getMinecraft().currentScreen instanceof GuiInventory || Minecraft.getMinecraft().currentScreen instanceof GuiContainerCreative) && RenderManager.instance.playerViewY == 180.0F))) { GL11.glTranslatef(0.06F, -1.1F, -0.45F); }else{ isFirstPerson = true; } }else{ GL11.glTranslatef(0.06F, -1.1F, -0.45F); } this.staff.renderModel(0.0625F); GL11.glPopMatrix(); } default: break; }} Then render your model. (You can adjust the size and rotation and stuff with the GL11 methods.)
  20. I'm not sure but maybe this works: public boolean canAttackClass(Class class) { return redEntitySomething.class != class && blueEntitySomething.class != class; } I saw this in the source code of minecraft somewhere. I forget where.
  21. I do not have an idea how to stop overriding blocks with airblocks lol.. Could you give me a tip or something? Or how you would do it?
  22. Now it's kinda better... But it still overrides block's I dont want.. I check the blocks under the floor block too. Maybe I messed up the code again.. public class ForestGen implements IWorldGenerator { static final int strWidth = 18; static final int strHeight = 7; static final int strDepth = 17; private Schematic schematic; public ForestGen(Schematic schematic) { this.schematic = schematic; } public static boolean isStructureLocationValid(World world, int x, int y, int z, int blocksLength, int blocksHeight, int blocksWidth) { for (int i = x; i <= blocksLength; i++) { for (int j = y; j <= blocksHeight; j++) { for (int k = z; k <= blocksWidth; k++) { if(!isBlockValid(world, x, y, z)) { return false; } } } } for(int a = x; a <= blocksLength; a++) { for(int c = z; c <= blocksWidth; c++) { if(!isGroundValid(world, a, y, c)) { return false; } } } return true; } public static boolean isBlockValid(World world, int x, int y, int z) { Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); Block blockBelow = world.getBlockState(new BlockPos(x, y - 1, z)).getBlock(); if(block.getMaterial() == Material.plants && isValidBlock(blockBelow, world, x, y, z)) { return true; }if(block.isAir(world, new BlockPos(x, y, z))) { return true; }if (block == Blocks.snow_layer && isValidBlock(blockBelow, world, x, y, z)) { return true; } return false; } public static boolean isGroundValid(World world, int x, int y, int z) { Block groundBlock = world.getBlockState(new BlockPos(x, y - 1, z)).getBlock(); if(isValidBlock(groundBlock, world, x, y, z)) { return true; } return false; } public static boolean isValidBlock(Block block, World world, int x, int y, int z) { block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); if(block == Blocks.dirt || block == Blocks.grass || block == Blocks.stone) { return true; } return false; } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if(random.nextInt(200) == 0) { int x = chunkX * 16 + random.nextInt(16); int z = chunkZ * 16 + random.nextInt(16); int y = getWorldHeightAt(world, x, z); if(isStructureLocationValid(world, x, y, z, strWidth, strHeight, strDepth)) { if(world.getBiomeGenForCoords(new BlockPos(x, y, z)) == BiomeGenBase.forest) { schematic.generate(world, x, y, z); System.out.println("FOREST DUNGEON GENERATED!"); } System.out.println("FOREST DUNGEON SPOT WAS NOT VALID"); } } } private static int getWorldHeightAt(World world, int x, int z) { int height = 0; for(int i = 0; i < 255; i++) { if(world.getBlockState(new BlockPos(x, i, z)).getBlock().isSolidFullCube()) { height = i; } } return height; } }
  23. public boolean isBlockValid(World world, BlockPos pos) { Block block = world.getBlockState(pos); if(block.getMaterial() == Material.plant) { return true; }if(block == Blocks.air){ return true; } return false; } Because I wanted to override plants too, I tryed this. Also, maybe I will add these methods to a structure helper class or something.. So I can use it for other Structures. This should work I think.
  24. Yeah with the code I posted up there, I would only check the edges.. A simple and better one I came up with would look like this: public boolean isLocationValid(World world, int x, int y, int z, int blocksLength, int blocksHeight, int blocksWidth) { for (int i = x; i <= blocksLength; i++) { for (int j = y; j <= blocksHeight; j++) { for (int k = z; k <= blocksWidth; k++) { if (!world.getBlockState(new BlockPos(i, j, k)).getBlock() == Blocks.air) { return false; } } } } return true; } The last code was kinda messed up.. I just added so many unneccesary things like flags and stuff.. and it doesn't even check all blocks.. But this one should do it right? And later I could add some more things to override plants.. Can I check the if the block is a plant? Some thing like: if(world.getBlockState(x, y, z) == Material.plant) The check didn't made sense I think, but I think you understand what I mean.. EDIT: Found out how to check the material: world.getBlockState(new BlockPos(x, y, z)).getMaterial() == Material.plant I can't test the codes because I am not home right now.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.