
Franckyi
Members-
Posts
130 -
Joined
-
Last visited
Everything posted by Franckyi
-
[1.12] (Solved) My List won't save after I exit the world and rejoin
Franckyi replied to mutzy12's topic in Modder Support
Thanks for the clarification -
[1.12] (Solved) My List won't save after I exit the world and rejoin
Franckyi replied to mutzy12's topic in Modder Support
Isn't WorldSavedData deprecated because of capabilities ? -
Well, to start modding, you have to learn Minecraft. And to learn Minecraft, you have to play Minecraft. You should start with a very basic Survival World, and see how does the player interact with the world. If you don't understand something, the Minecraft wiki can help you. Then, after spending a few hours (depending if you learn fast or not) on the game, you can start modding. You have the official Forge documentation here. To create a basic mod (adding a block or an item), you don't need a lot of Minecraft knowledge. But when your mod starts to be complicated (networking, capabilities...), you'll need more and more Minecraft knowledge. Also, if you need examples when modding, always look at Minecraft source code. You'll find a lot of examples in the source code, and they will always be up-to-date. Good luck !
-
Hi ! I created a small mod but I didn't realize the system I used was bad for adding more content. So I decided to rewrite my mod so it's easier to add new content and to allow modders to add their own content to my mod. But I have some general questions before rewriting my mod. 1) The system I use to save my Tile Entity's data. Basically, my mod adds 2 types of blocks : controllers and devices. A device is controlled by 0 to N controllers. You can link a device to a controller by shift-right-clicking the device then shift-right-clicking the controller. This is the basis of my mod. The controller TileEntity stores it's data + all data from every linked device, whereas the device TileEntity only stores his data + the position of all controllers controlling the device. Both use Capabilities. This way I can easily update the controller when the device data changed. But it seems to be a huge use of useless space in NBT data, and the only way to "identify" the device is from it's BlockPos. Instead, should I store controllers datas and devices datas in the World itself ? Each controller/device will have an identifier (integer), and only this identifier will be stored in the TE data. And for the controller for example, I will store which device is linked to the controller using a list of device IDs. If this is more optimized, should I use a WorldSavedData or a Capability ? (basically, I'll be storing a Map<Integer, DeviceData> (or just a List<DeviceData>, though) containing all devices in the world). 2) Using Java 8 features, does this custom IMessageHandler implementation work for both sides ? Thanks for answering
-
HarvestDropsEvent::getDrops().clear() ?
-
It won't work. Do what I said and it should work.
-
What do you mean by "exporting as a jar file" ? Just run gradlew build, and copy the JAR file under build/libs in your mods folder.
-
ItemTossEvent.class : When you listen to the event, you get the position at the moment when the item is dropped, not when it hits the ground. That's why you always get minecraft:air.
-
Minecraft Crashing when I launch Forge Version of Minecraft
Franckyi replied to Voltingshock's topic in Support & Bug Reports
Update to Java 8 update 131, it works perfectly well. The post you linked is 3 years old. The issue has been fixed since a long time. Then launch again. -
Please show in which folder are your model and blockstate json files (and also file names). Two FileNotFoundException are thrown, meaning that your files are not located in the correct folder, or they are not named correctly.
-
You're right ! Now that works. Thanks !
-
Yeah, that's probably that for the Block::canConnectRedstone. I looked at BlockRedstoneDiode::updateTick but it seems that it only checks if it has power or not - and I want to check how much power I have.
-
Hi ! I'm creating a custom block that recieves a redstone signal from any face. A TileEntity implementing ITickable is created by this block. In the ITickable::update method, I'm getting the current power using World::isBlockIndirectlyGettingPowered. It works...a bit. Screenshot On this screenshot, the block on the right will receive a power of 15 whereas the block on the left will receive a power of 0. I really don't know why. My Block class : public class BlockRedstoneReceiver extends BlockRedstoneDevice { public BlockRedstoneReceiver(String name, Material mat, CreativeTabs tab, float hardness, float resistance, String tool, int harvest, float light) { super(name, mat, tab, hardness, resistance, tool, harvest, light, GuiHandler.REDSTONE_RECEIVER_GUI); } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityRedstoneReceiver(); } } The block superclass overrides Block::canConnectRedstone to return true. I'm stuck now. Maybe I forgot something on the block class but I'm not sure... if someone can help me !
-
[1.7.10] Anyone can describe my server crash report?
Franckyi replied to korey03's topic in Support & Bug Reports
1.7.10 is no longer supported here. But updating your Java version to 1.8 should resolve the problem. -
You should use ClientTickEvent.
-
Hi ! I'm using different types of maps that I have to Serialize to NBT, because they'll be saved in a TileEntity data. So, I decided to create a generic interface for my tables called ITable : package com.github.franckyi.netcraft.logic.tables; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.INBTSerializable; public interface ITable<T extends Map<? extends INBTSerializable<? extends NBTBase>, ? extends INBTSerializable<? extends NBTBase>>> extends INBTSerializable<NBTTagList> { public T getTable(); @Override default NBTTagList serializeNBT() { NBTTagList nbt = new NBTTagList(); for (Entry<? extends INBTSerializable<? extends NBTBase>, ? extends INBTSerializable<? extends NBTBase>> entry : getTable() .entrySet()) { NBTTagCompound c = new NBTTagCompound(); c.setTag("Key", entry.getKey().serializeNBT()); c.setTag("Value", entry.getValue().serializeNBT()); nbt.appendTag(c); } return nbt; } @Override default void deserializeNBT(NBTTagList nbt) { for (Iterator<NBTBase> i = nbt.iterator(); i.hasNext();) { NBTTagCompound c = (NBTTagCompound) i.next(); INBTSerializable<NBTBase> key; // I don't know what to do from here INBTSerializable<NBTBase> value; key.deserializeNBT(c.getTag("Key")); value.deserializeNBT(c.getTag("Value")); getTable().put(key, value); } } } But I'm having trouble deserializing the NBT tag to my Table. Should I let the subclass implementing ITable override deserializeNBT, or is there a direct solution in the interface itself ?
-
MODID:blockstats/fooblock.json <=> src/main/resources/assets/MODID/blockstates/fooblock.json As described here
-
Communication between Forge mod and Bukkit plugin
Franckyi replied to TheASTRO's topic in Modder Support
I think on the Bukkit side, because Forge already knows which discriminator to use, whereas Bukkit doesn't. -
[SOLVED] Getting TileEntity in onBlockDestroyed events
Franckyi replied to BenignBanana's topic in Modder Support
You should override Block::breakBlock. This method is called before the tile entity is destroyed so you can still access it. -
It seems to be good now ! Thanks !
-
Okay so everything seems to be fine. But I have another problem also linked to networking : my mod can't run on the server. Crash Report It fails when it registers a message that is handled on the client side. But I must register it on both sides anyway, right ? I really don't know where does it try to load the WorldClient class. Is it linked to my special PacketHandler class ? public class PacketHandler { public static abstract class ClientHandler<REQ extends IMessage> extends CommonHandler<REQ> { @Override public IMessage onMessage(REQ message, MessageContext ctx) { super.onMessage(message, ctx); this.world = Minecraft.getMinecraft().world; this.mainThread = Minecraft.getMinecraft(); this.mainThread.addScheduledTask(this); return null; } } public static abstract class CommonHandler<REQ extends IMessage> implements IMessageHandler<REQ, IMessage>, Runnable { protected World world; protected IThreadListener mainThread; protected REQ message; protected MessageContext ctx; @Override public IMessage onMessage(REQ message, MessageContext ctx) { this.message = message; this.ctx = ctx; return null; } } public static abstract class ServerHandler<REQ extends IMessage> extends CommonHandler<REQ> { @Override public IMessage onMessage(REQ message, MessageContext ctx) { super.onMessage(message, ctx); this.world = ctx.getServerHandler().player.world; this.mainThread = (WorldServer) this.world; this.mainThread.addScheduledTask(this); return null; } } public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(ModReference.MODID); } Client-side Message Handlers extends PacketHandler.ClientHandler whereas Server-side Message Handlers extends PacketHandler.ServerHandler.
-
Thanks ! So this should work ? BlockRedstoneController::breakBlock (everything is called server side) WorldServer worldServer = (WorldServer) world; for (EntityPlayer player : worldServer.playerEntities) { EntityPlayerMP playerMP = (EntityPlayerMP) player; if (worldServer.getPlayerChunkMap() { .getEntry(world.getChunkFromBlockCoords(pos).x, world.getChunkFromBlockCoords(pos).z) .containsPlayer(playerMP)) PacketHandler.INSTANCE.sendTo(new UpdateRedstoneControllerMessage(updateControllers), playerMP); } } (and the same for BlockRedstoneSwitch) EventHandler (I don't know if this event is fired on the server, on client or on both) @SubscribeEvent public void onChunkWatch(ChunkWatchEvent.Watch event) { WorldServer world = event.getPlayer().getServerWorld(); if (!world.isRemote) { for (TileEntity te : world.loadedTileEntityList) { if (event.getChunk().equals(world.getChunkFromBlockCoords(te.getPos()).getPos())) { if (te instanceof TileEntityRedstoneSwitch) { PacketHandler.INSTANCE.sendTo(new UpdateRedstoneSwitchMessage(te.getPos(), te.getCapability(RedstoneSwitchProvider.SWITCH_CAP, null).getSwitch()), event.getPlayer()); } else if (te instanceof TileEntityRedstoneController) { PacketHandler.INSTANCE.sendTo(new UpdateRedstoneControllerMessage(te.getPos(), te.getCapability(RedstoneControllerProvider.CONTROLLER_CAP, null).getController()), event.getPlayer()); } } } } }