mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Add Item.getModId to show which mod is associated with a subitem (#4330)
This commit is contained in:
1 parent
8a285e0fed
commit
cf39ff18e1
4 files changed
+97
-6
No files matched your search
@@ -356,6 +356,21 @@ public abstract class FluidRegistry
|
||||
return name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getModId(@Nullable FluidStack fluidStack)
|
||||
{
|
||||
if (fluidStack != null)
|
||||
{
|
||||
String defaultFluidName = getDefaultFluidName(fluidStack.getFluid());
|
||||
if (defaultFluidName != null)
|
||||
{
|
||||
ResourceLocation fluidResourceName = new ResourceLocation(defaultFluidName);
|
||||
return fluidResourceName.getResourceDomain();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void loadFluidDefaults(NBTTagCompound tag)
|
||||
{
|
||||
Set<String> defaults = Sets.newHashSet();
|
||||
|
||||
@@ -42,8 +42,6 @@ import net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -284,6 +282,15 @@ public class UniversalBucket extends Item
|
||||
return nbtSensitive;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getCreatorModId(@Nonnull ItemStack itemStack)
|
||||
{
|
||||
FluidStack fluidStack = getFluid(itemStack);
|
||||
String modId = FluidRegistry.getModId(fluidStack);
|
||||
return modId != null ? modId : super.getCreatorModId(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(@Nonnull ItemStack stack, NBTTagCompound nbt)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user