
mardiff
Members-
Posts
158 -
Joined
-
Last visited
Everything posted by mardiff
-
[1.6.4][SOLVED]Armor not giving player wearing it potion effects
mardiff replied to The_Fireplace's topic in Modder Support
So just to clarify, what do the if statements return that are checking whether or not the player is wearing the armor? We really don't know what the exact problem is... -
java.lang.ClassCastException when opening GUI of custom furnace
mardiff replied to MatthewGB's topic in Modder Support
Sorry for snapping at you then. Post your gui handler, your container, and your gui. Also, just go through every class and make sure the TileEntityFurnace isn't imported. Thst should immediately point out your problem. -
[1.7.2]Gui controls redstone power state of block
mardiff replied to KeeganDeathman's topic in Modder Support
Packets. Most likely I would send a packet to the tile entity if you have one for consistencies sake, and then have the tile entity update the blocks state like the furnace does. Since packets have changed a lot in 1.7, look here for how to use them: www.minecraftforge.net/wiki/Netty_Packet_Handling -
java.lang.ClassCastException when opening GUI of custom furnace
mardiff replied to MatthewGB's topic in Modder Support
If you had any idea what you were doing you would know exactly where to look when I said that. public class TileEntityEFurnace extends TileEntityFurnace implements ISidedInventory -
Id recommend using the LivingDeathEvent.
-
java.lang.ClassCastException when opening GUI of custom furnace
mardiff replied to MatthewGB's topic in Modder Support
Don't extend TileEntityFurnace. Extend TileEntity. -
Maybe you shouldn't be yelling at him for not knowing English and should instead try to answer his question. Oh, and by the way, it's syntaxes.
-
They really didn't... it's the same thing except EnumArmorMaterial is just Armor Material.
-
Show us your main class and your onBlockActivated in your block too.
-
[1.6.4] Change icon texture based on its state
mardiff replied to Camulorix's topic in Modder Support
If you know how to use metadata then use getIconFromDamage. -
Umm... I thought it was pretty self explanatory... the three methods take a variable from the tile entity and send it to the gui. Since the gui can't read the tile entity since it's on the client and the tile is on the server, the container has to manage their variables to make sure they are the same. That's why you see these methods check if, for example, the last burn time of the gui is the same as the tile entity. If you want to use them, just sub in your variables that you'll be using. If you only want to do exactly what you said in the first post, then just edit the gui. The container should do everything you'd like, but if not, just sub in your variables for the already-existing ones.
-
Well, you've got SuperNova.guiIdOxidizer in the server side switch when you're looking for the fragmenter I do believe. Be careful how you copy and paste.
-
Look at the vanilla furnace. To send the integer to the GUI, the container uses three methods. I think they're detectAndSendChanges, addCraftingToCrafters, and updateProgessBar. To have the time update, look at how the TileEntityFurnace class manages burnTime in updateEntity(). (Geez, I really need to do something different if I can remember all of that...)
-
Check the onUpdate method. It does exactly what Alias said it does as long as the entity is a player.
-
The furnace already sends an integer to the GUI, so al you would need to do is change where it gets the cook progress scaled and renders that as an image to just draw the burn time, cook time, or whatever you're looking for. Only the GUI should need to be changed as the container and the tile entity already take care of everything for you.
-
Sorry for not replying and apparently leaving you all in suspense, but it was just that I needed to register the handler. After that I just had to screw around and delete some things and it works like a charm now. Thanks guys.
-
Does it work for 1.7? I haven't found any documentation about it...
-
Hello Everyone, With the new packet system combined with my poor inexperience with packets, I can't figure out how to to send an integer from a gui to its tile entity. I'll put all the code here: The method in the gui that should sent a packet: SimpaddsBase.packetPipeline.sendToAll(new PacketTank(outputSelected, tileTank.xCoord, tileTank.yCoord, tileTank.zCoord)); The packet handler: package mardiff.simpadds.packets; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import mardiff.simpadds.tileentity.TileFluidTank; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import cpw.mods.fml.common.FMLCommonHandler; public class PacketTank extends AbstractPacket { int output, x, y, z; public PacketTank(){ } public PacketTank(int output, int x, int y, int z){ this.output = output; this.x = x; this.y = y; this.z = z; } @Override public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { buffer.writeInt(output); buffer.writeInt(x); buffer.writeInt(y); buffer.writeInt(z); } @Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { output = buffer.readInt(); x = buffer.readInt(); y = buffer.readInt(); z = buffer.readInt(); } @Override public void handleClientSide(EntityPlayer player) { System.out.println("ran"); } @Override public void handleServerSide(EntityPlayer player) { System.out.println("ranPacket"); World world = player.worldObj; TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TileFluidTank) { TileFluidTank tft = (TileFluidTank)te; tft.output = this.output; FMLCommonHandler.instance().getClientToServerNetworkManager().scheduleOutboundPacket(tft.getDescriptionPacket()); } } } The packet pipeline, which is mostly copied from the forge tutorial: package mardiff.simpadds.packets; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageCodec; import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; import java.util.LinkedList; import java.util.List; import mardiff.simpadds.lib.Reference; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.INetHandler; import net.minecraft.network.NetHandlerPlayServer; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.FMLEmbeddedChannel; import cpw.mods.fml.common.network.FMLOutboundHandler; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** * Packet pipeline class. Directs all registered packet data to be handled by the packets themselves. * @author sirgingalot * some code from: cpw */ @ChannelHandler.Sharable public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, AbstractPacket> { private EnumMap<Side, FMLEmbeddedChannel> channels; private LinkedList<Class<? extends AbstractPacket>> packets = new LinkedList<Class<? extends AbstractPacket>>(); private boolean isPostInitialised = false; /** * Register your packet with the pipeline. Discriminators are automatically set. * * @param clazz the class to register * * @return whether registration was successful. Failure may occur if 256 packets have been registered or if the registry already contains this packet */ public boolean registerPacket(Class<? extends AbstractPacket> clazz) { if (this.packets.size() > 256) { // You should log here!! return false; } if (this.packets.contains(clazz)) { // You should log here!! return false; } if (this.isPostInitialised) { // You should log here!! return false; } this.packets.add(clazz); return true; } // In line encoding of the packet, including discriminator setting @Override protected void encode(ChannelHandlerContext ctx, AbstractPacket msg, List<Object> out) throws Exception { ByteBuf buffer = Unpooled.buffer(); Class<? extends AbstractPacket> clazz = msg.getClass(); if (!this.packets.contains(msg.getClass())) { throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName()); } byte discriminator = (byte) this.packets.indexOf(clazz); buffer.writeByte(discriminator); msg.encodeInto(ctx, buffer); FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get()); out.add(proxyPacket); } // In line decoding and handling of the packet @Override protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception { ByteBuf payload = msg.payload(); byte discriminator = payload.readByte(); Class<? extends AbstractPacket> clazz = this.packets.get(discriminator); if (clazz == null) { throw new NullPointerException("No packet registered for discriminator: " + discriminator); } AbstractPacket pkt = clazz.newInstance(); pkt.decodeInto(ctx, payload.slice()); EntityPlayer player; switch (FMLCommonHandler.instance().getEffectiveSide()) { case CLIENT: player = this.getClientPlayer(); pkt.handleClientSide(player); break; case SERVER: INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); player = ((NetHandlerPlayServer) netHandler).playerEntity; pkt.handleServerSide(player); break; default: } out.add(pkt); } // Method to call from FMLInitializationEvent public void initialize() { this.channels = NetworkRegistry.INSTANCE.newChannel(Reference.MOD_ID, this); } // Method to call from FMLPostInitializationEvent // Ensures that packet discriminators are common between server and client by using logical sorting public void postInitialize() { if (this.isPostInitialised) { return; } this.isPostInitialised = true; Collections.sort(this.packets, new Comparator<Class<? extends AbstractPacket>>() { @Override public int compare(Class<? extends AbstractPacket> clazz1, Class<? extends AbstractPacket> clazz2) { int com = String.CASE_INSENSITIVE_ORDER.compare(clazz1.getCanonicalName(), clazz2.getCanonicalName()); if (com == 0) { com = clazz1.getCanonicalName().compareTo(clazz2.getCanonicalName()); } return com; } }); } @SideOnly(Side.CLIENT) private EntityPlayer getClientPlayer() { return Minecraft.getMinecraft().thePlayer; } /** * Send this message to everyone. * <p/> * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send */ public void sendToAll(AbstractPacket message) { this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); this.channels.get(Side.SERVER).writeAndFlush(message); } /** * Send this message to the specified player. * <p/> * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send * @param player The player to send it to */ public void sendTo(AbstractPacket message, EntityPlayerMP player) { this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); this.channels.get(Side.SERVER).writeAndFlush(message); } /** * Send this message to everyone within a certain range of a point. * <p/> * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send * @param point The {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint} around which to send */ public void sendToAllAround(AbstractPacket message, NetworkRegistry.TargetPoint point) { this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point); this.channels.get(Side.SERVER).writeAndFlush(message); } /** * Send this message to everyone within the supplied dimension. * <p/> * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send * @param dimensionId The dimension id to target */ public void sendToDimension(AbstractPacket message, int dimensionId) { this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION); this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId); this.channels.get(Side.SERVER).writeAndFlush(message); } /** * Send this message to the server. * <p/> * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send */ public void sendToServer(AbstractPacket message) { this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); this.channels.get(Side.CLIENT).writeAndFlush(message); } } The abstract packet class, which is entirely copied: package mardiff.simpadds.packets; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; /** * AbstractPacket class. Should be the parent of all packets wishing to use the PacketPipeline. * @author sirgingalot */ public abstract class AbstractPacket { /** * Encode the packet data into the ByteBuf stream. Complex data sets may need specific data handlers (See @link{cpw.mods.fml.common.network.ByteBuffUtils}) * * @param ctx channel context * @param buffer the buffer to encode into */ public abstract void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer); /** * Decode the packet data from the ByteBuf stream. Complex data sets may need specific data handlers (See @link{cpw.mods.fml.common.network.ByteBuffUtils}) * * @param ctx channel context * @param buffer the buffer to decode from */ public abstract void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer); /** * Handle a packet on the client side. Note this occurs after decoding has completed. * * @param player the player reference */ public abstract void handleClientSide(EntityPlayer player); /** * Handle a packet on the server side. Note this occurs after decoding has completed. * * @param player the player reference */ public abstract void handleServerSide(EntityPlayer player); } The area in my main mod class directed for packets: public static final PacketPipeline packetPipeline = new PacketPipeline(); @EventHandler public void initialise(FMLInitializationEvent evt) { packetPipeline.initialize(); } @EventHandler public void postInitialise(FMLPostInitializationEvent evt) { packetPipeline.postInitialize(); } And at this point, I have no idea what method to use in the tile entity, be it onDataPacket or receiveClientEvent. Thanks for reading all this clutter and helping out if you can.
-
[1.5.2] Server crash due to ModLoader.addArmor()?
mardiff replied to Drewseph's topic in Modder Support
Instead, use RenderingRegistry.addNewArmourRenderingPrefix("goggles") -
NBT works fine, just add in different print checks to see which parts are being called. Most likely one of your if statements is returning false and you don't realize it.
-
nukes != nuke_mod
-
[1.6.4] Get the Resource/Resource location of any item.
mardiff replied to lexwebb's topic in Modder Support
Does .getIconFromDamage(0) work? -
The instance of your mod as to be of your mod... (The instance name must be the same as the mod id)
-
It's really not much different from other versions. Nothing has really changed besides some method names. If you really want to, just try as hard as you can to update and we can help you the rest of the way.
-
It depends on whether or not the id that is being dropped is his ore or not. Usually if it is the ore then the block won't drop experience and will instead drop experience during smelting. He probably has another item being dropped besides his ore, so it would then make sense to drop experience since you wouldn't be smelting the item at all.