-
Posts
6157 -
Joined
-
Last visited
-
Days Won
59
Everything posted by Animefan8888
-
[1.10.2] Changing Item compound tag removes damage?
Animefan8888 replied to IceMetalPunk's topic in Modder Support
100%. Below is the full code of the block class, and the only output I'm getting in the console is "Player collided! On server?: false" (and only once per collision, not twice like you'd expect from a server and client execution). package com.IceMetalPunk.amethystic.AmethysticBlocks; import java.util.Random; import com.IceMetalPunk.amethystic.Amethystic; import net.minecraft.block.Block; import net.minecraft.block.BlockFire; import net.minecraft.block.material.MapColor; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockEnderFlame extends BlockFire { public BlockEnderFlame() { super(); this.setUnlocalizedName("ender_flame").setRegistryName(Amethystic.MODID, "ender_flame"); } @Override public int tickRate(World worldIn) { return 10; } @Override public MapColor getMapColor(IBlockState state) { return MapColor.CYAN; } @Override // So the Ender Flame doesn't spread public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { Block block = world.getBlockState(pos.down()).getBlock(); int i = ((Integer) state.getValue(AGE)).intValue(); boolean flag = block.isFireSource(world, pos.down(), EnumFacing.UP); if (!flag && world.isRaining() && this.canDie(world, pos) && rand.nextFloat() < 0.2F + (float) i * 0.03F) { world.setBlockToAir(pos); } else if (i < 15) { state = state.withProperty(AGE, Integer.valueOf(i + 1)); world.setBlockState(pos, state, 4); world.scheduleUpdate(pos, this, this.tickRate(world) + rand.nextInt(10)); } else { world.setBlockToAir(pos); } } // Teleport the player when they walk through the flames with a linked // portkey @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; ItemStack mainItem = player.getHeldItemMainhand(); ItemStack offItem = player.getHeldItemOffhand(); if (mainItem != null && mainItem.getItem() == Amethystic.items.PORTKEY && mainItem.hasTagCompound()) { NBTTagCompound tag = mainItem.getTagCompound(); int x = tag.getInteger("linkX"), y = tag.getInteger("linkY"), z = tag.getInteger("linkZ"); System.out.println("Player collided! On server?: " + !player.worldObj.isRemote); mainItem.damageItem(1, player); // FIXME: Damage only occurs on // client, not server? player.setPositionAndUpdate(x, y, z); player.setFire(1); } else if (offItem != null && offItem.getItem() == Amethystic.items.PORTKEY && offItem.hasTagCompound()) { NBTTagCompound tag = offItem.getTagCompound(); int x = tag.getInteger("linkX"), y = tag.getInteger("linkY"), z = tag.getInteger("linkZ"); offItem.damageItem(1, player); player.setPositionAndUpdate(x, y, z); player.setFire(1); } } } } Put a println before you do any if checks and just a suggestion use the logger system as it tells you whether it is server or client. Maybe the println does that but i dont remember it that way. -
[1.8.9] Throwable Entity ... (all entitys get the same model?)
Animefan8888 replied to terraya's topic in Modder Support
In your renderer create an instance of your model and call render(). -
[1.10.2] Changing Item compound tag removes damage?
Animefan8888 replied to IceMetalPunk's topic in Modder Support
I know...which is what I don't understand. As I said, the method that calls the item damaging has a debug output that prints player.isServerWorld(). Every output from that is true; i.e. it's only being called on the server (or at least it *is* being called on the server). And yet everything else regarding the damage suggests it's only being called on the client. How is it possible for isServerWorld (which just wraps !world.isRemote anyway) to return true but the next line of code to run only on the client? Just to clear it up !world.isRemote is server side and world.isRemote is client side. In the code above you return if !world.isRemote without doing anything in Item#onItemRightClick. And for the player.isServerWorld() println how are we supposed to know with out seeing updated code. -
If this isnt called when an entity is attacked by an item from the player there would be no point in the methods existence. PlayerControllerMp#attackEntity calls other methods figure out which one happens before resistance times are sent that are in the items class that give you the target then deal the damage there (hopefully without recursion).
-
Ah, yes, that makes sense. Well, the actual amount of bonus damage still needs calibration, so I may end up recalculating based on the cooldown anyway. But first I need to figure out why it doesn't seem to be doing any bonus damage unless the amount is turned way, way up... *EDIT* Okay, odd...I threw in some debugging console logging, and it seems like target.attackEntityFrom() is returning false. Unfortunately, there are many reasons that would happen, so I guess it's time for me to step through and find out what's going on... *EDIT 2* Well...the importance of breakpoints, everyone. So it turns out the problem here is in hit-based resistance times. After getting hit, there's a small amount of time where an entity will only take damage if the attack is stronger than the previous attack. Since this attack is equivalent, and applied immediately after the first attack, it was being ignored by the resistance time. When I was testing with very high values, those were more than the "previous attack" strength, so it let them through. Okay, then. Now I have a place to start with fixing this. Time to see if I can actually reset the resistance timer in order to apply the second damage... *EDIT 3* If anyone's still reading this... So it turns out the resistance timer is a public member, so that was easy enough. However, in order to take cooldown into consideration, it introduces another problem: the bonus damage is triggering when the cooldown has just been reset from the normal attack, meaning it actually does no damage if cooldown is considered, and this code will only see a value of 0 for the cooldown no matter what. So is there a way to get the "previous cooldown", as it were? Or should I just be ignoring cooldown and having full bonus damage? (I thought about just dealing the equivalent of target.lastDamage, but that's also protected...I hope I won't have to hack my way through this via reflection...) I am currently wondering where entities are actually damage by the player now... the best way to figure this out would probably be to see where getDamageVsEntity() is called.
-
[SOLVED] Recolour Leaves for use with custom block
Animefan8888 replied to james090500's topic in Modder Support
I dont have any code at the moment so I cant tell you what to do exactly, but look at how BlockLeaves works. -
slotIndex is the inventory slot that the Slot represents. slotNumber is the index of the Slot in the Container . If a Container has slots from two inventories (e.g. a chest and a player), slotIndex will be 0 to X for the first inventory and 0 to Y for the second inventory, while slotNumber will be 0 to X+Y. I don't think there is. Ah, okay! That makes sense; thanks for the explanation. I wish I could make stack transfers work, but honestly, it's such a small detail that it's not worth remaking the enchantment container entirely just for it. Players will have to be content with click-and-drop Thanks again! Just extend ContainerEnchantment and GuiEnchantment and override transferStackInSlot in the container. Ahh the wonders of OOP.
-
Another way to do this would be like Extra Utilities. Having a master pipes and "slave" pipes.
-
[1.8.9] More effective replacement for thread.sleep?
Animefan8888 replied to CoalOres's topic in Modder Support
How do we help without seeing the stack trace (the log)? -
Create your own custom Material then one that will allow you and give you what you want. Just how to make a material which is solid, but you can move through it and it has something like air, that no shadows are thrown. I have no idea how to create such a material, even after looking into the Material class. Sadly i do not have any code available at the moment (school) so i would keep messing around with it until some makes a suggestion.
-
Create your own custom Material then one that will allow you and give you what you want.
-
Ah! Sounds like the elegant way to do it, thanks! Unfortunately, it's not quite working. It's behaving oddly: it will occasionally accept the stack of amethysts (the gem item I'm trying to make it accept), but it usually won't. When I try placing the amethysts in the slot and it doesn't accept it, my player's hand blinks in the background as if switching items, even though I'm not. And if I double-click in the lapis slot with amethysts, even when it doesn't accept them, it'll still pull a full stack from my inventory as if the gems were properly in the slot. Here's my event handler code: @SubscribeEvent public void onOpenContainer(PlayerContainerEvent.Open ev) { Container cont = ev.getContainer(); if (cont instanceof ContainerEnchantment) { ContainerEnchantment ench = (ContainerEnchantment) cont; Slot newSlot = new Slot(ench.tableInventory, 1, 35, 47) { List<ItemStack> ores = OreDictionary.getOres("gemLapis"); /** * Check if the stack is a valid item for this slot. Always true * beside for the armor slots. */ public boolean isItemValid(@Nullable ItemStack stack) { if (stack.getItem() == Amethystic.items.AMETHYST) { return true; } for (ItemStack ore : ores) if (OreDictionary.itemMatches(ore, stack, false)) return true; return false; } }; ench.inventorySlots.set(1, newSlot); } } Am I missing something here? Are you talking about shift clicking or normally placing the item into the slot? Could you show some images?
-
I already have a playerList that I iterate through ... is there a way to just change what I have so it won't send the message if it already sent? I added a range which at least stops the spamming in chat and console of the message, but seems to add lag to the game double inRange = this.getDistanceSqToEntity(entityplayer); if ( inRange < 1000.0D & inRange > 900.0D){ You want to send a message when your entity spawns but only once it spawns, create a boolean value on the entity and save it to NBT.
-
Power systems are relatively simple in nature. You need 'machines' that can recieve power, 'generators' which generate power, and some way of transfering that power. Meaning atleast the old way you need three interfaces one for generators that allows you to extract power from it, another one for machines that allows input, and one that allows for both input and output. The way you handle the input and output is all up to you. There is another way, you can achieve this with capabilities there is an EnergyHandler (i believe that is its name) that you can give TileEntities and which is basically a forge energy network.
-
"Create the subject"? What does that mean? "Put a seperate unit"? This aswell. Do you want it to function like a cake or like the vanilla potions.
-
[1.9.4] Changing the Dual Wielding System
Animefan8888 replied to Legoboy0109's topic in Modder Support
You would need to intercept the right clicking of the item either with an event or if it is your own item Item#.nItemRightClick(...). And in that you need to simulate left clicking either with the item probably manually. -
Custom Block model has incorrect collision box
Animefan8888 replied to james090500's topic in Modder Support
Meaning dont call super -
Show what you have.
-
Instead of nbt.setTag and the reading equivalent just set the nbt parameter to the one from the ItemStackHandler
-
Sorry, ContainerSifter. I should check the cart.....Cart works fine. The github link's ContainerSifter does not contain the transferStackInSlot method.
-
I have personally had this alot, to me that method seems to be very fickle. You never stated which container it was...is it ContainerOreCart? When does it happen when shift clicking your slots or the players inventory slots.