Posted December 18, 20168 yr Hey there, So I have a TE that uses 4 stands as a crafting mechanic, however, I wanted to add a 'sacrifice' portion to it.. However, I'm having issues with getting the entity from the wrapper... Which looks like: public class StandRecipeHandler{ public ItemStack input; public ItemStack output; public ItemStack modifier1; public ItemStack modifier2; public ItemStack modifier3; public ItemStack modifier4; public EntityLivingBase sacrifice; public int requiredMana; public float[] particleColor; public int time; public StandRecipeHandler(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int requiredMana, int time, float[] particleColor, EntityLivingBase sacrifice){ this.input = input; this.output = output; this.modifier1 = modifier1; this.modifier2 = modifier2; this.modifier3 = modifier3; this.modifier4 = modifier4; this.sacrifice = sacrifice; this.requiredMana = requiredMana; this.particleColor = particleColor; this.time = time; } } I'm creating the recipes via: public final class StandRecipes{ public static final ArrayList<StandRecipeHandler> MAIN_PAGE_RECIPES = new ArrayList<StandRecipeHandler>(); public static StandRecipeHandler recipeDiamond; public static StandRecipeHandler recipeNetherStar; public static StandRecipeHandler recipeEmpoweredBloodstone; public static EntityChicken chicken; public static void init(){ ModUtil.LOGGER.info("Initializing Sacrifice Recipes"); PlentifulMiscAPI.addStandRecipe(new ItemStack(Items.GOLD_INGOT), new ItemStack(Items.DIAMOND), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), 7500, 100, new float[]{1F, 91F/255F, 76F/255F}, chicken); recipeDiamond = RecipeUtil.lastStandRecipe(); PlentifulMiscAPI.addStandRecipe(new ItemStack(Items.APPLE), new ItemStack(Items.NETHER_STAR), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), 7500, 100, new float[]{1F, 91F/255F, 76F/255F}, chicken); recipeNetherStar = RecipeUtil.lastStandRecipe(); // PlentifulMiscAPI.addStandRecipe(new ItemStack(InitItems.item_gems, 1, 0), new ItemStack(InitItems.item_gems_empowered, 1, 0), new ItemStack(Items.GOLD_INGOT), new ItemStack(Items.GLOWSTONE_DUST), new ItemStack(Items.GOLD_INGOT), new ItemStack(Items.GLOWSTONE_DUST), 15000, 250, new float[]{1F, 0, 0}); recipeEmpoweredBloodstone = RecipeUtil.lastStandRecipe(); } } And trying to access it via: this.entityForSacrifice = recipe.sacrifice; here is the entire TE for reference: @Override public void updateEntity() { super.updateEntity(); if(!worldObj.isRemote) { List<StandRecipeHandler> recipes = getRecipesForInput(this.slots.getStackInSlot(0)); EntityPlayer player = this.getPlayer(); if(!recipes.isEmpty() && player != null){ for(StandRecipeHandler recipe : recipes) { TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe); if (modifierStands != null) { this.recipeForRenderIndex = PlentifulMiscAPI.STAND_RECIPES.indexOf(recipe); this.processTime++; boolean done = this.processTime >= recipe.time; this.entityForSacrifice = recipe.sacrifice; System.out.print(entityForSacrifice); for (TileEntityDisplayStand stand : modifierStands) { if (done) { stand.slots.decrStackSize(0, 1); } } if (this.processTime % 5 == 0 && this.worldObj instanceof WorldServer) { boolean almostDone = this.processTime + 40 >= recipe.time; if (!almostDone) { ((WorldServer) this.worldObj).spawnParticle(EnumParticleTypes.PORTAL, false, this.pos.getX() + .5, this.pos.getY() + 1.1, this.pos.getZ() + .5, 10, 0, 0, 0, 0.5D); // entityNear.attackEntityFrom(DamageSource.lightningBolt, 10f); // this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, entityNear.getPosition().getX(), entityNear.getPosition().getY(), entityNear.getPosition().getZ(), false)); } } if (lineMode) { this.drawDamageLaser(this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f}); this.drawDamageLaser(this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f}); this.drawDamageLaser(this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f}); this.drawDamageLaser(this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f}); } if (done) { ((WorldServer) this.worldObj).spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, false, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 100, 0, 0, 0, 0.25D); this.slots.setStackInSlot(0, recipe.output.copy()); this.markDirty(); this.processTime = 0; this.recipeForRenderIndex = -1; } break; } } } else{ this.processTime = 0; this.entityForSacrifice = null; this.recipeForRenderIndex = -1; } if(this.lastRecipe != this.recipeForRenderIndex){ this.lastRecipe = this.recipeForRenderIndex; this.sendUpdate(); } } } Well atleast the update part... With this current system, it returns null. Thanks, Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr PlentifulMiscAPI.addStandRecipe(new ItemStack, blah blah blah..., chicken); "Chicken?" Chicken? Where is this variable defined? All you did is declare it. Why are you (trying to) pass a reference to a specific entity? If you want a recipe you need to pass something generic. Like, say, a class. PlentifulMiscAPI.addStandRecipe(new ItemStack, blah blah blah..., EntityChicken.class); Then you can check if the specific entity is the same type. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 18, 20168 yr Author Yes, however, what would I change my EntityLivingBase to?.. because I cannot simply do that because i'm asking for a EntityLivingBase, but passing entity chicken... I want to be able for all entities to be passed in there. Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr You want a class reference. If you want to insure that it is an EntityLivingBase, your "add this recipe" method accepts Class<? extends EntityLivingBase> Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 18, 20168 yr Author Fuck. I'm so fucking dumb. Will repost if something changes. Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr Author Okay, seems to be returning the entity now... Would you know how I would find an entity nearby the TileEntity? Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr Okay, seems to be returning the entity now... Would you know how I would find an entity nearby the TileEntity? World#getEntitiesInAABB(...) VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 18, 20168 yr Author What does it want for the first parameter? Cant really figure it out.. and for the aabb would I do: new AxisAlignedBB(range, range, range, -range, -range, -range) range being 5 Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr What does it want for the first parameter? The class of the entity you are interested in. e.g. EntityLivingBase.class Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 18, 20168 yr Author if(worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(range, range, range, -range, -range, -range))); This, still is erroring on the parameter saying it wants java.lang.Class<? extends T> I feel like a fucking retard.. maybe because I'm running on 5 hours of sleep Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr if(worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(range, range, range, -range, -range, -range))); This, still is erroring on the parameter saying it wants java.lang.Class<? extends T> I feel like a fucking retard.. maybe because I'm running on 5 hours of sleep Cant do anything without the crash we can't do anything... VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 18, 20168 yr Author No crash, just an IDE error. Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr No crash, just an IDE error. Is EntityLivingBase imported? And if it is refresh your IDE. Edit: That is also not a proper if statement. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 18, 20168 yr Author No, Everything is working fine, the full error : Wrong 1st argument type. Found: 'java.lang.Class<net.minecraft.entity.EntityLivingBase>', required: 'java.lang.Class<? extends T> Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr No, Everything is working fine, the full error : Wrong 1st argument type. Found: 'java.lang.Class<net.minecraft.entity.EntityLivingBase>', required: 'java.lang.Class<? extends T> Did you fix the if statement? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 18, 20168 yr Author No the (worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(range, range, range, -range, -range, -range)) needs a java.lang.Class<? extends T> Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr No the (worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(range, range, range, -range, -range, -range)) needs a java.lang.Class<? extends T> Post your whole class please. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 18, 20168 yr Author Fixed it, however, now its not detecting the entities... @Override public void updateEntity() { super.updateEntity(); if(!worldObj.isRemote) { List<StandRecipeHandler> recipes = getRecipesForInput(this.slots.getStackInSlot(0)); EntityPlayer player = this.getPlayer(); if(!recipes.isEmpty() && player != null){ for(StandRecipeHandler recipe : recipes) { TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe); List<EntityLivingBase> entityLivingBases = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(5, 5, 5, -5, -5, -5)); System.out.println(entityLivingBases); if (modifierStands != null && entityLivingBases.contains(recipe.sacrifice)) { this.recipeForRenderIndex = PlentifulMiscAPI.STAND_RECIPES.indexOf(recipe); this.processTime++; boolean done = this.processTime >= recipe.time; for (TileEntityDisplayStand stand : modifierStands) { if (done) { stand.slots.decrStackSize(0, 1); } } if (this.processTime % 5 == 0 && this.worldObj instanceof WorldServer) { boolean almostDone = this.processTime + 40 >= recipe.time; if (!almostDone) { ((WorldServer) this.worldObj).spawnParticle(EnumParticleTypes.PORTAL, false, this.pos.getX() + .5, this.pos.getY() + 1.1, this.pos.getZ() + .5, 10, 0, 0, 0, 0.5D); // entityNear.attackEntityFrom(DamageSource.lightningBolt, 10f); // this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, entityNear.getPosition().getX(), entityNear.getPosition().getY(), entityNear.getPosition().getZ(), false)); } } if (lineMode) { this.drawDamageLaser(this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f}); this.drawDamageLaser(this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f}); this.drawDamageLaser(this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f}); this.drawDamageLaser(this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f}); } if (done) { ((WorldServer) this.worldObj).spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, false, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 100, 0, 0, 0, 0.25D); this.slots.setStackInSlot(0, recipe.output.copy()); this.markDirty(); this.processTime = 0; this.recipeForRenderIndex = -1; } break; } } } else{ this.processTime = 0; this.recipeForRenderIndex = -1; } if(this.lastRecipe != this.recipeForRenderIndex){ this.lastRecipe = this.recipeForRenderIndex; this.sendUpdate(); } } } is the function that i'm changing. Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr Two things [*]Your World#getEntitiesWithinAABB(...) needs to be relative to the TEs position. [*]Second what is recipe.sacrifice? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 18, 20168 yr Author public class StandRecipeHandler{ public ItemStack input; public ItemStack output; public ItemStack modifier1; public ItemStack modifier2; public ItemStack modifier3; public ItemStack modifier4; public Class<? extends EntityLivingBase> sacrifice; public int requiredMana; public float[] particleColor; public int time; public StandRecipeHandler(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int requiredMana, int time, float[] particleColor, Class<? extends EntityLivingBase> sacrifice){ this.input = input; this.output = output; this.modifier1 = modifier1; this.modifier2 = modifier2; this.modifier3 = modifier3; this.modifier4 = modifier4; this.sacrifice = sacrifice; this.requiredMana = requiredMana; this.particleColor = particleColor; this.time = time; } } the recipe.sacrifice is referenced towards this, which is set in the recipes. ex: PlentifulMiscAPI.addStandRecipe(new ItemStack(Items.APPLE), new ItemStack(Items.NETHER_STAR), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), 7500, 100, new float[]{1F, 91F/255F, 76F/255F}, EntityChicken.class); and this still returns nothing: List<EntityLivingBase> entityLivingBases = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(this.getPos().getX()+5, this.getPos().getY()+5, this.getPos().getY()+5, this.getPos().getX()-5, this.getPos().getY()-5, this.getPos().getZ()-5)); Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr public class StandRecipeHandler{ public ItemStack input; public ItemStack output; public ItemStack modifier1; public ItemStack modifier2; public ItemStack modifier3; public ItemStack modifier4; public Class<? extends EntityLivingBase> sacrifice; public int requiredMana; public float[] particleColor; public int time; public StandRecipeHandler(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int requiredMana, int time, float[] particleColor, Class<? extends EntityLivingBase> sacrifice){ this.input = input; this.output = output; this.modifier1 = modifier1; this.modifier2 = modifier2; this.modifier3 = modifier3; this.modifier4 = modifier4; this.sacrifice = sacrifice; this.requiredMana = requiredMana; this.particleColor = particleColor; this.time = time; } } the recipe.sacrifice is referenced towards this, which is set in the recipes. ex: PlentifulMiscAPI.addStandRecipe(new ItemStack(Items.APPLE), new ItemStack(Items.NETHER_STAR), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE), 7500, 100, new float[]{1F, 91F/255F, 76F/255F}, EntityChicken.class); and this still returns nothing: List<EntityLivingBase> entityLivingBases = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(this.getPos().getX()+5, this.getPos().getY()+5, this.getPos().getY()+5, this.getPos().getX()-5, this.getPos().getY()-5, this.getPos().getZ()-5)); Then it will never contain your sacrifice, because it will return an instance of the class and not the class itself. You will want to do an instanceof check instead. Plus your AxisAlignedBB needs to have the smaller (aka "-5"s) first instead. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 18, 20168 yr Author How would I reference the recipe.sacrifice ? I cannot do instanceof due to it not being a class, but a variable. Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr clazz.isInstance(obj) Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 18, 20168 yr Author List<EntityLivingBase> entityLivingBases = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(this.getPos().getX()-5, this.getPos().getY()-5, this.getPos().getY()-5, this.getPos().getX()+5, this.getPos().getY()+5, this.getPos().getZ()+5)); if (modifierStands != null && StandRecipeHandler.class.isInstance(entityLivingBases)) { Seems to be ruturning false on StandRecipeHandler.class.isInstance(entityLivingBases) , should I be iterating though all the list? or maybe my instance isnt working properly. Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
December 18, 20168 yr StandRecipeHandler.class.isInstance Ah for fuck's sake. That's your StandRecipeHandler.class, not your recipe's entity class. You want to reference the field, just like any other property of your recipe. StandRecipeHandler.sacrifice.isInstance(...) Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.