use of net.fabricmc.api.Environment in project GearReborn by loleq2105.
the class TaserItem method appendTooltip.
@Environment(EnvType.CLIENT)
@Override
public void appendTooltip(ItemStack stack, @Nullable World worldIn, List<Text> tooltip, TooltipContext flagIn) {
Ag4trItemUtils.buildActiveTooltip(stack, tooltip);
// TranslatableText line1 = new TranslatableText("ag4tr.misc.tasertooltipcapacitors");
LiteralText line1 = new LiteralText("[");
// line1.append(" [");
line1.formatted(Formatting.GRAY);
if (getCapCharge4ToolTip(stack) == capacitorChargeUnits) {
line1.append(new LiteralText("■").formatted(Formatting.GREEN));
} else if (getCapCharge4ToolTip(stack) == 0) {
line1.append(new LiteralText("■").formatted(Formatting.DARK_GRAY));
} else {
line1.append(new LiteralText("■").formatted(Formatting.YELLOW));
}
line1.append("]");
line1.formatted(Formatting.GRAY);
tooltip.add(line1);
}
use of net.fabricmc.api.Environment in project architectury-api by architectury.
the class NetworkManagerImpl method registerS2CReceiver.
@SuppressWarnings("Convert2Lambda")
@Environment(EnvType.CLIENT)
private static void registerS2CReceiver(ResourceLocation id, List<PacketTransformer> packetTransformers, NetworkReceiver receiver) {
S2C_RECEIVER.put(id, receiver);
PacketTransformer transformer = PacketTransformer.concat(packetTransformers);
ClientPlayNetworking.registerGlobalReceiver(id, new ClientPlayNetworking.PlayChannelHandler() {
@Override
public void receive(Minecraft client, ClientPacketListener handler, FriendlyByteBuf buf, PacketSender sender) {
var context = context(client.player, client, true);
transformer.inbound(NetworkManager.Side.S2C, id, buf, context, (side, id1, buf1) -> {
NetworkReceiver networkReceiver = side == NetworkManager.Side.C2S ? C2S_RECEIVER.get(id1) : S2C_RECEIVER.get(id1);
if (networkReceiver == null) {
throw new IllegalArgumentException("Network Receiver not found! " + id1);
}
networkReceiver.receive(buf1, context);
});
}
});
S2C_TRANSFORMERS.put(id, transformer);
}
use of net.fabricmc.api.Environment in project Paradise-Lost by devs-immortal.
the class AmbrosiumTorchWallBlock method randomDisplayTick.
@Environment(EnvType.CLIENT)
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
int max = random.nextInt(3) + 2;
for (int i = 0; i <= max; i++) {
Direction direction = state.get(FACING).getOpposite();
double e = (double) pos.getX() + 0.5D + (random.nextDouble() - 0.5D) * 0.23D + 0.3D * (double) direction.getOffsetX();
double f = (double) pos.getY() + 0.6D + (random.nextDouble() - 0.5D) * 0.25D + 0.22D;
double g = (double) pos.getZ() + 0.5D + (random.nextDouble() - 0.5D) * 0.23D + 0.3D * (double) direction.getOffsetZ();
world.addParticle(this.particle, e, f, g, 0.0D, -4.0D, 0.0D);
}
}
use of net.fabricmc.api.Environment in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class LMSoundPacket method playSoundClient.
@Environment(EnvType.CLIENT)
public static void playSoundClient(int entityId, String soundName) {
PlayerEntity player = MinecraftClient.getInstance().player;
if (player == null)
return;
Entity entity = player.world.getEntityById(entityId);
if (entity instanceof SoundPlayable) {
((SoundPlayable) entity).play(soundName);
}
}
use of net.fabricmc.api.Environment in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class SyncMultiModelPacket method applyMultiModelClient.
// context.getTaskQueue().execute()の中では@Environmentの効力が及ばないため別メソッドに分離
@Environment(EnvType.CLIENT)
public static void applyMultiModelClient(int entityId, boolean isContract, TextureColors color, String textureName, ArmorSets<String> armorTextureName) {
World world = MinecraftClient.getInstance().world;
if (world == null)
return;
Entity entity = world.getEntityById(entityId);
if (!(entity instanceof IHasMultiModel))
return;
IHasMultiModel multiModel = (IHasMultiModel) entity;
multiModel.setContract(isContract);
multiModel.setColor(color);
LMTextureManager textureManager = LMTextureManager.INSTANCE;
textureManager.getTexture(textureName).filter(textureHolder -> multiModel.isAllowChangeTexture(entity, textureHolder, Layer.SKIN, Part.HEAD)).ifPresent(textureHolder -> multiModel.setTextureHolder(textureHolder, Layer.SKIN, Part.HEAD));
for (Part part : Part.values()) {
String armorName = armorTextureName.getArmor(part).orElseThrow(() -> new IllegalStateException("テクスチャが存在しません。"));
textureManager.getTexture(armorName).filter(textureHolder -> multiModel.isAllowChangeTexture(entity, textureHolder, Layer.INNER, part)).ifPresent(textureHolder -> multiModel.setTextureHolder(textureHolder, Layer.INNER, part));
}
}
Aggregations