• Recently Browsing

    No registered users viewing this page.

  • Posts

    • I'm not sure where you got this from, but it doesn't make much sense her.e In the write method you have to serialize all your data into NBT and return that. In read you have to read it back in.   A capability provider can expose different capabilities on each direction. This is mostly useful for blocks, but the player entity for example exposes the armor and other inventories using specific Direction values as a convention. null can usually be used.
    • Yes, you should, modding isn't a good way to learn Java, get used to the language before trying to make something, think about trying to write a book in a language you aren't familiar with.
    • Hello community,   I recently started with my first minecraft mod. I usually programm in c++, but I wanted to try something new. The whole Idea of my mod is to give every LivingEntity elemental properties for defence and attack. While the player can equip the right gear for the job, most mobs will have set weaknesses/resistance and may have certain elemental attacks. For example a Blaze will naturally be prone to ice attacks, while his projectiles obviously have the element 'fire'. I want to give each mobs these properties through the 'Capabilities'-system. Every LivingEntity should have 4 lists, which should be filled by loading data from .json files. This will make adding mobs from other mods/newer minecraft versions much easier, I hope. So how can I do that? For example the zombie_elemetalproperties.json file looks like this right now: { "weakness": [ "fire" ], "resistance": [ "ice", "water" ], "absorb": [ ], "wall": [ "thunder" ] } So some of the list can be empty and some can have multiple values. My best guess is, that I use the 'compability'-system, which is why I have the ElementalCombatData class and the appropiate interface: package Tavi007.ElementalCombat.capabilities; import java.util.List; public class ElementalCombatData implements IElementalCombatData { private List<String> weaknessList = null; private List<String> resistanceList = null; private List<String> wallList = null; private List<String> absorbList = null; // Setter @Override public void setWeaknessList(List<String> elementList) { this.weaknessList = elementList; } @Override public void setResistanceList(List<String> elementList) { this.resistanceList = elementList; } @Override public void setWallList(List<String> elementList) { this.wallList = elementList; } @Override public void setAbsorbList(List<String> elementList) { this.absorbList = elementList; } //Getter @Override public List<String> getWeaknessList() { return this.weaknessList; } @Override public List<String> getResistanceList() { return this.resistanceList; } @Override public List<String> getWallList() { return this.wallList; } @Override public List<String> getAbsorbList() { return this.absorbList; } }   Once I know how I get one of these list to work, I can adjust the rest. Now I also have the capability-class: package Tavi007.ElementalCombat.capabilities; import javax.annotation.Nonnull; import javax.annotation.Nullable; import net.minecraft.nbt.ListNBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.util.LazyOptional; public class ElementalCombatDataCapability implements ICapabilitySerializable<ListNBT> { @CapabilityInject(IElementalCombatData.class) public static final Capability<IElementalCombatData> DATA_CAPABILITY = null; private LazyOptional<IElementalCombatData> instance = LazyOptional.of(DATA_CAPABILITY::getDefaultInstance); public static void register() { CapabilityManager.INSTANCE.register(IElementalCombatData.class, new ElementalCombatDataStorage(), ElementalCombatData::new); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { return DATA_CAPABILITY.orEmpty(cap, instance); } @Override public ListNBT serializeNBT() { return (ListNBT) DATA_CAPABILITY.getStorage().writeNBT(DATA_CAPABILITY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional cannot be empty!")), null); } @Override public void deserializeNBT(ListNBT nbt) { DATA_CAPABILITY.getStorage().readNBT(DATA_CAPABILITY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional cannot be empty!")), null, nbt); } } Granted, I only copied it from another thread, that I found through google, which I modified a little bit. I'm not sure, if I did everything correct so far. So please correct me, if you found anything.   My problem right now lies within the storage-class, where the readNBT and writeNBT function reside. Right now it looks like this: package Tavi007.ElementalCombat.capabilities; import javax.annotation.Nullable; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.INBT; import net.minecraft.nbt.JsonToNBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; public class ElementalCombatDataStorage implements Capability.IStorage<IElementalCombatData> { @Nullable @Override public INBT writeNBT(Capability<IElementalCombatData> capability, IElementalCombatData instance, Direction side) { CompoundNBT tag = JsonToNBT.getTagFromJson(jsonString) return tag; } @Override public void readNBT(Capability<IElementalCombatData> capability, IElementalCombatData instance, Direction side, INBT nbt) { if (!(instance instanceof ElementalCombatData)) throw new IllegalArgumentException("Can not deserialize to an instance that isn't the default implementation"); } } What do I have to enter for jsonString and what do I have to do in the read-function? Also what is 'Direction' supposed to mean?   Thanks in advance  
    • package com.callumwong.sixsomod.events; import com.callumwong.sixsomod.SixSOMod; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.item.Items; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.extensions.IForgeBlockState; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @Mod.EventBusSubscriber(modid = SixSOMod.MOD_ID, bus = Bus.FORGE) public class ClickWaterEvent { @SubscribeEvent public static void clickWaterEvent(PlayerInteractEvent.RightClickBlock event) { BlockPos blockPos = event.getPos().offset(event.getFace()); IForgeBlockState state = event.getWorld().getBlockState(blockPos); if (((BlockState) state).getBlock() == Blocks.WATER) { if(player.getCurrentEquuippedItem() != null){ if(player.getCurrentEquippedItem().getItem() == Items.GLASS_BOTTLE){ } } } } }   I am very new to Minecraft Forge, and I am still a beginner at Java. Should I be learning more about Java before I start using Forge?
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

  • Who's Online (See full list)