TheGreyGhost
Members-
Posts
3280 -
Joined
-
Last visited
-
Days Won
8
Everything posted by TheGreyGhost
-
[SOLVED] ProxyInjector LoaderException crash
TheGreyGhost replied to PizzAna's topic in Modder Support
Hi My version of forge says this at cpw.mods.fml.common.ProxyInjector.inject(ProxyInjector.java:68) if (!target.getType().isAssignableFrom(proxy.getClass())) { FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, targ.getClassName(), targ.getObjectName()); throw new LoaderException(); } Looks to me like your @SidedProxy declaration is wrong for one of the three mods loaded, not necessarily the one whose code you showed? Could put a breakpoint there and find out easily enough? -TGG -
No worries, good luck tracking it down, let us know when you find the problem yeah? -TGG
-
Hi If you're only interested in sheep - first do if (target instanceof EntitySheep) { EntitySheep theSheep = (EntitySheep)target // rest of your code here, working on theSheep } Don't bother casting to IShearable. -TGG
-
[SOLVED] Canceling Hurt Animation and Sound
TheGreyGhost replied to firstdwarf's topic in Modder Support
Hi Tracing through the DamageSource it looks like you can: damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity); public static DamageSource causeArrowDamage(EntityArrow par0EntityArrow, Entity par1Entity) { return (new EntityDamageSourceIndirect("arrow", par0EntityArrow, par1Entity)).setProjectile(); } public class EntityDamageSourceIndirect extends EntityDamageSource { private Entity indirectEntity; public EntityDamageSourceIndirect(String par1Str, Entity par2Entity, Entity par3Entity) { super(par1Str, par2Entity); this.indirectEntity = par3Entity; and EntityDamageSourceIndirect: public Entity getEntity() { return this.indirectEntity; } The event parameter provides you with the damage source event.source -TGG -
Hi Yeah there's a bit of a problem with your code- EntitySheep.onSheared(...) when you call mySheep.onSheared, you are saying "shear mySheep". But of course you need to tell it which sheep to shear. Your current code attempts to say "shear the definition of a sheep" which is very different. Luckily you have something that might be a sheep already (i.e. target) if (target instanceof EntitySheep) { (EntitySheep)target.onSheared( ..etc.. ) } -TGG
-
Why doesn't this onBlockActivated method work?
TheGreyGhost replied to MrProg's topic in Modder Support
Hi If you have nothing in your hand, par5EntityPlayer.getCurrentEquippedItem() returns null. If you try to call a method on it, you get a null pointer exception. So you need to make sure it's not null first. -TGG -
Hi no worries, you understood me correctly, you need to include the parameters but you can use any value you want (including null for the ItemStack) because the code won't use them. -TGG
-
Hi you're right, there are more than one. One on the client side, and several on the server side. See http://greyminecraftcoder.blogspot.com.au/2013/10/server-side-class-linkage-map.html (MinecraftServer.worldInstances) and http://greyminecraftcoder.blogspot.com.au/2013/10/client-side-class-linkage-map.html If your method in Block is activated on both sides, it will probably be given a World object, which you can use to get to the right WorldInfo on both sides. -TGG
-
Hi onSheared is applied to the sheep not the item Have a look in EntitySheep.onSheared it's pretty simple and it doesn't even use any of the parameters you give it. What you should do is just call EntitySheep.onSheared yourself, it will return an ArrayList containing one or more wool, see ItemShears.itemInteractionWithEntity to see what to do with it. (Or just ignore if you don't care about the wool) Alternatively you could call ItemShears.itemInteractionWithEntity, giving it the parameter it expects (eg a dummy shears and the sheep you want to shear). -TGG
-
[SOLVED] Canceling Hurt Animation and Sound
TheGreyGhost replied to firstdwarf's topic in Modder Support
Hi I tried tracing through the chain of calls starting from EntityArrow and I wound up in EntityPlayer: public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { if (ForgeHooks.onLivingAttack(this, par1DamageSource, par2)) return false; It looks to me like you should be able to register a LivingAttackEvent handler, inspect the source to see if it's an arrow, and if so cancel it. Have you used the Forge Event Bus before? They're pretty simple once you've seen it once. https://github.com/TheGreyGhost/TestFramework/blob/master/src/testframework/clientonly/EventHandlers/ItemEventHandler.java Just replace DrawBlockHighlightEvent with LivingAttackEvent and change the method code to suit. And register your handler in postInit MinecraftForge.EVENT_BUS.register(new ItemEventHandler()); Easy as that... -TGG -
Hi I had a quick look through the code, didn't notice anything obvious, suggest you could add a few logging statements to narrow it down, eg @SideOnly(Side.CLIENT) public Icon getIcon(int side, int metadata){ System.out.println("getIcon side = " + side + ", metadata = " + metadata); return side == metadata ? this.iconFront : this.blockIcon; } and System.out.println("onBlockPlacedBy b0 = " + b0); if (l != this.blockID && i1 != this.blockID && j1 != this.blockID && k1 != this.blockID) { System.out.println("setBlockMetadataWithNotify b0 = " + b0); par1World.setBlockMetadataWithNotify(x, y, z, b0, 3); } etc -TGG
-
Hi My guess is that your code is doing something in a very inefficient way. Or your map is huge. You could try looking at the vanilla code for inspiration (Ocean biome?). Alternatively you could try a bit of benchmarking of your code to see which parts are taking so long - if your IDE doesn't do profiling you could add System.out.println at a couple of well-chosen locations. -TGG
-
Hi Rendering in inventory doesn't use block brightness settings, it uses "normals" instead. See RenderBlocks.renderBlockAsItem eg tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1.0F, 0.0F); this.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(par1Block, 0)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); this.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(par1Block, 1)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1.0F); this.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(par1Block, 2)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); this.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(par1Block, 3)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1.0F, 0.0F, 0.0F); this.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(par1Block, 4)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); this.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(par1Block, 5)); tessellator.draw(); see also this link at the end of the page http://greyminecraftcoder.blogspot.com.au/2013/09/custom-item-rendering-using.html -TGG -TGG
-
test them both?
-
Hi Some hints final float LENGTH_OF_LOOK = 8.0; Vec3 playerLook = player.getLook(partialTick); Vec3 playerEyesPos = player.worldObj.getWorldVec3Pool().getVecFromPool(playerOriginX, playerOriginY, playerOriginZ); Vec3 startVec = playerEyesPos.addVector(0, 0, 0); Vec3 endVec = playerEyesPos.addVector(playerLook.xCoord * LENGTH_OF_LOOK, playerLook.yCoord * LENGTH_OF_LOOK, playerLook.zCoord * LENGTH_OF_LOOK); AxisAlignedBB expandedAABB = AxisAlignedBB.getBoundingBox(AABBminX, AABBminY, AABBminZ, AABBmaxX, AABBmaxY, AABBmaxZ); MovingObjectPosition traceResult = expandedAABB.calculateIntercept(startVec, endVec); traceResult will be null if no hit, or traceResult.hitVec will contain the answer if it is. -TGG
-
Was introduced some time between 1.6.2 and 1.6.4. Guess I should upgrade my Forge more often...
-
Make a TileEntity render with a smaller bounding box?
TheGreyGhost replied to Busti's topic in Modder Support
Hi override TileEntity.getRenderBoundingBox to return the full bounding box? eg as for beacon? -TGG -
By crikey so it does, how on earth did I miss that? Was it recently introduced? That's exactly what I need, thanks! -TGG
-
Hi Perhaps you could describe in a bit more detail what you're trying to do in terms of gameplay, because I'm a bit confused about exactly what you're trying to do eg Once I've placed my Block of Repulsion, it won't let me add a second block of repulsion next to it unless I right-click on the ground instead of the block. You might want to look at forge event onPlayerInteract(RIGHT_CLICK_BLOCK). -TGG
-
Keen, glad you got it to work! Re graceful sliding back to zero - I suggest you could add a "shutdown animation" flag in addition to your existing"start animation flag", to make it complete the cycle that it's currently on then stop at zero. You could do this by: In your pump method, add the line long numberOfCyclesSinceStart = (System.currentTimeMillis() + animationOffset) / CYCLE_TIME_IN_MS; When your "stop animation flag" is triggered, calculate which cycle it's currently on, save it to the tileentity, and keep animating until you see numberOfCyclesSinceStart increase above the saved value (i.e. it is about to start the next pump cycle), then force "time" to zero and hold it there until the pump starts again. Alternatively you could use your "shutdown animation" flag to choose a completely separate pump method for updating the animation. -TGG
-
Hi I have been trying to find a way to capture scroll wheel actions to do something else with them instead of change current item. The vanilla code polls Mouse.getEventDWheel(); and jumps straight to InventoryPlayer.changeCurrentItem. Perhaps Forge could provide a hook in changeCurrentItem? Or even better, a more flexible way to intercept Mouse and Keyboard events before the vanilla code sees them, especially in Minecraft.runTick()? -TGG
-
Threading issues with Block.setBlockBoundsBasedOnState
TheGreyGhost replied to Sangar's topic in Modder Support
Hi I think you might be right. setBlockBoundsOnState is used mostly for rendering but also for collision/hit detection on the server eg arrow. Guess they hope that nobody will notice in-game. Have you tested it to verify? -TGG -
Grenade with a Blindness on Explode Help ! Please
TheGreyGhost replied to Heltrato's topic in Modder Support
Hi I'm having a bit of trouble seeing how your code is supposed to work. As far as I can tell, you use onUpdate to see if any living entities touch the grenade (collide with the boundingbox), and when they do, apply a blindness effect and explode the grenade. Is that what you intended? And if so, what doesn't work? -TGG -
Hi Does it render anything at all? If not, you're probably drawing the box at the wrong coordinates. You should set up the x,y,z to match what you see in RenderGlobal.drawSelectionBox, see below. The key point is that it calculates an interpolated current position for the player (d0, d1, d2) , and subtracts this from the bounding box coordinates (using getOffsetBoundingBox). -TGG public void drawSelectionBox(EntityPlayer par1EntityPlayer, MovingObjectPosition par2MovingObjectPosition, int par3, float par4) { if (par3 == 0 && par2MovingObjectPosition.typeOfHit == EnumMovingObjectType.TILE) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F); GL11.glLineWidth(2.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(false); float f1 = 0.002F; int j = this.theWorld.getBlockId(par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ); if (j > 0) { Block.blocksList[j].setBlockBoundsBasedOnState(this.theWorld, par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ); double d0 = par1EntityPlayer.lastTickPosX + (par1EntityPlayer.posX - par1EntityPlayer.lastTickPosX) * (double)par4; double d1 = par1EntityPlayer.lastTickPosY + (par1EntityPlayer.posY - par1EntityPlayer.lastTickPosY) * (double)par4; double d2 = par1EntityPlayer.lastTickPosZ + (par1EntityPlayer.posZ - par1EntityPlayer.lastTickPosZ) * (double)par4; this.drawOutlinedBoundingBox(Block.blocksList[j].getSelectedBoundingBoxFromPool(this.theWorld, par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ).expand((double)f1, (double)f1, (double)f1).getOffsetBoundingBox(-d0, -d1, -d2)); } GL11.glDepthMask(true); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); } }
-
Hi If you've only got a couple of different textures, I'd suggest you just make a different sword for each texture. That's a lot easier when you're just starting with modding. -TGG