Jump to content

captaincleric

Members
  • Posts

    57
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

captaincleric's Achievements

Stone Miner

Stone Miner (3/8)

2

Reputation

  1. I'm not sure about the item/stack stuff, but I might be able to help with the entity capabilities, as I've added two of my own; mana, and spell research. I'm not sure about the @Capability, either, unfortunately. What I do know, is that I might be able to help you out with the entity capabilities. Here's the code for my mana stuff: PlayerManaCapability package com.nosrick.masterofmagic.capabilities; import com.nosrick.masterofmagic.MoMMod; import com.nosrick.masterofmagic.items.wands.ItemBaseWand; import com.nosrick.masterofmagic.packets.PlayerManaChangePacket; import com.nosrick.masterofmagic.utils.PlayerUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class PlayerManaCapability implements IBaseManaCapability { protected int m_Mana = 0; @Override public int GetMana() { return m_Mana; } @Override public void SetMana(int mana, EntityPlayer player) { ItemStack itemStack = PlayerUtils.FindWand(player); if(itemStack == null) return; ItemBaseWand wand = (ItemBaseWand)itemStack.getItem(); m_Mana = Math.min(wand.GetMaxMana(), mana); MoMMod.s_NetworkChannel.sendTo(new PlayerManaChangePacket(Integer.toString(m_Mana)), (EntityPlayerMP)player); } @Override public void SetManaNoUpdate(int mana) { m_Mana = mana; } @Override public NBTTagCompound saveNBTData() { NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("mana", m_Mana); return nbt; } @Override public void loadNBTData(NBTTagCompound compound) { m_Mana = compound.getInteger("mana"); } } PlayerManaCapabilityHandler package com.nosrick.masterofmagic.capabilities; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability.IStorage; import net.minecraftforge.common.capabilities.CapabilityManager; public class PlayerManaCapabilityHandler implements IStorage<IBaseManaCapability> { public static final PlayerManaCapabilityHandler s_ManaHandler = new PlayerManaCapabilityHandler(); @Override public NBTBase writeNBT(Capability<IBaseManaCapability> capability, IBaseManaCapability instance, EnumFacing side) { return instance.saveNBTData(); } @Override public void readNBT(Capability<IBaseManaCapability> capability, IBaseManaCapability instance, EnumFacing side, NBTBase nbt) { instance.loadNBTData((NBTTagCompound) nbt); } } PlayerManaFactory package com.nosrick.masterofmagic.capabilities; import java.util.concurrent.Callable; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; public class PlayerManaFactory implements Callable<IBaseManaCapability> { @Override public PlayerManaCapability call() throws Exception { return new PlayerManaCapability(); } } And finally PlayerManaProvider package com.nosrick.masterofmagic.capabilities; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.INBTSerializable; public class PlayerManaProvider implements ICapabilityProvider, INBTSerializable { @CapabilityInject(IBaseManaCapability.class) public static Capability<IBaseManaCapability> s_Mana = null; protected IBaseManaCapability m_Mana = null; public PlayerManaProvider(){ m_Mana = new PlayerManaCapability(); } public PlayerManaProvider(IBaseManaCapability mana){ this.m_Mana = mana; } public static IBaseManaCapability Get(EntityPlayer player) { if(player.hasCapability(s_Mana, null)) { return player.getCapability(s_Mana, null); } return null; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return s_Mana != null && capability == s_Mana; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (s_Mana != null && capability == s_Mana) return (T)m_Mana; return null; } @Override public NBTBase serializeNBT() { return m_Mana.saveNBTData(); } @Override public void deserializeNBT(NBTBase nbt) { m_Mana.loadNBTData((NBTTagCompound) nbt); } } These four parts combine to make CAPTAIN PLANET! my mana system, which allows players to cast spells. I'm not sure it'll help, but I hope it does!
  2. Thanks for the help, guys. Both posts really helped me out. Here's what my structures look like now!
  3. Honestly, I'd just generate your own noise. It might not be as random, but it can be faster. I personally use Math.Sin(i * Math.PI * 2 + Random.NextFloat()), where i is an integer that is incremented each time you request a random number. I'm not sure if Random.NextFloat() exists in Java, but you just want a floating point number between 0 and 1. This creates some nice, wavy noise and is pretty quick. Sorry I couldn't give you better help!
  4. Are you registering the items and recipes in the correct order?
  5. Just a shameless bump. Anyone got any ideas on how to get the block's data to set it to the correct facing/type?
  6. I found the problem. The loops must go Y, Z, X, not X, Y, Z, for some reason. That's just the way schematics are constructed, apparently. Which apparently is how pre-1.4 Minecraft did its chunks. Whoever did that is stupid. EDIT TO PREVENT DOUBLE POSTING: So my structure builds, now. The only problem I have is that the block metadata (I think) for the slabs and stairs are not set properly, so they are not the right type, or are oriented incorrectly, as appropriate.
  7. You have a few ways to handle this one. You could use the LivingEntityHurt event (I think), and check if it's the player being hurt or hurting something. If there's an event for the swinging of an item, you could check if it's a sword that a player is holding, and play the music then.
  8. Try putting a breakpoint on the else if statement, and seeing what the values are when it gets there. Something has to be set wrongly. I'm guessing it might be that isPressed() function, because the other two conditions look like they're set just fine in the if statement.
  9. Does it ever print out the "Fly disabled" message?
  10. Nope, no blocks except vanilla blocks, and no mods at all. I created a separate version just for building stuff for my mod.
  11. Could you post your RobotHelper class?
  12. Are you only spawning them through the egg, or are you spawning them in your code somewhere?
  13. I have a few questions about structures. First, is there a decent schematic exporter for 1.8.9? I've tried MCEdit and mineways, but they both (possibly) produce garbled junk, that in no way resembles what I've created. It doesn't seem to handle stairs or slabs very well. Second, why - if the schematics are alright, which I think they are - would it generate garbled junk? Here's my generation code: public static void PlaceStructure(Schematic structure, World world, BlockPos centre) { int i = 0; if(structure == null) return; for(int x = centre.getX() - structure.width / 2; x < centre.getX() + structure.width / 2; x++) { for(int y = centre.getY() - 1; y < centre.getY() - 1 + structure.height; y++) { for(int z = centre.getZ() - structure.length / 2; z < centre.getZ() + structure.length / 2; z++) { Block currentBlock = Block.getBlockById(structure.blocks[i]); i += 1; if(currentBlock != Blocks.air) { world.setBlockState(new BlockPos(x, y, z), currentBlock.getDefaultState()); } } } } } And here's my Schematic class: public class SchematicHandler { public Schematic get(String schematic) { try { InputStream is = this.getClass().getClassLoader().getResourceAsStream("assets/masterofmagic/schematics/" + schematic + ".schematic"); NBTTagCompound nbtdata = CompressedStreamTools.readCompressed(is); short width = nbtdata.getShort("Width"); short height = nbtdata.getShort("Height"); short length = nbtdata.getShort("Length"); byte[] blocks = nbtdata.getByteArray("Blocks"); byte[] data = nbtdata.getByteArray("Data"); System.out.println("schem size:" + width + " x " + height + " x " + length); NBTTagList tileentities = nbtdata.getTagList("TileEntities", 10); is.close(); return new Schematic(tileentities, width, height, length, blocks, data); } catch (Exception e) { System.out.println("I can't load schematic, because " + e.toString()); return null; } } public class Schematic { public NBTTagList tileentities; public short width; public short height; public short length; public byte[] blocks; public byte[] data; public Schematic(NBTTagList tileentities, short width, short height, short length, byte[] blocks, byte[] data) { this.tileentities = tileentities; this.width = width; this.height = height; this.length = length; this.blocks = blocks; this.data = data; } } } Here's one I made earlier:
  14. Hah! Was just about to post saying "Always check you've registered your capabilities" but you got there before me. So yeah, always check you've registered your capabilities. Thanks Choonster!
  15. I think I'm doing something stupid, but I just can't see past the code blindness. Here's the provider: package com.nosrick.masterofmagic.capabilities; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.INBTSerializable; public class PlayerResearchProvider implements ICapabilityProvider, INBTSerializable { @CapabilityInject(IBaseResearchCapability.class) public static Capability<IBaseResearchCapability> s_Research = null; protected IBaseResearchCapability m_Research = null; public PlayerResearchProvider() { m_Research = new PlayerResearchCapability(); } public PlayerResearchProvider(PlayerResearchCapability capability) { m_Research = capability; } public static IBaseResearchCapability Get(EntityPlayer player) { if(player.hasCapability(s_Research, null)) { return player.getCapability(s_Research, null); } return null; } @Override public NBTBase serializeNBT() { return m_Research.saveNBTData(); } @Override public void deserializeNBT(NBTBase nbt) { m_Research.loadNBTData((NBTTagCompound) nbt); } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return s_Research != null && capability == s_Research; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (s_Research != null && capability == s_Research) return (T)m_Research; return null; } } What am I doing wrong? Why is s_Research always null?
×
×
  • Create New...

Important Information

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