Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Crafting Table


Blooode
 Share

Recommended Posts

5 hours ago, Blooode said:

I want to create custom crafting table in my mod. What I need to do it?

you will need:

  • a custom block (your crafting table block)
  • a custom WorkbenchContainer, you need to overwrite the stillValid method and if you want you can change some vanilla logic

 

Link to comment
Share on other sites

10 hours ago, Luis_ST said:

you will need:

  • a custom block (your crafting table block)
  • a custom WorkbenchContainer, you need to overwrite the stillValid method and if you want you can change some vanilla logic

 

I have block, container and gui. But what I need to do my custom recipes in it?

Link to comment
Share on other sites

1 hour ago, Blooode said:

I have block, container and gui. But what I need to do my custom recipes in it?

do you already have a custom recipe implemented? if not, you'll a class that'l hold the recipe and check for matches, the recipe inventory and the recipe serializer

 

then it's up to you to write the logic in your container. you can use of the world's recipe manager to see if a recipe inventory matches any recipe

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hello! I'm trying to create a capability that reads a player's CompoundTag, and extracts some custom mod data from it to assemble an object, along with being given one of those mod objects and writing it to a Player's nbt. I've hopefully created the capability correctly, but I'm not sure how to go about having a `Player` read/write this data during a world save, and how I can go about retrieving the data from a given `Player` object on world join (I know I'd need to subscribe to the event, but I have no idea what I'd do from there). Additionally, this code results in "Invalid player data" whenever I join a world, and I don't know what's in here causes that. My full repository can be found here: https://github.com/hammy3502/elementalism , and the relevant code snippets are below:   Object with Custom Mod Data (PlayerProgressionData.java): public class PlayerProgressionData implements INBTSerializable<CompoundTag> { public static final String outerTag = "elementalism_data"; public ProgressionInfo.ElementType type; public ProgressionInfo.ElementType type2; public List<ProgressionInfo> powersUnlocked; public PlayerProgressionData() { this.type = ProgressionInfo.ElementType.NONE; this.type2 = ProgressionInfo.ElementType.NONE; this.powersUnlocked = new ArrayList<>(); } @Override public CompoundTag serializeNBT() { CompoundTag toRet = new CompoundTag(); CompoundTag data = new CompoundTag(); StringBuilder powersList = new StringBuilder(); for (int i = 0; i < powersUnlocked.size(); i++) { powersList.append(powersUnlocked.get(i).id); if (i != powersUnlocked.size() - 1) { powersList.append(","); } } data.putString("unlockedPowers", powersList.toString()); data.putString("element1", this.type.id); data.putString("element2", this.type2.id); toRet.put(outerTag, data); return toRet; } @Override public void deserializeNBT(CompoundTag nbt) { if (!nbt.contains(outerTag)) return; this.powersUnlocked.clear(); CompoundTag data = nbt.getCompound(outerTag); this.type = ProgressionInfo.ElementType.getElementById(data.getString("element1")); this.type2 = ProgressionInfo.ElementType.getElementById(data.getString("element2")); String[] powerIds = data.getString("unlockedPowers").split(","); for (String id : powerIds) { ProgressionInfo info = Objects.requireNonNull(ProgressionInfoInit.ALL_PROGRESSION_INFOS.get(id)); this.powersUnlocked.add(info); } } } Capability Registration (Elementalism.java): public void registerCapabilities(RegisterCapabilitiesEvent event) { event.register(PlayerProgressionData.class); }   Capability Attaching (CommonSubscriber.java): @SubscribeEvent public void attachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (!(event.getObject() instanceof Player)) return; PlayerProgressionData progressionData = new PlayerProgressionData(); LazyOptional<PlayerProgressionData> optionalProgressionData = LazyOptional.of(() -> progressionData); ICapabilityProvider provider = new ICapabilitySerializable<CompoundTag>() { @Override public CompoundTag serializeNBT() { return progressionData.serializeNBT(); } @Override public void deserializeNBT(CompoundTag nbt) { progressionData.deserializeNBT(nbt); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == DATA_STORAGE_CAPABILITY) { return optionalProgressionData.cast(); } return LazyOptional.empty(); } }; event.addCapability(new ResourceLocation(Elementalism.MOD_ID, "data_storage"), provider); event.addListener(optionalProgressionData::invalidate); }   Thank you so much for any help!
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • I made a gist and put it in there. I wasn't sure how to put it on here so do I just give you this link? https://gist.github.com/scottshube/2f1dcba8f69537804958c255ad207fc5
    • You can use https://gist.github.com/ for large text files.
    • I copied the whole debug.log but it's too large to post.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.