diff --git a/src/generated/resources/assets/kasuga_lib/blockstates/test/example_fluid.json b/src/generated/resources/assets/kasuga_lib/blockstates/test/example_fluid.json index f41e09ee..4402d471 100644 --- a/src/generated/resources/assets/kasuga_lib/blockstates/test/example_fluid.json +++ b/src/generated/resources/assets/kasuga_lib/blockstates/test/example_fluid.json @@ -1,20 +1,52 @@ { "variants": { - "level=0": {}, - "level=1": {}, - "level=2": {}, - "level=3": {}, - "level=4": {}, - "level=5": {}, - "level=6": {}, - "level=7": {}, - "level=8": {}, - "level=9": {}, - "level=10": {}, - "level=11": {}, - "level=12": {}, - "level=13": {}, - "level=14": {}, - "level=15": {} + "level=0": { + "model": "minecraft:block/air" + }, + "level=1": { + "model": "minecraft:block/air" + }, + "level=2": { + "model": "minecraft:block/air" + }, + "level=3": { + "model": "minecraft:block/air" + }, + "level=4": { + "model": "minecraft:block/air" + }, + "level=5": { + "model": "minecraft:block/air" + }, + "level=6": { + "model": "minecraft:block/air" + }, + "level=7": { + "model": "minecraft:block/air" + }, + "level=8": { + "model": "minecraft:block/air" + }, + "level=9": { + "model": "minecraft:block/air" + }, + "level=10": { + "model": "minecraft:block/air" + }, + "level=11": { + "model": "minecraft:block/air" + }, + "level=12": { + "model": "minecraft:block/air" + }, + "level=13": { + "model": "minecraft:block/air" + }, + "level=14": { + "model": "minecraft:block/air" + }, + "level=15": { + "model": "minecraft:block/air" + } } } \ No newline at end of file diff --git a/src/generated/resources/data/forge/tags/fluids/example_fluid.json b/src/generated/resources/data/forge/tags/fluids/example_fluid.json new file mode 100644 index 00000000..f6e36e98 --- /dev/null +++ b/src/generated/resources/data/forge/tags/fluids/example_fluid.json @@ -0,0 +1,6 @@ +{ + "values": [ + "kasuga_lib:example_fluid_still", + "kasuga_lib:example_fluid_flow" + ] +} \ No newline at end of file diff --git a/src/main/java/kasuga/lib/core/base/BucketItem.java b/src/main/java/kasuga/lib/core/base/BucketItem.java new file mode 100644 index 00000000..5b242aa5 --- /dev/null +++ b/src/main/java/kasuga/lib/core/base/BucketItem.java @@ -0,0 +1,169 @@ +package kasuga.lib.core.base; + +import kasuga.lib.core.util.LazyRecomputable; +import net.minecraft.advancements.CriteriaTriggers; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.stats.Stats; +import net.minecraft.tags.FluidTags; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemUtils; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BucketPickup; +import net.minecraft.world.level.block.LiquidBlockContainer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraftforge.common.SoundActions; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidUtil; + +import javax.annotation.Nullable; +import java.util.Optional; +import java.util.function.Supplier; + +public class BucketItem extends net.minecraft.world.item.BucketItem { + + private final LazyRecomputable fluidSupplier; + + public BucketItem(Supplier supplier, Properties builder) { + super(supplier, builder); + fluidSupplier = LazyRecomputable.of(supplier::get); + } + + public InteractionResultHolder use(Level pLevel, Player pPlayer, InteractionHand pHand) { + Fluid content = fluidSupplier.get(); + ItemStack itemstack = pPlayer.getItemInHand(pHand); + BlockHitResult blockhitresult = getPlayerPOVHitResult(pLevel, pPlayer, content == Fluids.EMPTY ? net.minecraft.world.level.ClipContext.Fluid.SOURCE_ONLY : net.minecraft.world.level.ClipContext.Fluid.NONE); + InteractionResultHolder ret = ForgeEventFactory.onBucketUse(pPlayer, pLevel, itemstack, blockhitresult); + if (ret != null) { + return ret; + } else if (blockhitresult.getType() == HitResult.Type.MISS) { + return InteractionResultHolder.pass(itemstack); + } else if (blockhitresult.getType() != HitResult.Type.BLOCK) { + return InteractionResultHolder.pass(itemstack); + } else { + BlockPos blockpos = blockhitresult.getBlockPos(); + Direction direction = blockhitresult.getDirection(); + BlockPos blockpos1 = blockpos.relative(direction); + if (pLevel.mayInteract(pPlayer, blockpos) && pPlayer.mayUseItemAt(blockpos1, direction, itemstack)) { + BlockState blockstate1; + if (content == Fluids.EMPTY) { + blockstate1 = pLevel.getBlockState(blockpos); + if (blockstate1.getBlock() instanceof BucketPickup) { + BucketPickup bucketpickup = (BucketPickup)blockstate1.getBlock(); + ItemStack itemstack1 = bucketpickup.pickupBlock(pLevel, blockpos, blockstate1); + if (!itemstack1.isEmpty()) { + pPlayer.awardStat(Stats.ITEM_USED.get(this)); + bucketpickup.getPickupSound(blockstate1).ifPresent((p_150709_) -> { + pPlayer.playSound(p_150709_, 1.0F, 1.0F); + }); + pLevel.gameEvent(pPlayer, GameEvent.FLUID_PICKUP, blockpos); + ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, pPlayer, itemstack1); + if (!pLevel.isClientSide) { + CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)pPlayer, itemstack1); + } + + return InteractionResultHolder.sidedSuccess(itemstack2, pLevel.isClientSide()); + } + } + + return InteractionResultHolder.fail(itemstack); + } else { + blockstate1 = pLevel.getBlockState(blockpos); + BlockPos blockpos2 = this.canBlockContainFluid(pLevel, blockpos, blockstate1) ? blockpos : blockpos1; + if (this.emptyContents(pPlayer, pLevel, blockpos2, blockhitresult, itemstack)) { + this.checkExtraContent(pPlayer, pLevel, itemstack, blockpos2); + if (pPlayer instanceof ServerPlayer) { + CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)pPlayer, blockpos2, itemstack); + } + + pPlayer.awardStat(Stats.ITEM_USED.get(this)); + return InteractionResultHolder.sidedSuccess(getEmptySuccessItem(itemstack, pPlayer), pLevel.isClientSide()); + } else { + return InteractionResultHolder.fail(itemstack); + } + } + } else { + return InteractionResultHolder.fail(itemstack); + } + } + } + + public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_, @Nullable ItemStack container) { + Fluid content = fluidSupplier.get(); + if (!(content instanceof FlowingFluid)) { + return false; + } else { + BlockState blockstate = p_150717_.getBlockState(p_150718_); + Block block = blockstate.getBlock(); + Material material = blockstate.getMaterial(); + boolean flag = blockstate.canBeReplaced(content); + boolean flag1 = blockstate.isAir() || flag || block instanceof LiquidBlockContainer && ((LiquidBlockContainer)block).canPlaceLiquid(p_150717_, p_150718_, blockstate, content); + Optional containedFluidStack = Optional.ofNullable(container).flatMap(FluidUtil::getFluidContained); + if (!flag1) { + return p_150719_ != null && this.emptyContents(p_150716_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), (BlockHitResult)null, container); + } else if (containedFluidStack.isPresent() && content.getFluidType().isVaporizedOnPlacement(p_150717_, p_150718_, (FluidStack)containedFluidStack.get())) { + content.getFluidType().onVaporize(p_150716_, p_150717_, p_150718_, (FluidStack)containedFluidStack.get()); + return true; + } else if (p_150717_.dimensionType().ultraWarm() && content.is(FluidTags.WATER)) { + int i = p_150718_.getX(); + int j = p_150718_.getY(); + int k = p_150718_.getZ(); + p_150717_.playSound(p_150716_, p_150718_, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (p_150717_.random.nextFloat() - p_150717_.random.nextFloat()) * 0.8F); + + for(int l = 0; l < 8; ++l) { + p_150717_.addParticle(ParticleTypes.LARGE_SMOKE, (double)i + Math.random(), (double)j + Math.random(), (double)k + Math.random(), 0.0, 0.0, 0.0); + } + + return true; + } else if (block instanceof LiquidBlockContainer && ((LiquidBlockContainer)block).canPlaceLiquid(p_150717_, p_150718_, blockstate, content)) { + ((LiquidBlockContainer)block).placeLiquid(p_150717_, p_150718_, blockstate, ((FlowingFluid)content).getSource(false)); + this.playEmptySound(p_150716_, p_150717_, p_150718_); + return true; + } else { + if (!p_150717_.isClientSide && flag && !material.isLiquid()) { + p_150717_.destroyBlock(p_150718_, true); + } + + if (!p_150717_.setBlock(p_150718_, content.defaultFluidState().createLegacyBlock(), 11) && !blockstate.getFluidState().isSource()) { + return false; + } else { + this.playEmptySound(p_150716_, p_150717_, p_150718_); + return true; + } + } + } + } + + protected void playEmptySound(@Nullable Player pPlayer, LevelAccessor pLevel, BlockPos pPos) { + Fluid content = fluidSupplier.get(); + SoundEvent soundevent = content.getFluidType().getSound(pPlayer, pLevel, pPos, SoundActions.BUCKET_EMPTY); + if (soundevent == null) { + soundevent = content.is(FluidTags.LAVA) ? SoundEvents.BUCKET_EMPTY_LAVA : SoundEvents.BUCKET_EMPTY; + } + + pLevel.playSound(pPlayer, pPos, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); + pLevel.gameEvent(pPlayer, GameEvent.FLUID_PLACE, pPos); + } + + protected boolean canBlockContainFluid(Level worldIn, BlockPos posIn, BlockState blockstate) { + return blockstate.getBlock() instanceof LiquidBlockContainer && ((LiquidBlockContainer)blockstate.getBlock()).canPlaceLiquid(worldIn, posIn, blockstate, fluidSupplier.get()); + } +} diff --git a/src/main/java/kasuga/lib/example_env/AllExampleElements.java b/src/main/java/kasuga/lib/example_env/AllExampleElements.java index 26300c86..b74fa37a 100644 --- a/src/main/java/kasuga/lib/example_env/AllExampleElements.java +++ b/src/main/java/kasuga/lib/example_env/AllExampleElements.java @@ -1,11 +1,14 @@ package kasuga.lib.example_env; import kasuga.lib.KasugaLib; +import kasuga.lib.core.base.BucketItem; import kasuga.lib.core.menu.base.GuiBinding; import kasuga.lib.core.menu.base.GuiMenu; import kasuga.lib.core.menu.base.GuiMenuRegistry; import kasuga.lib.core.menu.base.GuiMenuType; import kasuga.lib.core.util.Envs; +import kasuga.lib.example_env.block.fluid.ExampleFluid; +import kasuga.lib.example_env.block.fluid.ExampleFluidBlock; import kasuga.lib.example_env.block.green_apple.GreenAppleBlock; import kasuga.lib.example_env.block.green_apple.GreenAppleItem; import kasuga.lib.example_env.block.green_apple.GreenAppleTile; @@ -117,16 +120,15 @@ public class AllExampleElements { */ - /* + public static final FluidReg exampleFluid = new FluidReg("example_fluid") .still(ExampleFluid::new, "block/fluid/water_still") - .flow(ExampleFluid::new, "block/fluid/water_flow") + .flow(ExampleFluid.Flowing::new, "block/fluid/water_flow") + .numericProperties(1, 8, 3, 10) .overlayTexPath("block/fluid/water_overlay") .bucketItem(BucketItem::new) .blockType(ExampleFluidBlock::new) - .submit(testRegistry); - - */ + .submit(REGISTRY); public static final MenuReg apple = new MenuReg("green_apple_screen") diff --git a/src/main/java/kasuga/lib/example_env/block/fluid/ExampleFluid.java b/src/main/java/kasuga/lib/example_env/block/fluid/ExampleFluid.java new file mode 100644 index 00000000..a7f5c925 --- /dev/null +++ b/src/main/java/kasuga/lib/example_env/block/fluid/ExampleFluid.java @@ -0,0 +1,48 @@ +package kasuga.lib.example_env.block.fluid; + +import kasuga.lib.registrations.common.FluidReg; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraftforge.common.extensions.IForgeFluid; +import net.minecraftforge.fluids.FluidType; +import net.minecraftforge.fluids.ForgeFlowingFluid; +import net.minecraftforge.registries.RegistryObject; +import org.jetbrains.annotations.NotNull; + +public class ExampleFluid extends ForgeFlowingFluid { + + + public ExampleFluid(Properties properties) { + super(properties); + } + + @Override + protected void createFluidStateDefinition(StateDefinition.Builder pBuilder) { + super.createFluidStateDefinition(pBuilder.add(LEVEL)); + } + + @Override + public boolean isSource(FluidState fluidState) { + return true; + } + + @Override + public int getAmount(@NotNull FluidState fluidState) { + return isSource(fluidState) ? 8 : (Integer) fluidState.getValue(LEVEL); + } + + public static class Flowing extends ExampleFluid { + + public Flowing(Properties properties) { + super(properties); + } + + @Override + public boolean isSource(FluidState fluidState) { + return false; + } + } +} diff --git a/src/main/java/kasuga/lib/example_env/block/fluid/ExampleFluidBlock.java b/src/main/java/kasuga/lib/example_env/block/fluid/ExampleFluidBlock.java new file mode 100644 index 00000000..c69b0113 --- /dev/null +++ b/src/main/java/kasuga/lib/example_env/block/fluid/ExampleFluidBlock.java @@ -0,0 +1,26 @@ +package kasuga.lib.example_env.block.fluid; + +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraftforge.fluids.ForgeFlowingFluid; +import net.minecraftforge.fluids.IFluidBlock; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Supplier; + +public class ExampleFluidBlock extends LiquidBlock { + + public ExampleFluidBlock(Supplier supplier, Properties properties) { + super(supplier, properties); + } + + @Override + public @Nullable BlockState getStateForPlacement(BlockPlaceContext pContext) { + return super.getStateForPlacement(pContext).setValue(LEVEL, 8); + } +} diff --git a/src/main/java/kasuga/lib/registrations/TagReg.java b/src/main/java/kasuga/lib/registrations/TagReg.java index 9d4f60c5..d0782e8c 100644 --- a/src/main/java/kasuga/lib/registrations/TagReg.java +++ b/src/main/java/kasuga/lib/registrations/TagReg.java @@ -15,15 +15,18 @@ public abstract class TagReg extends Reg { public ResourceLocation location = null; public final String otherNamespace; + public final String path; - public TagReg(String registrationKey) { + public TagReg(String registrationKey, String path) { super(registrationKey); otherNamespace = null; + this.path = path; } - public TagReg(ResourceLocation location) { - super(location.getPath()); - otherNamespace = location.getNamespace(); + public TagReg(String namespace, String registrationKey, String path) { + super(registrationKey); + otherNamespace = namespace; + this.path = path; } public abstract TagKey tag(); diff --git a/src/main/java/kasuga/lib/registrations/common/BlockTagReg.java b/src/main/java/kasuga/lib/registrations/common/BlockTagReg.java index 64ff7e90..41e31154 100644 --- a/src/main/java/kasuga/lib/registrations/common/BlockTagReg.java +++ b/src/main/java/kasuga/lib/registrations/common/BlockTagReg.java @@ -15,7 +15,6 @@ */ public class BlockTagReg extends TagReg { TagKey tag = null; - private final String path; /** * Use this to create a new block tag registration. @@ -23,14 +22,19 @@ public class BlockTagReg extends TagReg { * @param path the path of your tag file. Root folder is namespace:tag (It's usually under the "resource/data" folder) */ public BlockTagReg(String registrationKey, String path) { - super(registrationKey); - this.path = path; + super(registrationKey, path); + } + + public BlockTagReg(String namespace, String registrationKey, String path) { + super(namespace ,registrationKey, path); } @Override @Mandatory public BlockTagReg submit(SimpleRegistry registry) { - location = new ResourceLocation(registry.namespace, path); + location = otherNamespace == null ? + new ResourceLocation(registry.namespace, path) : + new ResourceLocation(otherNamespace, path); tag = BlockTags.create(location); return this; } diff --git a/src/main/java/kasuga/lib/registrations/common/BucketItemReg.java b/src/main/java/kasuga/lib/registrations/common/BucketItemReg.java index b9e076b5..4c57a6cc 100644 --- a/src/main/java/kasuga/lib/registrations/common/BucketItemReg.java +++ b/src/main/java/kasuga/lib/registrations/common/BucketItemReg.java @@ -113,7 +113,7 @@ public BucketItemReg fluidType(Supplier fluid) { * @return self. */ @Mandatory - public BucketItemReg itemType(BucketBuilder builder) { + public BucketItemReg itemType(BucketBuilder builder) { this.builder = (BucketBuilder) builder; return this; } diff --git a/src/main/java/kasuga/lib/registrations/common/FluidReg.java b/src/main/java/kasuga/lib/registrations/common/FluidReg.java index c59d1b15..5614cebc 100644 --- a/src/main/java/kasuga/lib/registrations/common/FluidReg.java +++ b/src/main/java/kasuga/lib/registrations/common/FluidReg.java @@ -38,7 +38,7 @@ public class FluidReg extends Reg { private final FluidType.Properties properties; private ForgeFlowingFluid.Properties fluidProp = null; private FluidBuilder stillBuilder = null, flowingBuilder = null; - private PropertyBuilder propertyBuilder = null; + private final ArrayList propertyBuilders; private BucketItemReg itemReg = null; private final ArrayList builders; private FluidBlockReg block; @@ -49,6 +49,7 @@ public class FluidReg extends Reg { private MenuReg menuReg = null; private int tintColor = 0xffffff; boolean registerItem = false, registerBlock = false, registerMenu = false; + private final FluidTagReg tag; /** * Create a fluid registration. @@ -59,6 +60,8 @@ public FluidReg(String registrationKey) { properties = FluidType.Properties.create(); builders = new ArrayList<>(); block = new FluidBlockReg<>(registrationKey); + propertyBuilders = new ArrayList<>(); + tag = new FluidTagReg("forge", registrationKey, "fluids/" + registrationKey); } /** @@ -89,6 +92,29 @@ public FluidReg flow(FluidBuilder builder, String flowingTexPath return this; } + public FluidReg decreasePreBlock(int decrease) { + return this.fluidProperty(prop -> prop.levelDecreasePerBlock(decrease)); + } + + public FluidReg slopeFindDistance(int distance) { + return this.fluidProperty(prop -> prop.slopeFindDistance(distance)); + } + + public FluidReg explosionResistance(float resistance) { + return this.fluidProperty(prop -> prop.explosionResistance(resistance)); + } + + public FluidReg tickRate(int tickRate) { + return this.fluidProperty(prop -> prop.tickRate(tickRate)); + } + + public FluidReg numericProperties(int decrease, int distance, int tickRate, float resistance) { + return decreasePreBlock(decrease) + .slopeFindDistance(distance) + .tickRate(tickRate) + .explosionResistance(resistance); + } + /** * Your fluid must has a fluid block, pass your fluid-block's constructor lambda here. * @param builder The constructor lambda of your fluid block. @@ -97,12 +123,14 @@ public FluidReg flow(FluidBuilder builder, String flowingTexPath @Mandatory public FluidReg blockType(FluidBlockReg.FluidBlockBuilder builder) { block.blockType(builder); + builders.add(prop -> prop.block(block::getBlock)); registerBlock = true; return this; } public FluidReg blockType(FluidBlockReg reg) { block = reg; + builders.add(prop -> prop.block(block::getBlock)); registerBlock = false; return this; } @@ -124,9 +152,10 @@ public FluidReg type(FluidType type) { * @return self. */ @Mandatory - public FluidReg bucketItem(BucketBuilder builder) { + public FluidReg bucketItem(BucketItemReg.BucketBuilder builder) { itemReg = new BucketItemReg(registrationKey + ".bucket"); - itemReg.itemType((BucketItemReg.BucketBuilder) builder); + itemReg.itemType(builder); + itemReg.fluidType(this::stillFluid); registerItem = true; return this; } @@ -315,7 +344,7 @@ public FluidReg overlayTexPath(String path) { */ @Optional public FluidReg typeProperty(PropertyBuilder builder) { - this.propertyBuilder = builder; + this.propertyBuilders.add(builder); return this; } @@ -339,9 +368,8 @@ public FluidReg fluidProperty(FluidPropertyBuilder builder) { @Override public FluidReg submit(SimpleRegistry registry) { properties.descriptionId(registrationKey); - if(propertyBuilder != null) { - propertyBuilder.build(properties); - } + + propertyBuilders.forEach(b -> b.build(properties)); if (flowingBuilder == null) { crashOnNotPresent(ForgeFlowingFluid.class, "flow", "submit"); } @@ -364,6 +392,7 @@ public FluidReg submit(SimpleRegistry registry) { if(!registry.hasMenuCache(this.toString())) registry.cacheMenuIn(menuReg); } + tag.submit(registry); return this; } @@ -459,6 +488,6 @@ public interface FluidPropertyBuilder { } public interface BucketBuilder { - T build(ForgeFlowingFluid fluid, Item.Properties properties); + T build(Supplier fluid, Item.Properties properties); } } diff --git a/src/main/java/kasuga/lib/registrations/common/FluidTagReg.java b/src/main/java/kasuga/lib/registrations/common/FluidTagReg.java index b48b6ee2..333030f6 100644 --- a/src/main/java/kasuga/lib/registrations/common/FluidTagReg.java +++ b/src/main/java/kasuga/lib/registrations/common/FluidTagReg.java @@ -16,12 +16,12 @@ public class FluidTagReg extends TagReg { private final String path; public FluidTagReg(String registrationKey, String path) { - super(registrationKey); + super(registrationKey, path); this.path = path; } - public FluidTagReg(ResourceLocation loc, String path) { - super(loc); + public FluidTagReg(String namespace, String registrationKey, String path) { + super(namespace, registrationKey, path); this.path = path; } diff --git a/src/main/java/kasuga/lib/registrations/common/ItemTagReg.java b/src/main/java/kasuga/lib/registrations/common/ItemTagReg.java index 3fbe7148..b314c021 100644 --- a/src/main/java/kasuga/lib/registrations/common/ItemTagReg.java +++ b/src/main/java/kasuga/lib/registrations/common/ItemTagReg.java @@ -16,7 +16,6 @@ */ public class ItemTagReg extends TagReg { TagKey tag = null; - private final String path; /** * Create a item tag reg. @@ -24,8 +23,11 @@ public class ItemTagReg extends TagReg { * @param path the resource location path of your item. */ public ItemTagReg(String registrationKey, String path) { - super(registrationKey); - this.path = path; + super(registrationKey, path); + } + + public ItemTagReg(String namespace, String registrationKey, String path) { + super(namespace, registrationKey, path); } /** @@ -36,7 +38,9 @@ public ItemTagReg(String registrationKey, String path) { @Override @Mandatory public ItemTagReg submit(SimpleRegistry registry) { - location = new ResourceLocation(registry.namespace, path); + location = otherNamespace == null ? + new ResourceLocation(registry.namespace, path) : + new ResourceLocation(otherNamespace, path); tag = ItemTags.create(location); return this; }