use of net.minecraft.tags.TagKey in project assemblylinemachines by HaydenBelanger.
the class TagMaster method tagAllInMaster.
@SuppressWarnings("unchecked")
static <T> void tagAllInMaster(DataProviderContainer provider, TagType type) {
for (WrappedTagKey wn : Stream.concat(TAG_SINGLE_MASTER.keySet().stream(), TAG_GROUP_MASTER.keySet().stream()).collect(Collectors.toSet())) {
for (Object x : Stream.concat(TAG_SINGLE_MASTER.get(wn).stream(), TAG_GROUP_MASTER.get(wn).stream()).collect(Collectors.toList())) {
x = x instanceof Pair ? new ResourceLocation(((Pair<String, String>) x).getFirst(), ((Pair<String, String>) x).getSecond()) : x;
if (x instanceof String) {
String[] split = ((String) x).split(":");
if (split.length == 1) {
split = new String[] { AssemblyLineMachines.MODID, split[0] };
}
x = wn.type == TagType.BLOCK ? ForgeRegistries.BLOCKS.getValue(new ResourceLocation(split[0], split[1])) : ForgeRegistries.ITEMS.getValue(new ResourceLocation(split[0], split[1]));
}
switch(wn.type) {
case BLOCK:
if (type == wn.type)
provider.blockProvider.passback(x, (TagKey<Block>) wn.named);
if (wn.copy && type == TagType.ITEM)
provider.itemProvider.passback((TagKey<Block>) wn.named, wn.namedItemCopy.orElseThrow());
break;
case ITEM:
if (type == wn.type)
provider.itemProvider.passback(x, (TagKey<Item>) wn.named);
}
}
}
}
use of net.minecraft.tags.TagKey in project Mohist by MohistMC.
the class TagsCommand method listTagElements.
private static int listTagElements(final CommandContext<CommandSourceStack> ctx, final int page) throws CommandSyntaxException {
final ResourceKey<? extends Registry<?>> registryKey = getResourceKey(ctx, "registry", ROOT_REGISTRY_KEY).orElseThrow();
final Registry<?> registry = ctx.getSource().getServer().registryAccess().registry(registryKey).orElseThrow(() -> UNKNOWN_REGISTRY.create(registryKey.location()));
final ResourceLocation tagLocation = ResourceLocationArgument.getId(ctx, "tag");
final TagKey<?> tagKey = TagKey.create(cast(registryKey), tagLocation);
final HolderSet.Named<?> tag = registry.getTag(cast(tagKey)).orElseThrow(() -> UNKNOWN_TAG.create(tagKey.location(), registryKey.location()));
ctx.getSource().sendSuccess(createMessage(new TranslatableComponent("commands.forge.tags.tag_key", new TextComponent(tagKey.registry().location().toString()).withStyle(ChatFormatting.GOLD), new TextComponent(tagKey.location().toString()).withStyle(ChatFormatting.DARK_GREEN)), "commands.forge.tags.element_count", "commands.forge.tags.copy_element_names", tag.size(), page, ChatFormatting.YELLOW, () -> tag.stream().map(s -> s.unwrap().map(k -> k.location().toString(), Object::toString))), false);
return tag.size();
}
use of net.minecraft.tags.TagKey in project forge-autofish by North-West-Wind.
the class FilterSelectionScreen method init.
@Override
protected void init() {
reducedHeight = this.height - 90;
reducedWidth = this.width - 30;
max = /* (int) Math.round(300 * (reducedWidth / 550.0 + reducedHeight / 330.0) / 2.0) */
300;
maxPage = (int) Math.ceil(original.size() / (double) max);
searching = original;
search = new EditBox(this.font, this.width / 2 - 75, 35, 150, 20, new TranslatableComponent("gui.superfilterscreen.search")) {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == GLFW.GLFW_MOUSE_BUTTON_2)
this.setValue("");
return super.mouseClicked(mouseX, mouseY, button);
}
};
search.setResponder(s -> {
String[] args = s.split("/ +/");
String[] mods = Arrays.stream(args).filter(s1 -> s1.startsWith("@")).toArray(String[]::new);
String[] tags = Arrays.stream(args).filter(s1 -> s1.startsWith("#")).toArray(String[]::new);
String[] finalArgs = Arrays.stream(args).filter(s1 -> !s1.startsWith("@") && !s1.startsWith("#")).toArray(String[]::new);
;
searching = original.stream().filter(item -> {
boolean matchmod = mods.length < 1, matchtag = tags.length < 1, matcharg = finalArgs.length < 1;
for (String mod : mods) {
mod = mod.toLowerCase().substring(1);
matchmod = item.getRegistryName().getNamespace().toLowerCase().contains(mod);
}
Optional<IReverseTag<Item>> reverseTagsOptional = ForgeRegistries.ITEMS.tags().getReverseTag(item);
if (reverseTagsOptional.isPresent())
for (String tag : tags) {
String finalTag = tag.toLowerCase().substring(1);
matchtag = reverseTagsOptional.get().getTagKeys().anyMatch(tagKey -> tagKey.location().getPath().contains(finalTag));
}
for (String arg : finalArgs) {
arg = arg.toLowerCase();
matcharg = item.getRegistryName().getPath().contains(arg) || item.getDescription().getString().contains(arg);
}
return matchmod && matchtag && matcharg;
}).collect(Collectors.toList());
maxPage = (int) Math.ceil(searching.size() / (double) max);
if (page > maxPage - 1)
page = maxPage - 1;
});
addRenderableWidget(search);
Button add = new Button(this.width / 2 - 75, 60, 72, 20, new TranslatableComponent("gui.filterselection.save"), button -> {
List<String> items = selected.stream().map(item -> item.getRegistryName().toString()).collect(Collectors.toList());
Config.setFILTER(items);
Minecraft.getInstance().setScreen(parent);
});
addRenderableWidget(add);
Button done = new Button(this.width / 2 + 3, 60, 72, 20, new TranslatableComponent("gui.filterselection.cancel"), button -> Minecraft.getInstance().setScreen(parent));
addRenderableWidget(done);
previous = new Button(this.width / 2 - 100, 60, 20, 20, new TextComponent("<"), button -> {
if (page > 0)
page--;
});
previous.visible = false;
addRenderableWidget(previous);
next = new Button(this.width / 2 + 80, 60, 20, 20, new TextComponent(">"), button -> {
if (page < maxPage - 1)
page++;
});
next.visible = false;
addRenderableWidget(next);
}
use of net.minecraft.tags.TagKey in project ItemPhysic by CreativeMD.
the class ItemPhysicServer method updateFluidHeightAndDoFluidPushing.
public static boolean updateFluidHeightAndDoFluidPushing(ItemEntity item, TagKey<Fluid> fluidTag, double p_210500_2_) {
double size = -0.001D;
if (fluidTag == FluidTags.WATER && ItemPhysic.CONFIG.general.swimmingItems.canPass(item.getItem()))
size = 0.3;
if (item.touchingUnloadedChunk()) {
return false;
} else {
AABB aabb = item.getBoundingBox().inflate(size);
int i = Mth.floor(aabb.minX);
int j = Mth.ceil(aabb.maxX);
int k = Mth.floor(aabb.minY);
int l = Mth.ceil(aabb.maxY);
int i1 = Mth.floor(aabb.minZ);
int j1 = Mth.ceil(aabb.maxZ);
double d0 = 0.0D;
boolean flag = item.isPushedByFluid();
boolean flag1 = false;
Vec3 vec3 = Vec3.ZERO;
int k1 = 0;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int l1 = i; l1 < j; ++l1) {
for (int i2 = k; i2 < l; ++i2) {
for (int j2 = i1; j2 < j1; ++j2) {
blockpos$mutableblockpos.set(l1, i2, j2);
FluidState fluidstate = item.level.getFluidState(blockpos$mutableblockpos);
if (fluidstate.is(fluidTag)) {
double d1 = i2 + fluidstate.getHeight(item.level, blockpos$mutableblockpos);
if (d1 >= aabb.minY) {
flag1 = true;
d0 = Math.max(d1 - aabb.minY, d0);
if (flag) {
Vec3 vec31 = fluidstate.getFlow(item.level, blockpos$mutableblockpos);
if (d0 < 0.4D) {
vec31 = vec31.scale(d0);
}
vec3 = vec3.add(vec31);
++k1;
}
}
}
}
}
}
if (vec3.length() > 0.0D) {
if (k1 > 0)
vec3 = vec3.scale(1.0D / k1);
vec3 = vec3.normalize();
Vec3 vec32 = item.getDeltaMovement();
vec3 = vec3.scale(p_210500_2_ * 1.0D);
if (Math.abs(vec32.x) < 0.003D && Math.abs(vec32.z) < 0.003D && vec3.length() < 0.0045D)
vec3 = vec3.normalize().scale(0.0045D);
item.setDeltaMovement(item.getDeltaMovement().add(vec3));
}
try {
Set<TagKey<Fluid>> map = (Set<TagKey<Fluid>>) fluidOnEyesField.get(item);
map.add(fluidTag);
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
return flag1;
}
}
use of net.minecraft.tags.TagKey in project Silent-Gear by SilentChaos512.
the class GearDiggerItem method isCorrectToolForDrops.
@Override
public boolean isCorrectToolForDrops(ItemStack stack, BlockState state) {
for (Map.Entry<ToolAction, TagKey<Block>> entry : TOOL_TYPES.entrySet()) {
ToolAction action = entry.getKey();
TagKey<Block> tag = entry.getValue();
if (canPerformAction(stack, action) && GearHelper.isCorrectToolForDrops(stack, state, tag, extraMaterials)) {
return true;
}
}
return false;
}
Aggregations