ic2.core.IC2 Java Examples
The following examples show how to use
ic2.core.IC2.
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 File: BW_TileEntityContainer_Multiple.java From bartworks with MIT License | 6 votes |
@Override public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (worldObj.isRemote) { return true; } if (!player.isSneaking()) { TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof IHasGui) { return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); } else if (tile instanceof ITileWithGUI) { return worldObj.isRemote || ((ITileWithGUI) tile).openGUI(tile, player); } } return false; }
Example #2
Source File: GTItemSensorStick.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public static EnumActionResult tryParseCoords(IGTCoordinateTile coordTile, World world, EntityPlayer player, EnumHand hand) { NBTTagCompound nbt = StackUtil.getNbtData(player.getHeldItem(hand)); if (nbt.getIntArray(POS).length == 4) { int[] posArr = nbt.getIntArray(POS); if (!coordTile.isInterdimensional() && posArr[3] != world.provider.getDimension()) { IC2.platform.messagePlayer(player, "This machine does not support interdimensional communication"); return EnumActionResult.SUCCESS; } ItemStack playerStack = player.getHeldItem(hand); if (coordTile.insertSensorStick(playerStack)) { coordTile.applyCoordinates(new BlockPos(posArr[0], posArr[1], posArr[2]), posArr[3]); player.getHeldItem(hand).shrink(1); IC2.platform.messagePlayer(player, "Sensor Stick successfully installed into machine!"); return EnumActionResult.SUCCESS; } else { IC2.platform.messagePlayer(player, "Sensor Stick already found in machine"); return EnumActionResult.SUCCESS; } } IC2.platform.messagePlayer(player, "Sensor Card cannot be installed in this!"); return EnumActionResult.SUCCESS; }
Example #3
Source File: GTTileMagicEnergyConverter.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onNetworkUpdate(String field) { if (field.equals("isActive") && this.isActiveChanged()) { if (this.audioSource != null && this.audioSource.isRemoved()) { this.audioSource = null; } if (this.audioSource == null && this.getOperationSoundFile() != null) { this.audioSource = IC2.audioManager.createSource(this, PositionSpec.Center, this.getOperationSoundFile(), true, false, IC2.audioManager.defaultVolume); } if (this.getActive()) { if (this.audioSource != null) { this.audioSource.play(); } } else if (this.audioSource != null) { this.audioSource.stop(); } } super.onNetworkUpdate(field); }
Example #4
Source File: GTTileBedrockMiner.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onNetworkUpdate(String field) { if (field.equals("isActive") && this.isActiveChanged()) { if (this.audioSource != null && this.audioSource.isRemoved()) { this.audioSource = null; } if (this.audioSource == null) { this.audioSource = IC2.audioManager.createSource(this, PositionSpec.Center, Ic2Sounds.drillSoft, true, false, IC2.audioManager.defaultVolume); } if (this.getActive()) { if (this.audioSource != null) { this.audioSource.play(); } } else if (this.audioSource != null) { this.audioSource.stop(); } } super.onNetworkUpdate(field); }
Example #5
Source File: GTItemDestructoPack.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (playerIn.isSneaking() && playerIn.isCreative()) { for (int i = 0; i < playerIn.inventory.getSizeInventory(); i++) { Item item = playerIn.inventory.getStackInSlot(i).getItem(); if (!(item instanceof GTItemDestructoPack || item instanceof GTItemCreativeScanner || item instanceof GTItemSurvivalScanner || item instanceof GTItemMagnifyingGlass)) { playerIn.inventory.setInventorySlotContents(i, ItemStack.EMPTY); } } return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } if (IC2.platform.isSimulating()) { IC2.platform.launchGui(playerIn, this.getInventory(playerIn, handIn, playerIn.getHeldItem(handIn)), handIn); } return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); }
Example #6
Source File: GTItemDuctTape.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (player.isSneaking()) { return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } else if (tileEntity instanceof IInsulationModifieableConductor) { IInsulationModifieableConductor wire = (IInsulationModifieableConductor) tileEntity; if (wire.tryAddInsulation()) { player.getHeldItem(hand).damageItem(1, player); IC2.audioManager.playOnce(player, Ic2Sounds.painterUse); return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } } else { return EnumActionResult.FAIL; } }
Example #7
Source File: GTTileMagicEnergyAbsorber.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onNetworkUpdate(String field) { if (field.equals("isActive") && this.isActiveChanged()) { if (this.audioSource != null && this.audioSource.isRemoved()) { this.audioSource = null; } if (this.audioSource == null && this.getOperationSoundFile() != null) { this.audioSource = IC2.audioManager.createSource(this, PositionSpec.Center, this.getOperationSoundFile(), true, false, IC2.audioManager.defaultVolume); } if (this.getActive()) { if (this.audioSource != null) { this.audioSource.play(); } } else if (this.audioSource != null) { this.audioSource.stop(); } } super.onNetworkUpdate(field); }
Example #8
Source File: GTItemSensorStick.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if (IC2.platform.isRendering()) { IC2.audioManager.playOnce(player, Ic2Sounds.wrenchUse); return EnumActionResult.SUCCESS; } TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof IGTCoordinateTile) { return tryParseCoords((IGTCoordinateTile) tileEntity, world, player, hand); } else { NBTTagCompound nbt = StackUtil.getOrCreateNbtData(player.getHeldItem(hand)); nbt.setIntArray(POS, new int[] { pos.getX(), pos.getY(), pos.getZ(), world.provider.getDimension() }); String blockName = world.getBlockState(pos).getBlock().getLocalizedName(); nbt.setString(BLOCK, blockName); IC2.platform.messagePlayer(player, "Coordinates set to " + blockName); } return EnumActionResult.SUCCESS; }
Example #9
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (playerIn.isSneaking() && handIn == EnumHand.MAIN_HAND) { ItemStack playerStack = playerIn.getHeldItemMainhand(); NBTTagCompound nbt = StackUtil.getOrCreateNbtData(playerStack); if (nbt.hasKey(COLOR)) { int i = nbt.getInteger(COLOR); if (i + 1 > 15) { nbt.setInteger(COLOR, 0); } else { nbt.setInteger(COLOR, i + 1); } } else { nbt.setInteger(COLOR, 0); } if (!IC2.platform.isSimulating()) { IC2.audioManager.playOnce(playerIn, Ic2Sounds.cutterUse); } return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } return ActionResult.newResult(EnumActionResult.PASS, playerIn.getHeldItem(handIn)); }
Example #10
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand handIn) { if (!playerIn.isSneaking() && handIn == EnumHand.MAIN_HAND) { ItemStack playerStack = playerIn.getHeldItemMainhand(); NBTTagCompound nbt = StackUtil.getNbtData(playerStack); if (nbt.hasKey(COLOR)) { EnumDyeColor dye = EnumDyeColor.byDyeDamage(nbt.getInteger(COLOR)); if (colorBlock(world.getBlockState(pos), world, pos, null, dye)) { if (playerStack.getItemDamage() < playerStack.getMaxDamage()) { playerStack.damageItem(1, playerIn); if (!IC2.platform.isSimulating()) { IC2.audioManager.playOnce(playerIn, Ic2Sounds.painterUse); } } else { playerIn.setHeldItem(handIn, GTMaterialGen.get(GTItems.sprayCanEmpty)); if (!IC2.platform.isSimulating()) { playerIn.playSound(SoundEvents.ENTITY_ITEM_BREAK, 1.0F, 1.0F); } } return EnumActionResult.SUCCESS; } } } return EnumActionResult.PASS; }
Example #11
Source File: GTBlockMachine.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { super.onBlockPlacedBy(worldIn, pos, state, placer, stack); TileEntity tile = worldIn.getTileEntity(pos); if (this.hasVertical() && !IC2.platform.isRendering()) { if (tile instanceof TileEntityBlock) { TileEntityBlock block = (TileEntityBlock) tile; if (placer == null) { block.setFacing(EnumFacing.NORTH); } else { int pitch = Math.round(placer.rotationPitch); if (pitch >= 65) { block.setFacing(EnumFacing.UP); } else if (pitch <= -65) { block.setFacing(EnumFacing.DOWN); } else { block.setFacing(EnumFacing.fromAngle((double) placer.rotationYaw).getOpposite()); } } } } if (tile instanceof GTTileIDSU && placer != null) { ((GTTileIDSU) tile).setOwner(placer); } }
Example #12
Source File: GTRecipe.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public static void initIC2Circuits() { if (!Loader.isModLoaded(GTValues.MOD_ID_GTCX)) { if (GTConfig.general.addBasicCircuitRecipes) { int recipeId = IC2.config.getFlag(IC2_STEEL_MODE) ? 1921363733 : 1058514721; recipes.overrideRecipe("shaped_item.itemPartCircuit_" + recipeId, GTMaterialGen.getIc2(Ic2Items.electricCircuit, 1), "CCC", "RIR", "CCC", 'C', Ic2Items.insulatedCopperCable.copy(), 'R', GTValues.DUST_REDSTONE, 'I', GTValues.INPUT_INGOT_ELECTRIC); recipeId = IC2.config.getFlag(IC2_STEEL_MODE) ? -1911001323 : 1521116961; recipes.overrideRecipe("shaped_item.itemPartCircuit_" + recipeId, GTMaterialGen.getIc2(Ic2Items.electricCircuit, 1), "CRC", "CIC", "CRC", 'C', Ic2Items.insulatedCopperCable.copy(), 'R', GTValues.DUST_REDSTONE, 'I', GTValues.INPUT_INGOT_ELECTRIC); recipes.addRecipe(GTMaterialGen.getIc2(Ic2Items.electricCircuit, 2), "CCC", "III", "CCC", 'C', Ic2Items.insulatedCopperCable.copy(), 'I', GTValues.INPUT_INGOT_ELECTRIC); recipes.addRecipe(GTMaterialGen.getIc2(Ic2Items.electricCircuit, 2), "CIC", "CIC", "CIC", 'C', Ic2Items.insulatedCopperCable.copy(), 'I', GTValues.INPUT_INGOT_ELECTRIC); } if (GTConfig.general.addAdvCircuitRecipes) { recipes.overrideRecipe("shaped_item.itemPartCircuitAdv_-1948043137", GTMaterialGen.getIc2(Ic2Items.advancedCircuit, 1), "RGR", "LCL", "RGR", 'R', GTValues.DUST_REDSTONE, 'G', GTValues.DUST_GLOWSTONE, 'C', GTValues.CIRCUIT_BASIC, 'L', GTValues.INPUT_LAPIS_ANY); recipes.overrideRecipe("shaped_item.itemPartCircuitAdv_-205948801", GTMaterialGen.getIc2(Ic2Items.advancedCircuit, 1), "RLR", "GCG", "RLR", 'R', GTValues.DUST_REDSTONE, 'G', GTValues.DUST_GLOWSTONE, 'C', GTValues.CIRCUIT_BASIC, 'L', GTValues.INPUT_LAPIS_ANY); recipes.addRecipe(GTMaterialGen.getIc2(Ic2Items.advancedCircuit, 2), "RGR", "LCL", "RGR", 'R', GTValues.INPUT_INGOT_SILVER, 'G', GTValues.DUST_GLOWSTONE, 'C', GTValues.INPUT_CIRCUIT_BASIC_X2, 'L', GTValues.INPUT_LAPIS_ANY); recipes.addRecipe(GTMaterialGen.getIc2(Ic2Items.advancedCircuit, 2), "RLR", "GCG", "RLR", 'R', GTValues.INPUT_INGOT_SILVER, 'G', GTValues.DUST_GLOWSTONE, 'C', GTValues.INPUT_CIRCUIT_BASIC_X2, 'L', GTValues.INPUT_LAPIS_ANY); } } }
Example #13
Source File: GTTileBaseMachine.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public void onNetworkEvent(int event) { if (this.audioSource != null && this.audioSource.isRemoved()) { this.audioSource = null; } if (this.audioSource == null && this.getStartSoundFile() != null) { this.audioSource = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStartSoundFile(), true, false, IC2.audioManager.defaultVolume * this.soundLevel); } if (event == 0) { if (this.audioSource != null) { this.audioSource.play(); } } else if (event == 1) { if (this.audioSource != null) { this.audioSource.stop(); if (this.getInterruptSoundFile() != null) { IC2.audioManager.playOnce(this, PositionSpec.Center, this.getInterruptSoundFile(), false, IC2.audioManager.defaultVolume * this.soundLevel); } } } else if (event == 2 && this.audioSource != null) { this.audioSource.stop(); } }
Example #14
Source File: GTTileDigitalChest.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
public void tryWriteOrbData(EntityPlayer player) { if (dataSlot().isEmpty()) { IC2.platform.messagePlayer(player, "No Data Orb present!"); return; } if (GTHelperStack.isEqual(dataSlot(), GTMaterialGen.get(GTItems.orbData))) { if (dataSlot().getCount() > 1) { IC2.platform.messagePlayer(player, "Write Failed: too many orbs"); return; } dataSlot(GTMaterialGen.get(GTItems.orbDataStorage)); NBTTagCompound nbt = StackUtil.getOrCreateNbtData(dataSlot()); NBTTagList list = new NBTTagList(); for (int i = 0; i < 54; ++i) { if (this.inventory.get(i).isEmpty()) { continue; } NBTTagCompound data = new NBTTagCompound(); this.inventory.get(i).writeToNBT(data); data.setInteger("Slot", i); list.appendTag(data); this.inventory.set(i, ItemStack.EMPTY); } nbt.setTag("Items", list); } }
Example #15
Source File: GTTileBaseFuelMachine.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onNetworkEvent(int event) { if (this.audioSource != null && this.audioSource.isRemoved()) { this.audioSource = null; } if (this.audioSource == null && this.getStartSoundFile() != null) { this.audioSource = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStartSoundFile(), true, false, IC2.audioManager.defaultVolume * this.soundLevel); } if (event == 0) { if (this.audioSource != null) { this.audioSource.play(); } } else if (event == 1) { if (this.audioSource != null) { this.audioSource.stop(); if (this.getInterruptSoundFile() != null) { IC2.audioManager.playOnce(this, PositionSpec.Center, this.getInterruptSoundFile(), false, IC2.audioManager.defaultVolume * this.soundLevel); } } } else if (event == 2 && this.audioSource != null) { this.audioSource.stop(); } }
Example #16
Source File: BW_TileEntityContainer.java From bartworks with MIT License | 6 votes |
@Override public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (worldObj.isRemote) { return false; } TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof BW_TileEntity_HeatedWaterPump) { if (player.getHeldItem() != null && (player.getHeldItem().getItem().equals(Items.bucket) || player.getHeldItem().getItem() instanceof IFluidContainerItem) && ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, false) != null) if (player.getHeldItem().getItem().equals(Items.bucket) && ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, false).amount == 1000) { ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, true); player.getHeldItem().stackSize--; if (player.getHeldItem().stackSize <= 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null); player.inventory.addItemStackToInventory(new ItemStack(Items.water_bucket)); return true; } } if (!player.isSneaking()) { if (tile instanceof IHasGui) { return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); } else if (tile instanceof ITileWithGUI) { return worldObj.isRemote || ((ITileWithGUI) tile).openGUI(tile, player); } } return false; }
Example #17
Source File: GTCommandTeleport.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException { if (!IC2.platform.isOp(sender.getCommandSenderEntity().getUniqueID())) { sender.sendMessage(new TextComponentString(TextFormatting.RED + "You do not have permission to use this command")); return; } if (args.length < 1) { return; } String s = args[0]; int dim; try { dim = Integer.parseInt(s); } catch (NumberFormatException e) { sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error parsing dimension!")); return; } if (sender instanceof EntityPlayer) { GTCommandTeleporter.teleportToDimension((EntityPlayer) sender, dim, 0, 100, 0); } }
Example #18
Source File: GTTileMultiLESU.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand hand, EnumFacing facing, Side side) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty()) { this.onNetworkEvent(player, 0); if (this.isSimulating()) { IC2.platform.messagePlayer(player, this.getRedstoneMode()); } player.playSound(SoundEvents.UI_BUTTON_CLICK, 1.0F, 1.0F); return true; } return false; }
Example #19
Source File: GTTileTesseractSlave.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand arg1, EnumFacing arg2, Side arg3) { ItemStack slotStack = this.getStackInSlot(0); if (slotStack.isEmpty() || !player.isSneaking()) { return false; } ItemHandlerHelper.giveItemToPlayer(player, slotStack.copy()); slotStack.shrink(1); setTarget(null); this.targetPos = null; IC2.audioManager.playOnce(player, Ic2Sounds.wrenchUse); return true; }
Example #20
Source File: GTTileLamp.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand hand, EnumFacing enumFacing, Side side) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty()) { this.inverted = !this.inverted; this.shouldUpdate = true; if (this.isSimulating()) { String msg = this.inverted ? "Inverted" : "Not Inverted"; IC2.platform.messagePlayer(player, msg); } player.playSound(SoundEvents.UI_BUTTON_CLICK, 1.0F, 1.0F); return true; } return false; }
Example #21
Source File: GTTileDrum.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand hand, EnumFacing enumFacing, Side side) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty()) { this.flow = !this.flow; if (this.isSimulating()) { String msg = this.flow ? "Will fill adjacent tanks" : "Wont fill adjacent tanks"; IC2.platform.messagePlayer(player, msg); IC2.audioManager.playOnce(player, Ic2Sounds.wrenchUse); } } else { GTHelperFluid.doClickableFluidContainerThings(player, hand, world, pos, this.tank); } return true; }
Example #22
Source File: GTTileDisplayScreen.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand arg1, EnumFacing arg2, Side arg3) { ItemStack slotStack = this.getStackInSlot(0); if (slotStack.isEmpty() || !player.isSneaking()) { return false; } ItemHandlerHelper.giveItemToPlayer(player, slotStack.copy()); slotStack.shrink(1); this.resetTargetPos(); IC2.audioManager.playOnce(player, Ic2Sounds.wrenchUse); return true; }
Example #23
Source File: GTItemElectromagnet.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { IC2.audioManager.playOnce(playerIn, Ic2Sounds.forceFieldOp); if (IC2.platform.isSimulating()) { NBTTagCompound nbt = StackUtil.getOrCreateNbtData(playerIn.getHeldItem(handIn)); boolean result = !nbt.getBoolean(ACTIVE); nbt.setBoolean(ACTIVE, result); } return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); }
Example #24
Source File: GTItemLightHelmet.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { if (IC2.platform.isRendering()) { return; } if (TileEntitySolarPanel.isSunVisible(world, player.getPosition())) { if (ElectricItem.manager.getCharge(stack) == ElectricItem.manager.getMaxCharge(stack)) { ElectricItemManager.chargeArmor(player, 1); } else { ElectricItem.manager.charge(stack, 1.0D, 1, false, false); } } doLightHelmetThings(world, player, stack); }
Example #25
Source File: GTItemJackHammer.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player) { World worldIn = player.world; if (!player.isSneaking()) { for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, player)) { breakBlock(additionalPos, worldIn, player, stack); } if (IC2.platform.isRendering()) { IC2.audioManager.playOnce(player, Ic2Sounds.drillHard); } } return false; }
Example #26
Source File: GTBlockBattery.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { if (!IC2.platform.isRendering()) { TileEntity tile = worldIn.getTileEntity(pos); if (tile instanceof GTTileBattery) { ((GTTileBattery) tile).setItem(stack.copy()); ((GTTileBattery) tile).setElectricTileInfo(this.tier, this.maxCharge, this.transferLimit); } } super.onBlockPlacedBy(worldIn, pos, state, placer, stack); }
Example #27
Source File: GTBlockMortar.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand h, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack playerStack = player.getHeldItemMainhand(); if (playerStack.isEmpty()) { return false; } int matches = 0; for (IRecipeInput inputMatcher : INPUT_LIST) { if (inputMatcher.matches(playerStack)) { matches++; } } if (matches == 0) { return false; } if (IC2.platform.isSimulating()) { int chance = this == GTBlocks.ironMortar ? 2 : 15; if (worldIn.rand.nextInt(chance) != 0) { return true; } for (MultiRecipe recipe : RECIPE_LIST.getRecipeList()) { IRecipeInput inputStack = recipe.getInputs().get(0); ItemStack outputStack = recipe.getOutputs().getAllOutputs().get(0); if (inputStack.matches(playerStack)) { playerStack.shrink(inputStack.getAmount()); ItemHandlerHelper.giveItemToPlayer(player, outputStack.copy()); } } } worldIn.playSound(player, pos, SoundEvents.BLOCK_ANVIL_BREAK, SoundCategory.BLOCKS, 1.0F, 1.0F); return true; }
Example #28
Source File: GTRecipe.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
public static void initIC2Jetpacks() { if (GTConfig.general.harderJetpacks) { String inputItem = Loader.isModLoaded(GTValues.MOD_ID_GTCX) ? "plateStainlessSteel" : GTValues.INGOT_TITANIUM; int id = IC2.config.getFlag(IC2_STEEL_MODE) ? -1657838234 : 176647782; recipes.overrideRecipe("shaped_item.itemArmorJetpack_" + id, StackUtil.copyWithDamage(Ic2Items.jetpack, 18001), "ICI", "IFI", "R R", 'I', inputItem, 'C', GTValues.CIRCUIT_BASIC, 'F', Ic2Items.fuelCan.copy(), 'R', GTValues.DUST_REDSTONE); id = IC2.config.getFlag(IC2_STEEL_MODE) ? -1370803315 : 463682701; recipes.overrideRecipe("shaped_item.itemArmorJetpackElectric_" + id, GTMaterialGen.getIc2(Ic2Items.electricJetpack), "ICI", "IBI", "G G", 'I', inputItem, 'C', GTValues.CIRCUIT_ADVANCED, 'B', Ic2Items.batBox.copy(), 'G', Items.DRAGON_BREATH); } }
Example #29
Source File: GTGuiCompBuffer.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override @SideOnly(Side.CLIENT) public void onButtonClick(GuiIC2 gui, GuiButton button) { if (button.id == 0) { this.tile.getNetwork().initiateClientTileEntityEvent(this.tile, 0); String conduct = !this.tile.conduct ? "Emit Energy to Outputside" : "Dont emit Energy"; IC2.platform.messagePlayer(this.player.player, conduct); } if (this.tile.hasRedstone) { if (button.id == 1) { this.tile.getNetwork().initiateClientTileEntityEvent(this.tile, 1); String type = this.tile.isFluid ? "tank" : "slots"; String redstone = !this.tile.outputRedstone ? "Emit Redstone if " + type + " contain something" : "Dont emit Redstone"; IC2.platform.messagePlayer(this.player.player, redstone); } if (button.id == 2) { this.tile.getNetwork().initiateClientTileEntityEvent(this.tile, 2); String invert = !this.tile.invertRedstone ? "Invert Redstone" : "Dont invert Redstone"; IC2.platform.messagePlayer(this.player.player, invert); } } if (this.tile.hasInvertFilter && button.id == 3) { this.tile.getNetwork().initiateClientTileEntityEvent(this.tile, 3); String filter = !this.tile.invertFilter ? "Invert Filter" : "Dont invert Filter"; IC2.platform.messagePlayer(this.player.player, filter); } if (this.tile.hasNbtFilter && button.id == 4) { this.tile.getNetwork().initiateClientTileEntityEvent(this.tile, 4); String nbt = !this.tile.ignoreNbt ? "Ignore Nbt" : "Nbt Has to Match"; IC2.platform.messagePlayer(this.player.player, nbt); } }
Example #30
Source File: GuiPL.java From Production-Line with MIT License | 5 votes |
@Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(getResource()); this.x = (this.width - this.xSize) / 2; this.y = (this.height - this.ySize) / 2; this.drawTexturedModalRect(this.x, this.y, 0, 0, this.xSize, this.ySize); if (this.container.tile instanceof IUpgradableBlock) { this.mc.getTextureManager().bindTexture(new ResourceLocation(IC2.RESOURCE_DOMAIN, "textures/gui/infobutton.png")); this.drawTexturedModalRect(this.x + 3, this.y + 3, 0, 0, 10, 10); this.mc.getTextureManager().bindTexture(this.getResource()); } }