net.minecraftforge.fml.relauncher.Side Java Examples

The following examples show how to use net.minecraftforge.fml.relauncher.Side. 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 Project: AdvancedRocketry   Author: zmaster587   File: TileRailgun.java    License: MIT License 6 votes vote down vote up
@Override
public void useNetworkData(EntityPlayer player, Side side, byte id,
		NBTTagCompound nbt) {
	if(side.isClient()) {
		if(id == 3) {
			EnumFacing dir = RotatableBlock.getFront(world.getBlockState(pos));
			LibVulpes.proxy.playSound(world, pos, AudioRegistry.railgunFire, SoundCategory.BLOCKS, Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.BLOCKS), 0.975f + world.rand.nextFloat()*0.05f);
			recoil = world.getTotalWorldTime();
		}
	}
	else if(id == 4) {
		minStackTransferSize = nbt.getInteger("minTransferSize");

	}			
	else if(id == 5) {
		state = RedstoneState.values()[nbt.getByte("state")];
	}
	else
		super.useNetworkData(player, side, id, nbt);
}
 
Example #2
Source Project: AgriCraft   Author: AgriCraft   File: ContainerSeedStorageBase.java    License: MIT License 6 votes vote down vote up
/**
 * Tries to move an item stack form the correct tile entity to the player's inventory
 */
public void moveStackFromTileEntityToPlayer(int slotId, ItemStack stack) {
    ISeedStorageControllable controllable = this.getControllable(stack).orElse(null);
    if (controllable == null) {
        return;
    }
    ItemStack stackToMove = controllable.getStackForSlotId(slotId);
    if (stack.isEmpty()) {
        return;
    }
    if (stackToMove.isEmpty()) {
        return;
    }
    stackToMove.setCount(stack.getCount() > stackToMove.getCount() ? stackToMove.getCount() : stack.getCount());
    stackToMove.setTagCompound(controllable.getStackForSlotId(slotId).getTagCompound());
    if (this.mergeItemStack(stackToMove, 0, PLAYER_INVENTORY_SIZE, false)) {
        if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
            //this method is only called form the gui client side, so we need to manually tell the server to execute it there
            new MessageContainerSeedStorage(stack, slotId).sendToServer();
        } else {
            //on the server decrease the size of the stack, where it is synced to the client
            controllable.decreaseStackSizeInSlot(slotId, stack.getCount() - stackToMove.getCount());
        }
    }
}
 
Example #3
Source Project: Wizardry   Author: TeamWizardry   File: ItemFairyBell.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onScroll(MouseEvent event) {
	EntityPlayer player = Minecraft.getMinecraft().player;
	if (player == null) return;

	if (Keyboard.isCreated() && event.getDwheel() != 0) {

		for (EnumHand hand : EnumHand.values()) {
			ItemStack stack = player.getHeldItem(hand);

			if (stack.getItem() != ModItems.FAIRY_BELL)
				continue;


			IMiscCapability cap = MiscCapabilityProvider.getCap(Minecraft.getMinecraft().player);
			if (cap == null) continue;

			cap.setSelectedFairy(null);

			PacketHandler.NETWORK.sendToServer(new PacketUpdateMiscCapToServer(cap.serializeNBT()));
		}
	}
}
 
Example #4
Source Project: ExNihiloAdscensio   Author: MikeLydeamore   File: ENBlocks.java    License: MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void initModels()
{
	dust.initModel();
	netherrackCrushed.initModel();
	endstoneCrushed.initModel();
	
	barrelWood.initModel();
	barrelStone.initModel();
	
	sieve.initModel();
	crucible.initModel();
	
	infestedLeaves.initModel();
	
	fluidWitchwater.initModel();
}
 
Example #5
Source Project: GregTech   Author: GregTechCE   File: NetworkHandler.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@SideOnly(Side.CLIENT)
private static void initClient() {
    registerClientExecutor(PacketUIOpen.class, (packet, handler) -> {
        UIFactory<?> uiFactory = UIFactory.FACTORY_REGISTRY.getObjectById(packet.uiFactoryId);
        if (uiFactory == null) {
            GTLog.logger.warn("Couldn't find UI Factory with id '{}'", packet.uiFactoryId);
        } else {
            uiFactory.initClientUI(packet.serializedHolder, packet.windowId, packet.initialWidgetUpdates);
        }
    });
    registerClientExecutor(PacketUIWidgetUpdate.class, (packet, handler) -> {
        GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
        if(currentScreen instanceof ModularUIGui) {
            ((ModularUIGui) currentScreen).handleWidgetUpdate(packet);
        }
    });

    registerClientExecutor(PacketBlockParticle.class, (packet, handler) -> {
        World world = Minecraft.getMinecraft().world;
        IBlockState blockState = world.getBlockState(packet.blockPos);
        ParticleManager particleManager = Minecraft.getMinecraft().effectRenderer;
        ((ICustomParticleBlock) blockState.getBlock()).handleCustomParticle(world, packet.blockPos, particleManager, packet.entityPos, packet.particlesAmount);
    });
}
 
Example #6
Source Project: AdvancedRocketry   Author: zmaster587   File: TileOxygenVent.java    License: MIT License 5 votes vote down vote up
@Override
public void useNetworkData(EntityPlayer player, Side side, byte id,
		NBTTagCompound nbt) {
	if(id == PACKET_REDSTONE_ID)
		state = RedstoneState.values()[nbt.getByte("state")];
	else if(id == PACKET_TRACE_ID) {
		allowTrace = nbt.getBoolean("trace");
		if(!allowTrace)
			radius = -1;
	}
}
 
Example #7
Source Project: OpenModsLib   Author: OpenMods   File: SyncRpcTarget.java    License: MIT License 5 votes vote down vote up
@Override
public void readFromStreamStream(Side side, EntityPlayer player, PacketBuffer input) throws IOException {
	syncProvider.readFromStreamStream(side, player, input);

	SyncMap map = getSyncMap();
	objectId = input.readVarInt();
	object = map.getObjectById(objectId);
}
 
Example #8
Source Project: Wizardry   Author: TeamWizardry   File: ModuleEffectBackup.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Vec3d position = spell.getTarget(world);

	if (position == null) return;

	ParticleBuilder glitter = new ParticleBuilder(1);
	glitter.setAlphaFunction(new InterpFloatInOut(0.0f, 0.1f));
	glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
	glitter.enableMotionCalculation();
	glitter.setScaleFunction(new InterpScale(1, 0));
	glitter.setAcceleration(new Vec3d(0, -0.05, 0));
	glitter.setCollision(true);
	glitter.setCanBounce(true);
	ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), RandUtil.nextInt(20, 30), 0, (aFloat, particleBuilder) -> {
		if (RandUtil.nextInt(5) == 0) {
			glitter.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
		} else {
			glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
		}

		glitter.setScale(RandUtil.nextFloat());
		glitter.setLifetime(RandUtil.nextInt(50, 100));
		glitter.addMotion(new Vec3d(RandUtil.nextDouble(-0.05, 0.05), RandUtil.nextDouble(0.01, 0.05), RandUtil.nextDouble(-0.05, 0.05)));
	});

}
 
Example #9
Source Project: Valkyrien-Skies   Author: ValkyrienSkies   File: TileEntityShipHelm.java    License: Apache License 2.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void renderPilotText(FontRenderer renderer, ScaledResolution gameResolution) {
    // White text.
    int color = 0xFFFFFF;
    // Extra spaces so the that the text is closer to the middle when rendered.
    String message = "Wheel Rotation:    ";
    int i = gameResolution.getScaledWidth();
    int height = gameResolution.getScaledHeight() - 35;
    float middle = (float) (i / 2 - renderer.getStringWidth(message) / 2);
    message = "Wheel Rotation: " + Math.round(wheelRotation);
    renderer.drawStringWithShadow(message, middle, height, color);
}
 
Example #10
Source Project: Wizardry   Author: TeamWizardry   File: PacketAddBouncyBlock.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void handle(@NotNull MessageContext ctx) {
	if (pos == null) return;
	World world = Minecraft.getMinecraft().world;
	BounceManager.INSTANCE.forBlock(world, pos, time);
	BounceBlockRenderer.addBounce(world, pos, time);
}
 
Example #11
Source Project: Wizardry   Author: TeamWizardry   File: PacketNemezReversal.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handle(@Nonnull MessageContext ctx) {
	ClientRunnable.run(new ClientRunnable() {
		@Override
		@SideOnly(Side.CLIENT)
		public void runIfClient() {
			NemezTracker tracker = NemezEventHandler.getCurrent();
			tracker.absorb(nemez.getTagList("root", Constants.NBT.TAG_COMPOUND));
		}
	});
}
 
Example #12
Source Project: AgriCraft   Author: AgriCraft   File: CustomWoodType.java    License: MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Nonnull
public TextureAtlasSprite getIcon() {
    if (texture == null) {
        try {
            IBlockState state = block.getStateFromMeta(meta);
            texture = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state);
        } catch (Exception e) {
            AgriCore.getLogger("agricraft").debug("Unable to load texture for custom wood block {0}!", block.getLocalizedName());
            AgriCore.getLogger("agricraft").trace(e);
            texture = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
        }
    }
    return texture;
}
 
Example #13
Source Project: TofuCraftReload   Author: 0999312   File: ItemTofuForceCore.java    License: MIT License 5 votes vote down vote up
public ItemTofuForceCore() {
    super();
    this.setMaxStackSize(1);
    this.setMaxDamage(360);
    this.setUnlocalizedName(TofuMain.MODID + "." + "tofuforce_core");
    this.addPropertyOverride(new ResourceLocation("broken"), new IItemPropertyGetter() {
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
            return isUsable(stack) ? 0.0F : 1.0F;
        }
    });
}
 
Example #14
Source Project: enderutilities   Author: maruohon   File: MessageGuiAction.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public IMessage onMessage(final MessageGuiAction message, MessageContext ctx)
{
    if (ctx.side != Side.SERVER)
    {
        EnderUtilities.logger.error("Wrong side in MessageGuiAction: " + ctx.side);
        return null;
    }

    final EntityPlayerMP sendingPlayer = ctx.getServerHandler().player;
    if (sendingPlayer == null)
    {
        EnderUtilities.logger.error("Sending player was null in MessageGuiAction");
        return null;
    }

    final WorldServer playerWorldServer = sendingPlayer.getServerWorld();
    if (playerWorldServer == null)
    {
        EnderUtilities.logger.error("World was null in MessageGuiAction");
        return null;
    }

    playerWorldServer.addScheduledTask(new Runnable()
    {
        public void run()
        {
            processMessage(message, sendingPlayer);
        }
    });

    return null;
}
 
Example #15
Source Project: AdvancedRocketry   Author: zmaster587   File: BlockAlienPlank.java    License: MIT License 5 votes vote down vote up
/**
 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
 */
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
    for (BlockAlienPlank.EnumType BlockAlienPlank$enumtype : BlockAlienPlank.EnumType.values())
    {
        list.add(new ItemStack(itemIn, 1, BlockAlienPlank$enumtype.getMetadata()));
    }
}
 
Example #16
Source Project: GregTech   Author: GregTechCE   File: ImageWidget.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    if (!this.isVisible || area == null) return;
    Position position = getPosition();
    Size size = getSize();
    area.draw(position.x, position.y, size.width, size.height);
}
 
Example #17
Source Project: ForgeHax   Author: fr1kin   File: ForgeHax.java    License: MIT License 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
  if (event.getSide() == Side.CLIENT) {
    // ---- initialize mods ----//
    getModManager().loadAll();
  }
}
 
Example #18
Source Project: BetterChests   Author: Aroma1997   File: InventoryBPortableBarrel.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public Gui getGui(EntityPlayer player, short id) {
	switch (id) {
	case 1:
		return new GuiUpgrades(new ContainerUpgrades(this, player));
	default:
		return new GuiBarrel(new ContainerBarrel(this, player));
	}
}
 
Example #19
Source Project: GregTech   Author: GregTechCE   File: MaterialMetaItem.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
protected int getColorForItemStack(ItemStack stack, int tintIndex) {
    if (tintIndex == 0 && stack.getMetadata() < metaItemOffset) {
        Material material = Material.MATERIAL_REGISTRY.getObjectById(stack.getMetadata() % 1000);
        if (material == null) return 0xFFFFFF;
        return material.materialRGB;
    }
    return super.getColorForItemStack(stack, tintIndex);
}
 
Example #20
Source Project: AdvancedRocketry   Author: zmaster587   File: EntityElevatorCapsule.java    License: MIT License 5 votes vote down vote up
@Override
public void useNetworkData(EntityPlayer player, Side side, byte id,
		NBTTagCompound nbt) {
	if(id == PACKET_WRITE_DST_INFO && world.isRemote) {
		if(nbt.hasKey("dimid")) {
			dstTilePos = new DimensionBlockPosition(nbt.getInteger("dimid"), new HashedBlockPosition(nbt.getInteger("x"), nbt.getInteger("y"), nbt.getInteger("z")));
		}
		else dstTilePos = null;
	}
	else if(id == PACKET_WRITE_SRC_INFO && world.isRemote) {
		if(nbt.hasKey("dimid")) {
			srcTilePos = new DimensionBlockPosition(nbt.getInteger("dimid"), new HashedBlockPosition(nbt.getInteger("x"), nbt.getInteger("y"), nbt.getInteger("z")));
		}
		else srcTilePos = null;
	}
	else if(id == PACKET_RECIEVE_NBT) {
		PacketHandler.sendToPlayersTrackingEntity(new PacketEntity(this, PACKET_WRITE_DST_INFO), this);
	}
	else if(id == PACKET_LAUNCH_EVENT && world.isRemote) {
		List<EntityPlayer> list = world.getEntitiesWithinAABB(EntityPlayer.class, getEntityBoundingBox());
		for(Entity ent : list) {
			if(this.getRidingEntity() == null)
				ent.startRiding(this);
		}

		MinecraftForge.EVENT_BUS.post(new RocketEvent.RocketLaunchEvent(this));
	}
	else if(id == PACKET_DEORBIT && world.isRemote) {
		MinecraftForge.EVENT_BUS.post(new RocketEvent.RocketDeOrbitingEvent(this));
	}
}
 
Example #21
Source Project: GregTech   Author: GregTechCE   File: MetaTileEntity.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Renders this meta tile entity
 * Note that you shouldn't refer to world-related information in this method, because it
 * will be called on ItemStacks too
 *
 * @param renderState render state (either chunk batched or item)
 * @param pipeline    default set of pipeline transformations
 */
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    TextureAtlasSprite atlasSprite = TextureUtils.getMissingSprite();
    IVertexOperation[] renderPipeline = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering())));
    for (EnumFacing face : EnumFacing.VALUES) {
        Textures.renderFace(renderState, translation, renderPipeline, face, Cuboid6.full, atlasSprite);
    }
}
 
Example #22
Source Project: AdvancedRocketry   Author: zmaster587   File: BlockElectricMushroom.java    License: MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World world,
		BlockPos pos, Random rand) {
	
	super.randomDisplayTick(stateIn, world, pos, rand);
	if(world.getTotalWorldTime() % 100 == 0 && world.getBiome(pos) == AdvancedRocketryBiomes.stormLandsBiome) {
		FxSystemElectricArc.spawnArc(world, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f, .3, 7);
		world.playSound(Minecraft.getMinecraft().player, pos, AudioRegistry.electricShockSmall, SoundCategory.BLOCKS, .7f,  0.975f + world.rand.nextFloat()*0.05f);
	}
}
 
Example #23
Source Project: OpenModsLib   Author: OpenMods   File: ItemGeneric.java    License: MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
	if (isInCreativeTab(tab)) {
		for (Entry<Integer, IMetaItem> entry : metaitems.entrySet())
			entry.getValue().addToCreativeList(this, entry.getKey(), subItems);
	}
}
 
Example #24
Source Project: AdvancedRocketry   Author: zmaster587   File: BlockCrystal.java    License: MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState,
		IBlockAccess world, BlockPos pos, EnumFacing side) {
      
       EnumFacing dir = side;//side.getOpposite();
       IBlockState blockState2 = world.getBlockState(pos.offset(dir));
      
       return  blockState.equals(blockState2) ? false : super.shouldSideBeRendered(blockState, world, pos, side);
  
}
 
Example #25
Source Project: Cyberware   Author: Flaxbeard   File: HudHandler.java    License: MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void addHudElements(CyberwareHudEvent event)
{
	if (event.isHudjackAvailable())
	{
		event.addElement(pd);
		event.addElement(mpd);
		event.addElement(nd);

	}
}
 
Example #26
Source Project: mobycraft   Author: AdityaGupta1   File: GenericItem.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn,
		List<String> tooltip, boolean advanced) {
	if (!this.getUnlocalizedName().equals("container_wand")) {
		return;
	}

	tooltip.add(EnumChatFormatting.DARK_RED
			+ "Right click on a container's \"Name:\" sign to remove the container.");
}
 
Example #27
Source Project: Sakura_mod   Author: 0999312   File: TileEntityRegistry.java    License: MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void render() {
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCampfire.class, new RenderTileEntityCampfire());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStoneMortar.class, new RenderTileEntityStoneMortar());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCampfirePot.class, new RenderTileEntityCampfirePot());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMapleCauldron.class, new RenderTileEntityMapleCauldron());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityShoji.class, new ShojiRender());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityOben.class, new RenderTileEntityOben());
    getItem(BlockLoader.STONEMORTAR).setTileEntityItemStackRenderer(new TileEntityRenderHelper());
}
 
Example #28
Source Project: TFC2   Author: Deadrik   File: BlockFirepit.java    License: GNU General Public License v3.0 5 votes vote down vote up
/*******************************************************************************
 * 2. Rendering
 *******************************************************************************/

@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand)
{
	TileFirepit te = (TileFirepit)world.getTileEntity(pos);
	if(te.getField(TileFirepit.FIELD_FUEL_TIMER) > 0)
	{
		double x = rand.nextDouble() * 0.7;
		double z = rand.nextDouble() * 0.7;
		world.spawnParticle(EnumParticleTypes.FLAME, pos.getX()+0.15+x, pos.getY()+0.4, pos.getZ()+0.15+z, 0, 0.0, 0);
		world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX()+0.15+x, pos.getY()+0.4, pos.getZ()+0.15+z, 0, 0.02, 0);
	}
}
 
Example #29
Source Project: TFC2   Author: Deadrik   File: EntityLivingHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleFOV(FOVUpdateEvent event)
{
	EntityPlayer player = event.getEntity();

	// Calculate FOV based on the variable draw speed of the bow depending on player armor.
	//Removed on port
	/*if (player.isUsingItem() && player.getItemInUse().getItem() instanceof ItemCustomBow)
	{
		float fov = 1.0F;
		int duration = player.getItemInUseDuration();
		float speed = ItemCustomBow.getUseSpeed(player);
		float force = duration / speed;

		if (force > 1.0F)
		{
			force = 1.0F;
		}
		else
		{
			force *= force;
		}

		fov *= 1.0F - force * 0.15F;
		event.newfov = fov;
	}*/
}
 
Example #30
Source Project: GregTech   Author: GregTechCE   File: Widget.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
protected static List<String> getItemToolTip(ItemStack itemStack) {
    Minecraft mc = Minecraft.getMinecraft();
    ITooltipFlag flag = mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
    List<String> tooltip = itemStack.getTooltip(mc.player, flag);
    for (int i = 0; i < tooltip.size(); ++i) {
        if (i == 0) {
            tooltip.set(i, itemStack.getItem().getForgeRarity(itemStack).getColor() + tooltip.get(i));
        } else {
            tooltip.set(i, TextFormatting.GRAY + tooltip.get(i));
        }
    }
    return tooltip;
}