mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 06:24:43 +00:00
1 parent
80eb12e59d
commit
ca2ed1ff7a
139 files changed
+1034
-4067
No files matched your search
@@ -1059,6 +1059,6 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean shouldDisplayFluidOverlay(BlockState state, IBlockDisplayReader world, BlockPos pos, FluidState fluidState)
|
||||
{
|
||||
return state.getBlock() instanceof BreakableBlock || state.getBlock() instanceof StainedGlassBlock;
|
||||
return state.getBlock() instanceof BreakableBlock || state.getBlock() instanceof LeavesBlock;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,13 @@ package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.data.TagsProvider;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
//TODO, Tag removal support.
|
||||
public interface IForgeTagBuilder<T>
|
||||
{
|
||||
|
||||
@@ -37,73 +43,32 @@ public interface IForgeTagBuilder<T>
|
||||
return builder;
|
||||
}
|
||||
|
||||
/*default Tag.Builder<T> addOptional(final TagCollection<T> collection, final ResourceLocation... locations)
|
||||
{
|
||||
return addOptional(collection, Arrays.asList(locations));
|
||||
default TagsProvider.Builder<T> replace() {
|
||||
return replace(true);
|
||||
}
|
||||
|
||||
default Tag.Builder<T> addOptional(final TagCollection<T> collection, final Collection<ResourceLocation> locations)
|
||||
{
|
||||
return addOptional(collection.getEntryLookup(), locations);
|
||||
default TagsProvider.Builder<T> replace(boolean value) {
|
||||
getBuilder().getInternalBuilder().replace(value);
|
||||
return getBuilder();
|
||||
}
|
||||
|
||||
@Deprecated //Use the TagCollection version
|
||||
default Tag.Builder<T> addOptional(final Function<ResourceLocation, Optional<T>> entryLookup, final Collection<ResourceLocation> locations)
|
||||
default TagsProvider.Builder<T> addOptional(final ResourceLocation... locations)
|
||||
{
|
||||
return ((Tag.Builder<T>)this).add(new IOptionalTagEntry<T>() {
|
||||
@Override
|
||||
public void populate(Collection<T> itemsIn)
|
||||
{
|
||||
locations.stream().map(entryLookup).forEach(e -> e.ifPresent(itemsIn::add));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonArray array, Function<T, ResourceLocation> getNameForObject)
|
||||
{
|
||||
locations.stream().map(ResourceLocation::toString).forEach(array::add);
|
||||
}
|
||||
});
|
||||
return addOptional(Arrays.asList(locations));
|
||||
}
|
||||
|
||||
default Tag.Builder<T> addOptionalTag(final TagCollection<T> collection, @SuppressWarnings("unchecked") final Tag<T>... tags)
|
||||
default TagsProvider.Builder<T> addOptional(final Collection<ResourceLocation> locations)
|
||||
{
|
||||
for (Tag<T> tag : tags)
|
||||
addOptionalTag(tag.getId());
|
||||
return ((Tag.Builder<T>)this);
|
||||
return getBuilder().add(ForgeHooks.makeOptionalTag(true, locations));
|
||||
}
|
||||
|
||||
default Tag.Builder<T> addOptionalTag(final ResourceLocation... tags)
|
||||
default TagsProvider.Builder<T> addOptionalTag(final ResourceLocation... locations)
|
||||
{
|
||||
for (ResourceLocation rl : tags)
|
||||
addOptionalTag(rl);
|
||||
return ((Tag.Builder<T>)this);
|
||||
return addOptionalTag(Arrays.asList(locations));
|
||||
}
|
||||
|
||||
default Tag.Builder<T> addOptionalTag(ResourceLocation tag)
|
||||
default TagsProvider.Builder<T> addOptionalTag(final Collection<ResourceLocation> locations)
|
||||
{
|
||||
class TagTarget<U> extends Tag.TagEntry<U> implements IOptionalTagEntry<U>
|
||||
{
|
||||
private Tag<U> resolvedTag = null;
|
||||
protected TagTarget(ResourceLocation referent) {
|
||||
super(referent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resolve(@Nonnull Function<ResourceLocation, Tag<U>> resolver)
|
||||
{
|
||||
if (this.resolvedTag == null)
|
||||
this.resolvedTag = resolver.apply(this.getSerializedId());
|
||||
return true; // never fail if resolver returns null
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(@Nonnull Collection<U> items)
|
||||
{
|
||||
if (this.resolvedTag != null)
|
||||
items.addAll(this.resolvedTag.getAllElements());
|
||||
}
|
||||
};
|
||||
|
||||
return ((Tag.Builder<T>)this).add(new TagTarget<>(tag));
|
||||
}*/
|
||||
return getBuilder().add(ForgeHooks.makeOptionalTag(false, locations));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user