Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/07/19 in all areas

  1. In case any other people are going to look at this in the future. Final WorldSavedData object: import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.storage.MapStorage; import net.minecraft.world.storage.WorldSavedData; public class DataTest extends WorldSavedData { private static final String DATA_NAME = "ModID_Test"; private static DataTest instance; private int testInt; public DataTest() { super(DATA_NAME); } public DataTest(String name) { super(name); } public static DataTest get(World world) { MapStorage storage = world.getMapStorage(); instance = (DataTest) storage.getOrLoadData(DataTest.class, DATA_NAME); if (instance == null) { instance = new DataTest(); storage.setData(DATA_NAME, instance); } return instance; } @Override public void readFromNBT(NBTTagCompound nbt) { testInt = nbt.getInteger("testInt"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setInteger("testInt", testInt); return compound; } public void setCharData(int testInt) { this.testInt = testInt; markDirty(); } public int getTestInt() { return testInt; } } Using the WorldSavedData object from a PlayerEvent type: (Only example, you can get it from other ways, just keep in mind we have to use the Logical Server Side world) import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; @Mod.EventBusSubscriber(modid = Reference.MOD_ID) public class ServerListener { @SubscribeEvent(priority = EventPriority.NORMAL) public static void playerConnected(PlayerEvent.PlayerLoggedInEvent event) { DataTest data = DataTest.get(event.player.world); if(data != null) { int testInt = data.getCharData(); System.out.println("Value: "+testInt); } } @SubscribeEvent(priority = EventPriority.NORMAL) public static void playerDisconnected(PlayerEvent.PlayerLoggedOutEvent event) { DataTest data = DataTest.get(event.player.world); if(data != null) { data.setCharData(1); System.out.println("Value: "+testInt); } } }
    1 point
  2. The easiest way would be to create an event handler for LivingDropsEvent, and detect the item held in the player's hand. If all conditions match, spawn the drop(s) at the position of the event (the position of the EntityLiving that was killed). What you are trying to create sounds very similar to Draconic Evolution's mob soul system. You might want to check out Brandon's code for it here.
    1 point
  3. Ideally you would do the block rebuilding off-thread or even multithreaded. I haven't done that in this example though. https://gist.github.com/Cadiboo/753607e41ca4e2ca9e0ce3b928bab5ef If you do multi-thread/off-thread your rebuilding, you will need to have proper thread safe code.
    1 point
  4. https://github.com/MinecraftForge/MinecraftForge/commits/1.13.x Your reach that page by clicking the "commits" button on the main Github page for the project.
    1 point
×
×
  • Create New...

Important Information

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