use of net.minecraft.util.Identifier in project EdenClient by HahaOO7.
the class AntiStrip method onInteractBlock.
private ActionResult onInteractBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult blockHitResult) {
if (!enabled)
return ActionResult.PASS;
if (!axeItems.contains((hand == Hand.MAIN_HAND ? player.getMainHandStack() : player.getOffHandStack()).getItem()))
return ActionResult.PASS;
Identifier id = Registry.BLOCK.getId(world.getBlockState(blockHitResult.getBlockPos()).getBlock());
RegistryKey<? extends Registry<Block>> registry = BlockTags.LOGS.registry();
DynamicRegistryManager registryManager = world.getRegistryManager();
return registryManager.get(registry).containsId(id) ? ActionResult.FAIL : ActionResult.PASS;
}
use of net.minecraft.util.Identifier in project beebuddy by queenofthebees.
the class HeadFriendFeatureRenderer method render.
@Override
public void render(MatrixStack matrices, VertexConsumerProvider vcp, int light, T player, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
IFriendlyPlayer friend = (IFriendlyPlayer) (Object) player;
if (friend.beebuddy$hasHeadFriend()) {
CompoundTag t = friend.beebuddy$getHeadFriendNbt();
if (fake == null) {
fake = new FakeBeeEntity(player.world);
}
Identifier tex = null;
if (t.contains("BeeBuddyNectar")) {
String type = t.getString("BeeBuddyNectar");
if (!t.getString("BeeBuddyNectar").equals("default")) {
String texture = "textures/entity/bee/" + type + "_bee.png";
tex = new Identifier("beebuddy", texture);
}
}
if (tex == null) {
tex = new Identifier("textures/entity/bee/bee.png");
}
VertexConsumer v = vcp.getBuffer(bee.getLayer(tex));
ModelPart h = this.getContextModel().getHead();
matrices.push();
if (player.isInSneakingPose()) {
// offsets from BipedEntityModel
matrices.translate(0F, 0.2625F, 0F);
}
matrices.multiply(Vector3f.POSITIVE_Z.getRadialQuaternion(h.roll));
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(h.yaw));
matrices.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(h.pitch));
float ageMod = t.getInt("Age") >= 0 ? 2F : 1F;
float headPos = player.isInSneakingPose() ? -1.4875F : -1.5F;
matrices.translate(0F, ageMod * headPos - 0.4375, 0F);
matrices.scale(ageMod, ageMod, ageMod);
BeeEntityModelAccessor bea = (BeeEntityModelAccessor) (Object) bee;
bee.setAngles(fake, 0F, 0F, animationProgress, 0F, 0F);
bea.beebuddy$getBody().pitch = 0F;
bea.beebuddy$getBody().pivotY = 19F;
bee.render(matrices, v, light, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F);
matrices.pop();
}
}
use of net.minecraft.util.Identifier in project map-canvas-api by Patbox.
the class TestMod method onInitialize.
public void onInitialize() {
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
dispatcher.register(literal("test").then(argument("dir", IntegerArgumentType.integer(0, Direction.values().length)).then(argument("rot", IntegerArgumentType.integer(0, 4)).executes(this::test))));
dispatcher.register(literal("setfps").then(argument("fps", IntegerArgumentType.integer(1)).executes((ctx) -> {
this.msPerFrame = 1000 / IntegerArgumentType.getInteger(ctx, "fps");
return 0;
})));
dispatcher.register(literal("saveimage").executes((ctx -> {
var image = CanvasUtils.toImage(this.lastImage);
try {
ImageIO.write(image, "png", Files.newOutputStream(FabricLoader.getInstance().getGameDir().resolve("output.png"), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE));
} catch (IOException e) {
e.printStackTrace();
}
return 0;
})));
});
ServerPlayConnectionEvents.JOIN.register((ServerPlayNetworkHandler handler, PacketSender sender, MinecraftServer server) -> {
this.canvas.addPlayer(handler);
});
ServerPlayConnectionEvents.DISCONNECT.register((ServerPlayNetworkHandler handler, MinecraftServer server) -> {
this.canvas.removePlayer(handler);
});
try {
var image = ImageIO.read(new URL("https://cdn.discordapp.com/attachments/552976908070027270/854881217950122024/tinypotato.png"));
for (int i = 0; i < 10; i++) {
long start = System.currentTimeMillis();
this.tater = CanvasImage.from(image);
System.out.println("Buildin time passed = " + (System.currentTimeMillis() - start));
}
} catch (Exception e) {
e.printStackTrace();
}
try {
this.logo = CanvasImage.from(ImageIO.read(Files.newInputStream(FabricLoader.getInstance().getModContainer("map-canvas-api").get().getPath("assets/icon.png"))));
} catch (Exception e) {
e.printStackTrace();
}
try {
var vanillaZip = PolymerUtils.getClientJar();
var compPath = FabricLoader.getInstance().getGameDir().resolve("coml.zip");
var unsPath = FabricLoader.getInstance().getGameDir().resolve("uns.zip");
var vanillaJsonPath = FabricLoader.getInstance().getGameDir().resolve("../vanilla-font-json.zip");
if (!Files.exists(compPath)) {
FileUtils.copyURLToFile(new URL("https://github.com/Compliance-Resource-Pack/Compliance-Java-32x/releases/download/beta-20/Compliance-32x-Java-Beta-20.zip"), compPath.toFile(), 10000, 10000);
}
if (!Files.exists(unsPath)) {
FileUtils.copyURLToFile(new URL("https://media.forgecdn.net/files/3354/621/Unsanded-1.1.zip"), unsPath.toFile(), 10000, 10000);
}
var hdPack = new ZipFile(compPath.toFile());
var unsPack = new ZipFile(unsPath.toFile());
var jsonPack = new ZipFile(vanillaJsonPath.toFile());
this.font = FontUtils.fromVanillaFormat(new Identifier("minecraft:default"), vanillaZip);
this.fontHd = FontUtils.fromVanillaFormat(new Identifier("minecraft:default"), hdPack, vanillaZip);
this.fontUnsanded = FontUtils.fromVanillaFormat(new Identifier("minecraft:default"), unsPack, jsonPack);
var path = FabricLoader.getInstance().getGameDir().resolve("fonts_export");
Files.createDirectories(path);
{
var stream = new FileOutputStream(path.resolve("vanilla.mcaf").toFile());
RawBitmapFontSerializer.write((BitmapFont) this.font, stream);
stream.close();
}
{
var stream = new FileOutputStream(path.resolve("unsanded.mcaf").toFile());
RawBitmapFontSerializer.write((BitmapFont) this.fontUnsanded, stream);
stream.close();
}
{
var stream = new FileOutputStream(path.resolve("alt.mcaf").toFile());
RawBitmapFontSerializer.write((BitmapFont) FontUtils.fromVanillaFormat(new Identifier("minecraft:alt"), vanillaZip), stream);
stream.close();
}
{
var stream = new FileOutputStream(path.resolve("illageralt.mcaf").toFile());
RawBitmapFontSerializer.write((BitmapFont) FontUtils.fromVanillaFormat(new Identifier("minecraft:illageralt"), vanillaZip), stream);
stream.close();
}
vanillaZip.close();
hdPack.close();
unsPack.close();
jsonPack.close();
} catch (Exception e) {
e.printStackTrace();
}
try {
} catch (Exception e) {
e.printStackTrace();
}
ServerLifecycleEvents.SERVER_STARTED.register((s) -> {
this.setCurrentRenderer(this.menuRenderer);
this.renderers.add(new Pair<>("TaterDemo", new TaterDemoRenderer(this.tater, this.fontHd, this.logo)));
this.renderers.add(new Pair<>("SimpleSurface", new SurfaceRenderer()));
this.renderers.add(new Pair<>("Raycast", new RaycastRenderer(s)));
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
this.renderers.add(new Pair<>("Client Framebuffer", new ClientRenderer()));
}
this.startUpdateThread();
});
ServerLifecycleEvents.SERVER_STOPPED.register((s) -> {
this.setCurrentRenderer(this.menuRenderer);
this.renderers.clear();
this.activeRenderer = false;
});
}
use of net.minecraft.util.Identifier in project fabric by FabricMC.
the class ModNioResourcePack method findResources.
@Override
public Collection<Identifier> findResources(ResourceType type, String path, int depth, Predicate<String> predicate) {
List<Identifier> ids = new ArrayList<>();
String nioPath = path.replace("/", separator);
for (String namespace : getNamespaces(type)) {
Path namespacePath = getPath(type.getName() + "/" + namespace);
if (namespacePath != null) {
Path searchPath = namespacePath.resolve(nioPath).toAbsolutePath().normalize();
if (Files.exists(searchPath)) {
try {
Files.walk(searchPath, depth).filter(Files::isRegularFile).filter((p) -> {
String filename = p.getFileName().toString();
return !filename.endsWith(".mcmeta") && predicate.test(filename);
}).map(namespacePath::relativize).map((p) -> p.toString().replace(separator, "/")).forEach((s) -> {
try {
ids.add(new Identifier(namespace, s));
} catch (InvalidIdentifierException e) {
LOGGER.error(e.getMessage());
}
});
} catch (IOException e) {
LOGGER.warn("findResources at " + path + " in namespace " + namespace + ", mod " + modInfo.getId() + " failed!", e);
}
}
}
}
return ids;
}
use of net.minecraft.util.Identifier in project fabric by FabricMC.
the class ResourceManagerHelperImpl method sort.
protected void sort(List<ResourceReloadListener> listeners) {
listeners.removeAll(addedListeners);
// General rules:
// - We *do not* touch the ordering of vanilla listeners. Ever.
// While dependency values are provided where possible, we cannot
// trust them 100%. Only code doesn't lie.
// - We addReloadListener all custom listeners after vanilla listeners. Same reasons.
List<IdentifiableResourceReloadListener> listenersToAdd = Lists.newArrayList(addedListeners);
Set<Identifier> resolvedIds = new HashSet<>();
for (ResourceReloadListener listener : listeners) {
if (listener instanceof IdentifiableResourceReloadListener) {
resolvedIds.add(((IdentifiableResourceReloadListener) listener).getFabricId());
}
}
int lastSize = -1;
while (listeners.size() != lastSize) {
lastSize = listeners.size();
Iterator<IdentifiableResourceReloadListener> it = listenersToAdd.iterator();
while (it.hasNext()) {
IdentifiableResourceReloadListener listener = it.next();
if (resolvedIds.containsAll(listener.getFabricDependencies())) {
resolvedIds.add(listener.getFabricId());
listeners.add(listener);
it.remove();
}
}
}
for (IdentifiableResourceReloadListener listener : listenersToAdd) {
LOGGER.warn("Could not resolve dependencies for listener: " + listener.getFabricId() + "!");
}
}
Aggregations