Search in sources :

Example 1 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project MinecraftForge by MinecraftForge.

the class UniversalBucket method getSubItems.

@SideOnly(Side.CLIENT)
@Override
public void getSubItems(@Nonnull Item itemIn, @Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
    for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
        if (fluid != FluidRegistry.WATER && fluid != FluidRegistry.LAVA && !fluid.getName().equals("milk")) {
            // add all fluids that the bucket can be filled  with
            FluidStack fs = new FluidStack(fluid, getCapacity());
            ItemStack stack = new ItemStack(this);
            IFluidHandlerItem fluidHandler = new FluidBucketWrapper(stack);
            if (fluidHandler.fill(fs, true) == fs.amount) {
                ItemStack filled = fluidHandler.getContainer();
                subItems.add(filled);
            }
        }
    }
}
Also used : FluidBucketWrapper(net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper) IFluidHandlerItem(net.minecraftforge.fluids.capability.IFluidHandlerItem) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project MinecraftForge by MinecraftForge.

the class AnimationStateMachine method load.

/**
     * Load a new instance if AnimationStateMachine at specified location, with specified custom parameters.
     */
@SideOnly(Side.CLIENT)
public static IAnimationStateMachine load(IResourceManager manager, ResourceLocation location, ImmutableMap<String, ITimeValue> customParameters) {
    try {
        ClipResolver clipResolver = new ClipResolver();
        ParameterResolver parameterResolver = new ParameterResolver(customParameters);
        Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver);
        TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver);
        IResource resource = manager.getResource(location);
        AnimationStateMachine asm = asmGson.fromJson(new InputStreamReader(resource.getInputStream(), "UTF-8"), AnimationStateMachine.class);
        clipResolver.asm = asm;
        parameterResolver.asm = asm;
        asm.initialize();
        //System.out.println(location + ": " + json);
        return asm;
    } catch (IOException e) {
        FMLLog.log(Level.ERROR, e, "Exception loading Animation State Machine %s, skipping", location);
        return missing;
    } catch (JsonParseException e) {
        FMLLog.log(Level.ERROR, e, "Exception loading Animation State Machine %s, skipping", location);
        return missing;
    } finally {
        Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(null);
        TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(null);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) IResource(net.minecraft.client.resources.IResource) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project MinecraftForge by MinecraftForge.

the class ForgeNetworkHandler method addClientHandlers.

@SideOnly(Side.CLIENT)
private static void addClientHandlers() {
    FMLEmbeddedChannel clientChannel = channelPair.get(Side.CLIENT);
    String handlerName = clientChannel.findChannelHandlerNameForType(ForgeRuntimeCodec.class);
    clientChannel.pipeline().addAfter(handlerName, "DimensionHandler", new DimensionMessageHandler());
    clientChannel.pipeline().addAfter(handlerName, "FluidIdRegistryHandler", new FluidIdRegistryMessageHandler());
}
Also used : FMLEmbeddedChannel(net.minecraftforge.fml.common.network.FMLEmbeddedChannel) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project Witchworks by Um-Mitternacht.

the class BrewUtils method addPotionTooltip.

@SideOnly(Side.CLIENT)
public static void addPotionTooltip(ItemStack itemIn, List<String> tooltip, float durationFactor) {
    List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemIn);
    List<Tuple<String, AttributeModifier>> attributes = Lists.newArrayList();
    if (list.isEmpty()) {
        String empty = I18n.format("effect.none").trim();
        tooltip.add(TextFormatting.GRAY + empty);
    } else {
        for (PotionEffect effect : list) {
            StringBuilder string = new StringBuilder();
            string.append(I18n.format(effect.getEffectName()).trim());
            Potion potion = effect.getPotion();
            Map<IAttribute, AttributeModifier> map = potion.getAttributeModifierMap();
            if (!map.isEmpty()) {
                for (Map.Entry<IAttribute, AttributeModifier> entry : map.entrySet()) {
                    AttributeModifier attribute = entry.getValue();
                    attribute = new AttributeModifier(attribute.getName(), potion.getAttributeModifierAmount(effect.getAmplifier(), attribute), attribute.getOperation());
                    attributes.add(new Tuple<>(entry.getKey().getName(), attribute));
                }
            }
            if (effect.getAmplifier() > 0) {
                string.append(" ").append(RomanNumber.getRoman(effect.getAmplifier()));
            }
            if (effect.getDuration() > 20) {
                string.append(" (").append(Potion.getPotionDurationString(effect, durationFactor)).append(")");
            }
            if (potion.isBadEffect()) {
                tooltip.add(TextFormatting.DARK_RED + string.toString());
            } else {
                tooltip.add(TextFormatting.DARK_BLUE + string.toString());
            }
        }
    }
    if (!attributes.isEmpty()) {
        tooltip.add("");
        tooltip.add(TextFormatting.DARK_PURPLE + I18n.format("potion.whenDrank"));
        for (Tuple<String, AttributeModifier> tuple : attributes) {
            AttributeModifier modifier = tuple.getSecond();
            double amount = modifier.getAmount();
            double newAmount;
            if (modifier.getOperation() != 1 && modifier.getOperation() != 2) {
                newAmount = modifier.getAmount();
            } else {
                newAmount = modifier.getAmount() * 100.0D;
            }
            if (amount > 0.0D) {
                tooltip.add(TextFormatting.BLUE + I18n.format("attribute.modifier.plus." + modifier.getOperation(), ItemStack.DECIMALFORMAT.format(newAmount), I18n.format("attribute.name." + (String) tuple.getFirst())));
            } else if (amount < 0.0D) {
                newAmount = newAmount * -1.0D;
                tooltip.add(TextFormatting.RED + I18n.format("attribute.modifier.take." + modifier.getOperation(), ItemStack.DECIMALFORMAT.format(newAmount), I18n.format("attribute.name." + (String) tuple.getFirst())));
            }
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Potion(net.minecraft.potion.Potion) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) IAttribute(net.minecraft.entity.ai.attributes.IAttribute) Tuple(net.minecraft.util.Tuple) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class KeyHandler method playerTick.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void playerTick(PlayerTickEvent event) {
    if (event.side == Side.SERVER)
        return;
    if (event.phase == Phase.START) {
        if (ClientPilotingManager.isPlayerPilotingShip()) {
            // if(airshipDismount.isKeyDown()){
            // PilotShipManager.dismountPlayer();
            // }else{
            Entity player = Minecraft.getMinecraft().thePlayer;
            //				player.setPosition(player.posX, player.posY, player.posZ);
            ClientPilotingManager.sendPilotKeysToServer();
        // }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1430 ItemStack (net.minecraft.item.ItemStack)250 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)154 IBlockState (net.minecraft.block.state.IBlockState)153 ResourceLocation (net.minecraft.util.ResourceLocation)143 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)137 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)127 BlockPos (net.minecraft.util.math.BlockPos)92 Block (net.minecraft.block.Block)88 TileEntity (net.minecraft.tileentity.TileEntity)86 EntityPlayer (net.minecraft.entity.player.EntityPlayer)79 EnumFacing (net.minecraft.util.EnumFacing)79 World (net.minecraft.world.World)74 Vec3d (net.minecraft.util.math.Vec3d)70 Minecraft (net.minecraft.client.Minecraft)66 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)52 ArrayList (java.util.ArrayList)50 Nonnull (javax.annotation.Nonnull)41 Entity (net.minecraft.entity.Entity)41 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)39