Jump to content

TLHPoE

Members
  • Posts

    638
  • Joined

  • Last visited

Everything posted by TLHPoE

  1. Yes, I'm aware now. In the other post you referenced RecipeSorter, which I assumed was the main method of registering the recipe. Didn't see the mold_bucket recipe though, so my bad.
  2. So the recipe I'm adding is to craft any amount of potions with my item, and the result is my item with some more NBT data attached to it. What would the JSON file look like? I've tried just adding a generic shapeless recipe with my item as both the ingredient and result: The recipe doesn't load. Is there a specific type I'm missing? I can't seem to find any recipes like this in Minecraft to reference.
  3. Hello, I was referencing this post in order to add my dynamic recipe, but it recommends using a class (RecipeSorter) that is marked as deprecated. How do I register my recipe? I have my IRecipe class (plus its factory): And then I have my _factories.json (located in assets/quickconsume/recipes):
  4. Hello, I am putting together a mod pack for me and my friends, but when pregenerating chunks using the Chunk Pregenerator mod it closes the server without a crash log at what seems like random times. Here is a snippet of the end of a log: It occurs immediately when I create the world and run the command for pregenerator, and then again after I restart and let the task resumes for a couple of chunks (it generates a good handful before "auto restarting"). I am unsure if this is Forge, Chunk Pregenerator, or the mods that generate structures. The messages along the lines of "X loaded a new chunk..." is in the log quite often, with X mainly being Roguelike Dungeons of Recurrent Complex. I removed TickDynamic, JourneyMap, and AromaBackup, but the problem persisted. Before every "auto restart," AromaBackup would state that it was creating a backup. Here is my current mod list: For my server, I have disabled Biomes 'o Plenty to test. Here is the full log, which was taken after loading an already created world and letting the pregen task resume (it resumes automatically) Edit: the debug log is too big, even for pastebin. It says virtually the same thing at the end.
  5. https://github.com/phan-kavin/SlippWorld Forge version 1.11.2-13.20.0.2228
  6. This check: if(data != null && data.getCoolDown() == 0) { This passes every time, and inside the clause it sets the cool down to 100.
  7. Both times I access the capabilities are server side.
  8. Goal: Create a cool down system for firing a weapon, so getting and setting an integer within an itemstack How: Using forge capability system Problem: Can't set (but can retrieve capability) IRepeaterData: package com.kain.slippworld.data.repeater; public interface IRepeaterData { public int getCoolDown(); public void setCoolDown(int coolDown); } RepeaterData: package com.kain.slippworld.data.repeater; public class RepeaterData implements IRepeaterData { private int coolDown; @Override public int getCoolDown() { return coolDown; } @Override public void setCoolDown(int coolDown) { this.coolDown = coolDown; } } RepeaterCapability: package com.kain.slippworld.data.repeater; import com.kain.slippworld.*; import com.kain.slippworld.data.*; import net.minecraft.item.*; import net.minecraft.nbt.*; import net.minecraft.util.*; import net.minecraftforge.common.capabilities.*; public class RepeaterCapability { public static final ResourceLocation NAME = new ResourceLocation(Reference.MOD_ID, "_Repeater"); @CapabilityInject(IRepeaterData.class) public static final Capability<IRepeaterData> REPEATER_DATA_CAPABILITY = null; public static final EnumFacing DEFAULT_FACING = null; public static void register() { CapabilityManager.INSTANCE.register(IRepeaterData.class, new Capability.IStorage<IRepeaterData>() { @Override public NBTBase writeNBT(Capability<IRepeaterData> capability, IRepeaterData instance, EnumFacing side) { return new NBTTagInt(instance.getCoolDown()); } @Override public void readNBT(Capability<IRepeaterData> capability, IRepeaterData instance, EnumFacing side, NBTBase nbt) { instance.setCoolDown(((NBTTagInt) nbt).getInt()); } }, () -> new RepeaterData()); } public static IRepeaterData getCapability(ItemStack itemStack) { return itemStack != null && itemStack.hasCapability(REPEATER_DATA_CAPABILITY, DEFAULT_FACING) ? itemStack.getCapability(REPEATER_DATA_CAPABILITY, DEFAULT_FACING) : null; } public static ICapabilityProvider createProvider() { return new GenericCapabilityProvider<>(REPEATER_DATA_CAPABILITY, DEFAULT_FACING); } public static ICapabilityProvider createProvider(IRepeaterData repeaterData) { return new GenericCapabilityProvider(REPEATER_DATA_CAPABILITY, DEFAULT_FACING, repeaterData); } } GenericCapabilityProvider: package com.kain.slippworld.data; import net.minecraft.nbt.*; import net.minecraft.util.*; import net.minecraftforge.common.capabilities.*; public class GenericCapabilityProvider<HANDLER> implements ICapabilitySerializable<NBTBase> { private final Capability<HANDLER> capability; private final EnumFacing facing; private final HANDLER instance; public GenericCapabilityProvider(Capability<HANDLER> capability, EnumFacing facing) { this(capability, facing, capability.getDefaultInstance()); } public GenericCapabilityProvider(Capability<HANDLER> capability, EnumFacing facing, HANDLER instance) { this.capability = capability; this.facing = facing; this.instance = instance; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return capability == getCapability(); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if(capability == getCapability()) { return (T) instance; } return null; } @Override public NBTBase serializeNBT() { return getCapability().writeNBT(getInstance(), getFacing()); } @Override public void deserializeNBT(NBTBase nbt) { getCapability().readNBT(getInstance(), getFacing(), nbt); } public Capability<HANDLER> getCapability() { return capability; } public EnumFacing getFacing() { return facing; } public HANDLER getInstance() { return instance; } } ItemRepeater package com.kain.slippworld.item.tool; import javax.annotation.*; import com.kain.slippworld.*; import com.kain.slippworld.data.repeater.*; import net.minecraft.creativetab.*; import net.minecraft.entity.*; import net.minecraft.entity.player.*; import net.minecraft.item.*; import net.minecraft.nbt.*; import net.minecraft.util.*; import net.minecraft.world.*; import net.minecraftforge.common.capabilities.*; import net.minecraftforge.fml.relauncher.*; public class ItemRepeater extends Item { public final ToolMaterial material; protected final float damage; protected final int maxCoolDown; public ItemRepeater(ToolMaterial material, float distance, int maxCoolDown) { super(); ... } @Override public void onUpdate(ItemStack itemStack, World world, Entity e, int slot, boolean selected) { super.onUpdate(itemStack, world, e, slot, selected); if(!world.isRemote) { IRepeaterData data = RepeaterCapability.getCapability(itemStack); if(data != null) { int coolDown = data.getCoolDown(); if(coolDown > 0) { System.out.println("COOL DOWN"); data.setCoolDown(coolDown--); } } } } ... @Override @Nullable public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { return RepeaterCapability.createProvider(); } public void attackEntity(ItemStack itemStack, EntityLivingBase entity, EntityPlayer player) { if(!player.world.isRemote) { IRepeaterData data = RepeaterCapability.getCapability(itemStack); if(data != null && data.getCoolDown() == 0) { entity.hurtResistantTime = 0; entity.attackEntityFrom(DamageSource.GENERIC, getDamage()); data.setCoolDown(100); System.out.println("BANG"); } } } public float getDamage() { return damage; } public int getMaxCoolDown() { return maxCoolDown; } } ItemRepeater#attackEntity is being called externally by a packet. Right now when I right click (trigger the attackEntity method), it detects the cool down value as being 0 and outputs "BANG," but it never sets the cool down value to 100. I'm sure that there's some markDirty method somewhere but I just can't find it. I based my code around choonster's test mod.
  9. I dug around to find the source of MInecraft#objectMouseOver, and it's actually set using Entity#rayTrace. How come when I try to use the method myself it doesn't detect entities? @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { if(world.isRemote) { RayTraceResult ray = player.rayTrace(5F, 1F); System.out.println("Casting ray"); if(ray.entityHit != null && ray.typeOfHit == Type.ENTITY && ray.entityHit instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) ray.entityHit; SlippWorld.channel.sendToServer(new MessageTargetEntity(entity, player.getHeldItem(hand))); System.out.println("Attack sent"); } for(int i = 0; i < 3; i++) { Minecraft.getMinecraft().entityRenderer.itemRenderer.updateEquippedItem(); } } return new ActionResult(EnumActionResult.PASS, player.getHeldItem(hand)); } The only variable I feel iffy passing for the ray is the partialTick, which I'm not sure what to put there, only that it should be between 0F and 1F.
  10. Seeing as how no one has responded about using the actual chunk's NBT, I fixed my original method of storing my own chunk data in my WorldSavedData: package com.kain.slippworld; import java.util.*; import net.minecraft.nbt.*; import net.minecraft.util.math.*; import net.minecraft.world.*; import net.minecraft.world.storage.*; public class WorldSavedDataMod extends WorldSavedData { public static final String NAME = Reference.NAME + "_WorldData"; public boolean isDragonSlain = false; public Map<ChunkPos, NBTTagCompound> chunkData; public WorldSavedDataMod(String name) { super(name); chunkData = new HashMap<ChunkPos, NBTTagCompound>(); } public WorldSavedDataMod() { this(NAME); } @Override public void readFromNBT(NBTTagCompound nbt) { isDragonSlain = nbt.getBoolean(Reference.DRAGON_SLAIN_TAG); NBTTagCompound chunks = nbt.getCompoundTag(Reference.WORLD_DATA_CHUNKS); for(String pos : chunks.getKeySet()) { chunkData.put(fromString(pos), chunks.getCompoundTag(pos)); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setBoolean(Reference.DRAGON_SLAIN_TAG, isDragonSlain); NBTTagCompound chunks = new NBTTagCompound(); for(ChunkPos pos : chunkData.keySet()) { chunks.setTag(pos.toString(), chunkData.get(pos)); } nbt.setTag(Reference.WORLD_DATA_CHUNKS, chunks); return nbt; } public NBTTagCompound getChunkData(ChunkPos pos) { NBTTagCompound nbt = chunkData.get(pos); if(nbt == null) { nbt = new NBTTagCompound(); chunkData.put(pos, nbt); } return nbt; } public static WorldSavedDataMod get(World w) { MapStorage s = w.getMapStorage(); WorldSavedDataMod d = (WorldSavedDataMod) s.getOrLoadData(WorldSavedDataMod.class, NAME); if(d == null) { d = new WorldSavedDataMod(); s.setData(NAME, d); } return d; } public static ChunkPos fromString(String pos) { pos = pos.substring(1, pos.length() - 1); for(int i = 0; i < pos.length(); i++) { if(pos.charAt(i) == ',') { return new ChunkPos(Integer.parseInt(pos.substring(0, i)), Integer.parseInt(pos.substring(i + 2, pos.length()))); } } return null; } }
  11. I'm trying to make a ray-based weapon that damages the entity that the player is aiming at. Currently I am using Minecraft#objectMouseOver on the client and sending a packet to the server for processing, but it has a limited range. Another option I saw was EntityPlayer#rayTrace method, but it never returned an entity hit. Code: @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { if(world.isRemote) { RayTraceResult ray = Minecraft.getMinecraft().objectMouseOver; if(ray.typeOfHit == Type.ENTITY && ray.entityHit != null && ray.entityHit instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) ray.entityHit; SlippWorld.channel.sendToServer(new MessageTargetEntity(entity, player.getHeldItem(hand))); } } return new ActionResult(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } Is there a better option for casting a longer ray that will hit entities and blocks?
  12. ... Oops I know that the event gives access to the chunk's NBT, but I haven't been able to get the data to save at all: @SubscribeEvent public void chunkSave(ChunkDataEvent.Save e) { World w = e.getWorld(); if(!w.isRemote) { WorldSavedDataMod data = WorldSavedDataMod.get(w); NBTTagCompound nbt = e.getData(); if(data.isDragonSlain) { if(!nbt.hasKey(Reference.CHUNK_REJUVENATED_TAG)) { nbt.setBoolean(Reference.CHUNK_REJUVENATED_TAG, true); System.out.println("Generating new ores"); ... e.getChunk().setModified(true); data.markDirty(); } else { System.out.println("Chunk already has ores"); } } else { System.out.println("Dragon hasn't been slain yet"); } } } The code above is what I first tried and it doesn't save the data. The only reason I tried to store it within my WorldSavedData was because of this thread.
  13. I'm trying to use WorldSavedData to keep track of every chunk that's been loaded and assign it an NBTTagCompound. Right now I have a map that stores a custom class I made called ChunkPos as the key and the NBT tag as the entry. The ChunkPos class is mainly for converting from Chunk to a String for storing the chunk's NBT tag when loading/saving. WorldSavedData (with ChunkPos at the bottom): package com.kain.slippworld; import java.util.*; import net.minecraft.nbt.*; import net.minecraft.world.*; import net.minecraft.world.chunk.*; import net.minecraft.world.storage.*; public class WorldSavedDataMod extends WorldSavedData { public static final String NAME = Reference.NAME + "_WorldData"; public boolean isDragonSlain = false; public Map<ChunkPos, NBTTagCompound> chunkData = null; public WorldSavedDataMod(String name) { super(name); chunkData = new HashMap<ChunkPos, NBTTagCompound>(); } public WorldSavedDataMod() { this(NAME); } @Override public void readFromNBT(NBTTagCompound nbt) { isDragonSlain = nbt.getBoolean(Reference.DRAGON_SLAIN_TAG); NBTTagCompound chunks = nbt.getCompoundTag(Reference.WORLD_DATA_CHUNKS); for(String string : chunks.getKeySet()) { chunkData.put(new ChunkPos(string), chunks.getCompoundTag(string)); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setBoolean(Reference.DRAGON_SLAIN_TAG, isDragonSlain); NBTTagCompound chunks = new NBTTagCompound(); for(ChunkPos chunk : chunkData.keySet()) { chunks.setTag(chunk.toString(), chunkData.get(chunk)); } nbt.setTag(Reference.WORLD_DATA_CHUNKS, chunks); return nbt; } public NBTTagCompound getChunkData(Chunk chunk) { return chunkData.get(new ChunkPos(chunk)); } public void setChunkData(Chunk chunk, NBTTagCompound nbt) { chunkData.put(new ChunkPos(chunk), nbt); } public static WorldSavedDataMod get(World w) { MapStorage s = w.getMapStorage(); WorldSavedDataMod d = (WorldSavedDataMod) s.getOrLoadData(WorldSavedDataMod.class, NAME); if(d == null) { d = new WorldSavedDataMod(); s.setData(NAME, d); } return d; } public class ChunkPos { public long x, z; public ChunkPos(long x, long z) { this.x = x; this.z = z; } public ChunkPos(Chunk chunk) { this(chunk.xPosition, chunk.zPosition); } public ChunkPos(String string) { for(int i = 0; i < string.length(); i++) { if(string.charAt(i) == ',') { try { this.x = Long.parseLong(string.substring(0, i)); this.z = Long.parseLong(string.substring(i + 1, string.length())); } catch(Exception e) { e.printStackTrace(); } } } } public String toString() { return x + "," + z; } } } Data Attachment and Reading: @SubscribeEvent public void chunkLoad(ChunkDataEvent.Save e) { World w = e.getWorld(); if(!w.isRemote) { WorldSavedDataMod data = WorldSavedDataMod.get(w); NBTTagCompound nbt = data.getChunkData(e.getChunk()); if(nbt == null) { nbt = new NBTTagCompound(); data.setChunkData(e.getChunk(), nbt); data.markDirty(); System.out.println("Chunk doesn't have data, creating"); } } } The problem is that the chunks are either not saved correctly or not loaded correctly (the "Chunk doesn't have data, creating" is being constantly spammed in one area). I know for a fact that the WorldSavedData class is actually being saved to the world since the isDragonSlain field is being properly saved/loaded and that the ChunkPos class is correctly converting from Chunk to String.
  14. I have a custom WorldSavedData class but marking it dirty won't save it. Where I edit values and mark it dirty: @SubscribeEvent public void entityDeath(LivingDeathEvent ev) { EntityLivingBase e = ev.getEntityLiving(); if(!e.world.isRemote) { if(e instanceof EntityWolf) { WorldSavedDataMod data = WorldSavedDataMod.get(e.world); data.isDragonSlain = true; data.markDirty(); ... } } } My WorldSavedData: package com.kain.slippworld; import net.minecraft.nbt.*; import net.minecraft.world.*; import net.minecraft.world.storage.*; public class WorldSavedDataMod extends WorldSavedData { public static final String NAME = Reference.NAME + "_WorldData"; public boolean isDragonSlain = false; public WorldSavedDataMod() { super(NAME); } @Override public void readFromNBT(NBTTagCompound nbt) { isDragonSlain = nbt.getBoolean(Reference.DRAGON_SLAIN_TAG); } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setBoolean(Reference.DRAGON_SLAIN_TAG, isDragonSlain); return nbt; } public static WorldSavedDataMod get(World w) { MapStorage s = w.getMapStorage(); WorldSavedDataMod d = (WorldSavedDataMod) s.getOrLoadData(WorldSavedDataMod.class, NAME); if(d == null) { d = new WorldSavedDataMod(); s.setData(NAME, d); } return d; } public void save(World w) { w.getMapStorage().setData(NAME, this); } } When I kill a wolf it sets the boolean to true and it stays true, but when I exit the world and rejoin it's false.
  15. I'm trying to add a boolean to the world save file that indicates whether or not the player has done an action, in this case when they kill the ender dragon. I found the WorldInfo class and the ...AdditionalProperty methods, but I'm not quite sure how the system for custom data works. It seems that when you call get method it returns an entry from the overall map, but when you call the set method it replaces the entire map. How would I save my data without clearing other mods' preexisting data? This is what I have right now: WorldInfo info = w.getWorldInfo(); NBTTagCompound modNBT = (NBTTagCompound) info.getAdditionalProperty(SlippWorld.NAME); if(modNBT == null) { Map<String, NBTBase> map = new HashMap<String, NBTBase>(); map.put(SlippWorld.NAME, new NBTTagCompound()); info.setAdditionalProperties(map); } modNBT = (NBTTagCompound) info.getAdditionalProperty(SlippWorld.NAME); Yet when I run it and try to access the modNBT variable it triggers an NPE.
  16. I'm aware of this but I'm asking about using the curse mod page to automatically generate a list of versions rather than creating one myself.
  17. Is there anyway to retrieve all downloads of a mod on the curseforge website? Specifically for detecting if the instance of the mod is outdated? Or should I just stay with manually setting the latest version in a text file?
  18. If I build my mod for each major version (1.7, 1.8, 1.9, 1.10, 1.11), will it be able to run on its sub-versions (1.7.2, 1.7.10, 1.9.4, 1.10.2, etc)?
  19. http://pastebin.com/0FXgPP5C I'm not sure how I would accomplish this without referencing the player. I was thinking about having a static class that would just hold the items in a field so that it won't have to reference any piece of Minecraft at all, but that seems hacky.
  20. I'm receiving this error when trying to host a server with a built version of my mod (quickconsume): Here's the class in question: http://pastebin.com/hqGR6Cjm The purpose of the MessageSyncClient class is to be sent from the server to the client, so it has to be registered on the server side. I'm not sure why it's referencing EntityPlayerSP too.
  21. I have a "recipe" where a player can right click a full cauldron that has 2 entity items in it to create 1 entity item as a product. It consumes 2 gold nuggets and 1 healing potion I or 2 gold ingots and 1 healing potion II. The problem right now is presented below: 2 gold nuggets + 1 healing potion I = 1 healing potion 2 gold ingots + 1 healing potion II = 1 greater healing potion 4 gold nuggets + 1 healing potion I = 2 healing potions 4 gold ingots + 1 healing potion II = 2 greater healing potions 6 gold nuggets + 1 healing potion I = 2 healing potions (remainder of 2 gold nuggets) 6 gold ingots + 1 healing potion II = 2 greater healing potions (remainder of 2 gold ingots) The problematic results are bolded. Code:
  22. I realize this, but in the fromBytes and toBytes methods, how do I convert the ItemStacks to bytes? I asked this question in the original post as well.
  23. Ok, I've switched over to the capability system. Is there a way of synchronizing the capabilities with the client? It doesn't seem to at the moment.
  24. I have itemstacks stored inside of the player's NBTTagCompound on the server side, but I want to render the items on the client side. As far as I know, the player's NBTTagCompound isn't synced automatically, so my issue is how to send the NBTTagCompound or ItemStacks to the client from the server. I've tried looking online for solutions, but I only found articles regarding the old Packet system using CompressedStreamTools. I'm currently using the SimpleNetworkWrapper with classes implementing IMessage; is there anyway to input the ByteBuf as a stream object that can be used with CompressedStreamTools? Another solution I tried was finding a way to compress an NBTTagCompound or a NonNullList into a byte array, but I haven't found any methods yet. I'm not sure how to provide code for this, but here's how I'm storing the ItemStacks on the server:
  25. I'm having a lot of trouble trying to render a basic item. The console says nothing about the item texture and in-game the item renders as a block textured with the purple and black squares. Mod: CommonProxy: ClientProxy: ingotMod.json: File Hierarchy:
×
×
  • Create New...

Important Information

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