net.minecraft.tag.Tag Java Examples

The following examples show how to use net.minecraft.tag.Tag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinItem.java    From patchwork-api with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public Set<Identifier> getTags() {
	if (cachedTags == null || tagVersion != ItemTagsAccessor.getLatestVersion()) {
		this.cachedTags = new HashSet<>();

		for (final Map.Entry<Identifier, Tag<Item>> entry : ItemTags.getContainer().getEntries().entrySet()) {
			if (entry.getValue().contains((Item) (Object) this)) {
				cachedTags.add(entry.getKey());
			}
		}

		this.tagVersion = ItemTagsAccessor.getLatestVersion();
	}

	return this.cachedTags;
}
 
Example #2
Source File: MixinBlock.java    From patchwork-api with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public Set<Identifier> getTags() {
	if (cachedTags == null || tagVersion != BlockTagsAccessor.getLatestVersion()) {
		this.cachedTags = new HashSet<>();

		for (final Map.Entry<Identifier, Tag<Block>> entry : BlockTags.getContainer().getEntries().entrySet()) {
			if (entry.getValue().contains((Block) (Object) this)) {
				cachedTags.add(entry.getKey());
			}
		}

		this.tagVersion = BlockTagsAccessor.getLatestVersion();
	}

	return this.cachedTags;
}
 
Example #3
Source File: TagRegistry.java    From multiconnect with MIT License 5 votes vote down vote up
public final void addTag(Tag.Identified<T> tag, Tag.Identified<T> otherTag) {
    Set<T> value = get(otherTag.getId());
    if (value != null) {
        add(tag, value);
    } else {
        add(tag);
    }
}
 
Example #4
Source File: MixinLivingEntity.java    From multiconnect with MIT License 5 votes vote down vote up
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/tag/Tag;)D"))
private double redirectFluidHeight(LivingEntity entity, Tag<Fluid> tag) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2 && tag == FluidTags.WATER) {
        // If you're in water, you're in water, even if you're almost at the surface
        if (entity.getFluidHeight(tag) > 0)
            return 1;
    }
    return entity.getFluidHeight(tag);
}
 
Example #5
Source File: WItem.java    From LibGui with MIT License 5 votes vote down vote up
/**
 * Gets the render stacks ({@link Item#getStackForRender()}) of each item in a tag.
 */
private static List<ItemStack> getRenderStacks(Tag<? extends ItemConvertible> tag) {
	ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();

	for (ItemConvertible item : tag.values()) {
		builder.add(new ItemStack(item));
	}

	return builder.build();
}
 
Example #6
Source File: HallowedTags.java    From the-hallow with MIT License 4 votes vote down vote up
public static Tag<Fluid> register(String name) {
	return TagRegistry.fluid(TheHallow.id(name));
}
 
Example #7
Source File: HallowedTags.java    From the-hallow with MIT License 4 votes vote down vote up
public static Tag<Item> register(String name) {
	return TagRegistry.item(TheHallow.id(name));
}
 
Example #8
Source File: HallowedTags.java    From the-hallow with MIT License 4 votes vote down vote up
public static Tag<Block> register(String name) {
	return TagRegistry.block(TheHallow.id(name));
}
 
Example #9
Source File: TagRegistry.java    From multiconnect with MIT License 4 votes vote down vote up
@SafeVarargs
public final void add(Tag.Identified<T> tag, T... things) {
    add(tag, Arrays.asList(things));
}
 
Example #10
Source File: TagRegistry.java    From multiconnect with MIT License 4 votes vote down vote up
public final void add(Tag.Identified<T> tag, Collection<T> things) {
    computeIfAbsent(tag.getId(), k -> new HashSet<>()).addAll(things);
}
 
Example #11
Source File: AbstractProtocol.java    From multiconnect with MIT License 4 votes vote down vote up
protected void copyBlocks(TagRegistry<Item> tags, TagRegistry<Block> blockTags, Tag.Identified<Item> tag, Tag.Identified<Block> blockTag) {
    tags.add(tag, Collections2.transform(blockTags.get(blockTag.getId()), Block::asItem));
}
 
Example #12
Source File: MixinEntity.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "updateMovementInFluid", at = @At("HEAD"), cancellable = true)
private void modifyFluidMovementBoundingBox(Tag<Fluid> fluidTag, double d, CallbackInfoReturnable<Boolean> ci) {
    if (ConnectionInfo.protocolVersion > Protocols.V1_12_2)
        return;

    Box box = getBoundingBox().expand(0, -0.4, 0).contract(0.001);
    int minX = MathHelper.floor(box.minX);
    int maxX = MathHelper.ceil(box.maxX);
    int minY = MathHelper.floor(box.minY);
    int maxY = MathHelper.ceil(box.maxY);
    int minZ = MathHelper.floor(box.minZ);
    int maxZ = MathHelper.ceil(box.maxZ);

    if (!world.isRegionLoaded(minX, minY, minZ, maxX, maxY, maxZ))
        ci.setReturnValue(false);

    double waterHeight = 0;
    boolean foundFluid = false;
    Vec3d pushVec = Vec3d.ZERO;

    BlockPos.Mutable mutable = new BlockPos.Mutable();

    for (int x = minX; x < maxX; x++) {
        for (int y = minY - 1; y < maxY; y++) {
            for (int z = minZ; z < maxZ; z++) {
                mutable.set(x, y, z);
                FluidState state = world.getFluidState(mutable);
                if (state.isIn(fluidTag)) {
                    double height = y + state.getHeight(world, mutable);
                    if (height >= box.minY - 0.4)
                        waterHeight = Math.max(height - box.minY + 0.4, waterHeight);
                    if (y >= minY && maxY >= height) {
                        foundFluid = true;
                        pushVec = pushVec.add(state.getVelocity(world, mutable));
                    }
                }
            }
        }
    }

    if (pushVec.length() > 0) {
        pushVec = pushVec.normalize().multiply(0.014);
        setVelocity(getVelocity().add(pushVec));
    }

    this.fluidHeight.put(fluidTag, waterHeight);
    ci.setReturnValue(foundFluid);
}
 
Example #13
Source File: TagContainerAccessor.java    From multiconnect with MIT License 4 votes vote down vote up
@Accessor("entries")
void multiconnect_setEntries(BiMap<Identifier, Tag<T>> entries);
 
Example #14
Source File: WItem.java    From LibGui with MIT License 4 votes vote down vote up
public WItem(Tag<? extends ItemConvertible> tag) {
	this(getRenderStacks(tag));
}