Jump to content

Tschipp

Forge Modder
  • Posts

    307
  • Joined

  • Last visited

Everything posted by Tschipp

  1. I'm not sure this is it, but there is a shade tag that you can set to false for each element in the model. The wiki reads this:
  2. At what point did I ever say the word "proxy"? I was just thinking it had something to do with the registration for the color handlers in the client proxy
  3. but why? There is nothing in my Common Proxy that would cause that... package tschipp.creativePlus.Proxies; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import tschipp.creativePlus.items.CustomItems; public class CommonProxy { public void preInit(FMLPreInitializationEvent event) { CustomItems.createItems(); } public void init(FMLInitializationEvent event) { } public void postInit(FMLPostInitializationEvent event) { } } Client Proxy: package tschipp.creativePlus.Proxies; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import tschipp.creativePlus.CreativePlus; import tschipp.creativePlus.items.CircleWand; import tschipp.creativePlus.items.CustomItems; import tschipp.creativePlus.items.FloodFill; import tschipp.creativePlus.items.ItemRenderRegister; import tschipp.creativePlus.items.NoiseFill; import tschipp.creativePlus.items.Wand; public class ClientProxy extends CommonProxy{ public void preInit(FMLPreInitializationEvent event) { super.preInit(event); } public void init(FMLInitializationEvent event) { super.init(event); ItemRenderRegister.registerItems(); if(CreativePlus.enableNoiseWand) { FMLClientHandler.instance().getClient().getItemColors().registerItemColorHandler(new NoiseFill(), CustomItems.noiseFill); } if(CreativePlus.enableFillWand) { FMLClientHandler.instance().getClient().getItemColors().registerItemColorHandler(new FloodFill(), CustomItems.floodFill); } if(CreativePlus.enablePointWand) { FMLClientHandler.instance().getClient().getItemColors().registerItemColorHandler(new Wand(), CustomItems.wand); } if(CreativePlus.enableCircleWand) { FMLClientHandler.instance().getClient().getItemColors().registerItemColorHandler(new CircleWand(), CustomItems.circleWand); } } public void postInit(FMLPostInitializationEvent event) { super.postInit(event); } }
  4. Hm, I crash again, but it seems that the problem isn't even this mod, but another mod in my dev environment. Log: http://pastebin.com/eYNnRX6Y When I try and remove the mod, i crash because of another mod...
  5. Ah I see, so I'll just add a empty method to my common proxy. Thanks!
  6. Because I didn't know how else to access the getClientWorld() method from my client proxy. How do I get the client proxy from my proxy variable?
  7. Alright, so I now removed the @SidedProxy(clientSide = CLIENT_PROXY, serverSide = COMMON_PROXY) part, but it still crashes.
  8. I know, I also have this in my main mod class: @SidedProxy(clientSide = CLIENT_PROXY, serverSide = COMMON_PROXY) public static CommonProxy proxy; Sorry if I wasn't clear
  9. You could probably use Forge's ServerChatEvent
  10. I do this, works for me. public static CreativeTabs buildingBlocks = new CreativeTabs("moreBuildingBlocks"){ @Override public Item getTabIconItem(){ return Item.getItemFromBlock(BBBlocks.cotswoldBricks); } }; Keep in mind this is 1.10.2, in 1.11 I believe you need to return a ItemStack
  11. Welp, here I am again. I found out the mod crashes servers instantly... I'm pretty sure it's because of this here in my main mod class: @SidedProxy(clientSide = CLIENT_PROXY, serverSide = COMMON_PROXY) public static ClientProxy clientProxy; In any case,here is the log: http://pastebin.com/xvTbWXQN I have since removed it, but now there's an error in my PacketHandler class: EntityPlayer toSync = (EntityPlayer)FakeName.[color=red]clientProxy[/color].getClientWorld().getEntityByID(message.entityId); So I changed it to this: EntityPlayer toSync = (EntityPlayer)FakeName.proxy.getClientWorld().getEntityByID(message.entityId); but now it's erroring at getClientWorld(), because that is a method in my ClientProxy class. Here it is: package tschipp.fakename; import net.minecraft.client.Minecraft; import net.minecraft.world.World; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class ClientProxy extends CommonProxy { public void preInit(FMLPreInitializationEvent event) { super.preInit(event); } public void init(FMLInitializationEvent event) { super.init(event); } public void postInit(FMLPostInitializationEvent event) { super.postInit(event); } public World getClientWorld() { return Minecraft.getMinecraft().theWorld; } } The problem now is, how do I get access to the getClientWorld method from my PacketHandler class?
  12. Well, apparently that really was all it took It works fine now! Thank you so much! I added the working version to github, in case I still find a bug...
  13. Added it. And no, I didn't ignore it, I just haven't implemented it yet.
  14. I don't really. I only use it internally for the player's name, and it's just easier to replace the '&' with a '§' than having to replace them all with some huge piece of code...
  15. https://github.com/Tschipp/fakename/tree/master/src/main/java/tschipp/fakename Here it is. I've never used GitHub, tell me if something doesn't work.
  16. I added this event: @SubscribeEvent public void onJoinWorld(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event) { EntityPlayer player = event.player; if(!player.worldObj.isRemote) { WorldServer serverWorld = (WorldServer) event.player.worldObj; Iterator<? extends EntityPlayer> playersTracking = serverWorld.getEntityTracker().getTrackingPlayers(player).iterator(); if(player.getEntityData() != null && player.getEntityData().hasKey("fakename")) { while(playersTracking.hasNext()) { FakeName.network.sendTo(new FakeNamePacket(player.getEntityData().getString("fakename") , player.getEntityId()), (EntityPlayerMP) playersTracking.next()); } } } } Packet Handler: package tschipp.fakename; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHand; import net.minecraft.util.IThreadListener; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import tschipp.creativePlus.items.CustomItems; import tschipp.creativePlus.network.NoisePacket; public class FakeNamePacketHandler implements IMessageHandler<FakeNamePacket, IMessage>{ @Override public IMessage onMessage(final FakeNamePacket message, final MessageContext ctx) { EntityPlayer toSync = (EntityPlayer)FakeName.clientProxy.getClientWorld().getEntityByID(message.entityId); if(toSync != null) { NBTTagCompound tag = toSync.getEntityData(); tag.setString("fakename", message.fakename); toSync.refreshDisplayName(); } return null; } } It still isn't working. What am I missing here?
  17. Thanks for the feedback. How exactly do I get the player from my proxy? And about the EntityID int: Why will it sometimes crash and what can I do against that? Should I not even send the EntityID? Also, I added this event. It seems to work for the player hosting the lan world, players with a name get displayed correctly, but the joining player doesn't see the host's name. @SubscribeEvent public void onTracking(PlayerEvent.StartTracking event) { if(event.getTarget() instanceof EntityPlayer) { EntityPlayer targetPlayer = (EntityPlayer) event.getTarget(); System.out.println("The Targeted Player is " + targetPlayer); if(targetPlayer.getEntityData() != null && targetPlayer.getEntityData().hasKey("fakename")) { EntityPlayerMP toRecieve = (EntityPlayerMP) event.getEntityPlayer(); System.out.println("The Recieving Player is " + toRecieve); FakeName.network.sendTo(new FakeNamePacket(targetPlayer.getEntityData().getString("fakename") , targetPlayer.getEntityId()), toRecieve); } } }
  18. Right now I'm not sure when I should send the packet... I obviously send it when a player executes the command, but the problem there is that if the player rejoins the server, all the names for the other players will be lost for him. The other players do see the player's fake name though, as I send the packet also when a player joins the world. I originally wanted to send the packet when a player is rendered, but the RenderLivingEvent doesn't seem to be for that purpose, as I cannot detect if the player has any data stored on him. I now send it during LivingUpdateEvent, is that a bad idea performance wise? I'm not sure how the packets affect the performance. This is my packet at its current state. Is that any better, or am I still doing everything wrong? Packet: package tschipp.fakename; import io.netty.buffer.ByteBuf; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; public class FakeNamePacket implements IMessage { public String fakename; public int entityId; public FakeNamePacket() { } public FakeNamePacket(String fakename, int entityID) { this.fakename = fakename; this.entityId = entityID; } @Override public void fromBytes(ByteBuf buf) { this.fakename = ByteBufUtils.readUTF8String(buf); this.entityId = ByteBufUtils.readVarInt(buf, 4); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, this.fakename); ByteBufUtils.writeVarInt(buf, this.entityId, 4); } } Packet Handler: package tschipp.fakename; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHand; import net.minecraft.util.IThreadListener; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import tschipp.creativePlus.items.CustomItems; import tschipp.creativePlus.network.NoisePacket; public class FakeNamePacketHandler implements IMessageHandler<FakeNamePacket, IMessage>{ @Override public IMessage onMessage(final FakeNamePacket message, final MessageContext ctx) { EntityPlayer player = (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : ctx.getServerHandler().playerEntity); EntityPlayer toSync = (EntityPlayer) player.worldObj.getEntityByID(message.entityId); if(toSync != null) { NBTTagCompound tag = toSync.getEntityData(); tag.setString("fakename", message.fakename); toSync.refreshDisplayName(); } return null; } } Event: @SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if(event.getEntity() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntity(); if(player.getEntityData() != null && player.getEntityData().hasKey("fakename")) { FakeName.network.sendToAll(new FakeNamePacket(player.getEntityData().getString("fakename") , player.getEntityId())); } } }
  19. I think if I understand correctly, you have a ItemStack and want to get a BlockState from that. I would probably do this: ItemStack stack = new ItemStack(SOMEBLOCK, 1, META); IBlockState state = Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getMetadata()); Beware that this will fail if the Item is not a ItemBlock
  20. Why? This breaks the Comparable interface contract and will crash servers under some circumstances. What does this method do? What should I change it into? Thanks for being very detailed in your post. I think I figured out how to do the packets, I just need to handle some more Events. What does
  21. Because I edited the main post.
  22. Thanks everyone, got it working!
  23. What do you mean? I know Blockstates would probably be better but I find it a pain setting up the blockstates and all... I think I found it! I just had to set a cullface for the elements! But now the planes of the block below and my block are z-fighting (I think that's the right word). How do I fix that?
  24. What do you mean? I know Blockstates would probably be better but I find it a pain setting up the blockstates and all...
×
×
  • Create New...

Important Information

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