Jump to content

Jwosty

Forge Modder
  • Posts

    128
  • Joined

  • Last visited

Everything posted by Jwosty

  1. I just updated the Basic Items tutorial to 1.7. Try following it now. http://www.minecraftforge.net/wiki/Basic_Items
  2. Forge is now using Gradle: http://www.minecraftforge.net/forum/index.php?topic=14048.0
  3. Uhh... what tutorials are you following? That shouldn't work at all.
  4. Ah, didn't realize that, sorry. I think it's time someone should do it anyway... I think I will. I'll tell you when it's updated.
  5. Did you even bother to look at any of the google results? *sigh* if I really must... http://www.minecraftforge.net/wiki/Basic_Items That's how you make an item. The tutorial shows you how to create an item class and use it from your code. And BTW, your code will not work. onItemRightClick needs to go inside your custom item class, _not_ your main mod class. In there, it won't do anything. Also, protip: make sure you use @Override on methods where applicable (look it up).
  6. Seriously, do your research. It's not that hard. http://lmgtfy.com/?q=minecraft+forge+item
  7. Since those first errors that I can see are mainly due to renames, you could write a little script that uses regexes to search through your source and replace the old names with the new ones. That's really the most you can do.
  8. Read some vanilla code that uses a slider.
  9. Copy your source into a new forge gradle evironment. Look at the hundreds of compilation errors (ok, probably less than that ) and fix them.
  10. Do you open the GUI on the client or server side?
  11. BTW, I found example code somewhere (can't remember where tho) and used similar code. [spoiler=ChannelHandler] public class ChannelHandler extends FMLIndexedMessageToMessageCodec<IPacket> { public ChannelHandler() { this.addDiscriminator(0, PacketWormhole.class); this.addDiscriminator(1, PacketDHDEnterGlyph.class); } public static EnumMap<Side, FMLEmbeddedChannel> channels; public static void initChannels() { channels = NetworkRegistry.INSTANCE.newChannel("SpaceDistortion", new ChannelHandler()); } @SideOnly(Side.CLIENT) /** * Sends a packet from the client to the server * @param packet An IPacket to send */ public static void clientSendPacket(IPacket packet) { FMLEmbeddedChannel channel = ChannelHandler.channels.get(Side.CLIENT); channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); channel.writeOutbound(packet); } @SideOnly(Side.SERVER) /** * Sends a packet from the server to a given client * @param packet An IPacket to send * @param player A player to send it to */ public static void serverSentPacket(IPacket packet, EntityPlayer player) { FMLEmbeddedChannel channel = ChannelHandler.channels.get(Side.SERVER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); channel.writeOutbound(packet); } /** * Sends a packet from the server to all clients * @param packet An IPacket to send */ @SideOnly(Side.SERVER) public static void serverSendPacketAllClients(IPacket packet) { FMLEmbeddedChannel channel = ChannelHandler.channels.get(Side.SERVER); channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); channel.writeOutbound(packet); } @Override public void encodeInto(ChannelHandlerContext context, IPacket packet, ByteBuf data) throws Exception { packet.writeBytes(data); } @Override public void decodeInto(ChannelHandlerContext context, ByteBuf data, IPacket packet) { // read the packet packet.readBytes(data); // handle the packet by calling IPacket#onReceive Side side = FMLCommonHandler.instance().getEffectiveSide(); EntityPlayer player; switch (side) { case CLIENT: player = Minecraft.getMinecraft().thePlayer; packet.onReceive(player, side); case SERVER: INetHandler net = context.channel().attr(NetworkRegistry.NET_HANDLER).get(); player = ((NetHandlerPlayServer) net).playerEntity; packet.onReceive(player, side); } } [spoiler=IPacket] public interface IPacket { public void readBytes(ByteBuf bytes); public void writeBytes(ByteBuf bytes); public void onReceive(EntityPlayer player, Side side); } [/code] You probably don't need the entire class, but I hope this helps. Especially look at clientSendPacket, serverSendPacket, and serverSendPacketAllClients.
  12. Right, really stupid mistake. I guess I'm just used to checking for server side... But is seems that Block#onBlockAdded is only executed on the server and never the client (I've confimed this through the Minecraft source). EDIT: Block#onPostBlockPlaced executed both server and client side, but I realized it only works for blocks placed by an entity, which makes sense. Do you know of any ways for the client side to handle when a block is placed? It's almost like everything but this is executed on both server _and_ client.
  13. I'm trying to play a sound for a custom tile entity for its whole existence. Minecraft doesn't do many constantly looping sounds; the only instances of this in action (that I can find) are MovingSoundMinecart and MovingSoundMinecartRiding. I've come up with the following class based on the vanilla code, mainly only changing it to use a tile entity instead of an entity: public class LoopableTileEntitySound extends PositionedSound implements ITickableSound { protected boolean donePlaying = false; private TileEntity tileEntity; public LoopableTileEntitySound(ResourceLocation path, TileEntity tileEntity, float volume, float pitch) { super(path); this.repeat = true; this.tileEntity = tileEntity; this.volume = volume; this.field_147663_c = pitch; this.xPosF = tileEntity.xCoord; this.yPosF = tileEntity.yCoord; this.zPosF = tileEntity.zCoord; this.field_147665_h = 0; } public LoopableTileEntitySound(String path, TileEntity tileEntity, float volume, float pitch) { this(new ResourceLocation(path), tileEntity, volume, pitch); } @Override public void update() { if (this.tileEntity.isInvalid()) { this.donePlaying = true; } } @Override public boolean isDonePlaying() { return this.donePlaying; } } Here's how I use it -- it starts when this custom block is added into the world: @Override public void onBlockAdded(World world, int x, int y, int z) { if (!world.isRemote) { TileEntity tileEntity = world.getTileEntity(x, y, z); ISound eventHorizonSound = new LoopableTileEntitySound(CommonProxy.MOD_ID + ":stargate.eventhorizon", tileEntity, 0.1F, 1); Minecraft.getMinecraft().getSoundHandler().playSound(eventHorizonSound); } } However, the following error crashes the game: java.util.ConcurrentModificationException at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:859) at java.util.ArrayList$Itr.next(ArrayList.java:831) at net.minecraft.client.audio.SoundManager.updateAllSounds(SoundManager.java:245) at net.minecraft.client.audio.SoundHandler.update(SoundHandler.java:222) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2111) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1036) at net.minecraft.client.Minecraft.run(Minecraft.java:951) at net.minecraft.client.main.Main.main(Main.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) And the game doesn't crash and the sound loops until you exit to the main menu if I don't call this.tileEntity.isInvalid() in the update() method. Any idea what's going on here?
  14. I have similar functionality in a mod that I'm working on. You're free to look at some code for a teleportation block to give you some hints: https://github.com/jwosty/Minecraft-SpaceDistortionMod/blob/develop/src/main/java/jw/spacedistortion/common/block/BlockEventHorizon.java
  15. I think most of us here are too lazy to download and compile your project . Can you post a stacktrace and the appropriate file?
  16. I'm not quite sure what you're asking. Do you mean to check which side the code is running on (client vs. server)?
  17. Actually read your stacktrace. Line 43, the important line, says: Caused by: java.lang.IllegalArgumentException: Slot 1007 is already occupied by gems.block.BlockGemBlock@32b7795 when adding gems.block.BlockGemBlock@1ab7d8d3 This means that you have two blocks in there using the same ID (1007). Also, you should be using the latest version of Forge, in which you don't need to worry about block IDs. Among other nice things. Seriously, just upgrade.
  18. It doesn't render them in 3D any more than it renders glass in 3D -- that option says whether or not to draw transparency in some common textures. If it's disabled, then there's no alpha channel so it shows up black. I believe you can specify this by overriding Block#isOpaqueCube() ; at least it seems that way from a quick glance into the code for BlockLeaves .
  19. I don't know much about coremods, but maybe you _can't_ do it without ASM
  20. After a long break from this project then finally another debugging session, I discovered a few days ago that the problem was in the code that opens the GUI... I guess it was a simple as changing this: to:
  21. Just a confirmation: you pretty much just want to be able to increase/decrease the number of inventory slots for a player? If so, with what? Commands?
  22. I've got the packet initialization code; the packet info is actually even correct! And maybe the problem _is_ the GUI; I close it from within itself by using player.displayGuiScreen((GuiScreen) null) . Is this the correct way? I've seen it uses in the vanilla code
  23. OT: wait, really?! I've been using the 6000s for my block and nothing fails...
×
×
  • Create New...

Important Information

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