Jump to content

DoubleSix6

Members
  • Posts

    14
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

DoubleSix6's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. package com.darkona.adventurebackpack.block; import com.darkona.adventurebackpack.AdventureBackpack; import com.darkona.adventurebackpack.client.Icons; import com.darkona.adventurebackpack.handlers.GuiHandler; import com.darkona.adventurebackpack.init.ModItems; import com.darkona.adventurebackpack.reference.BackpackNames; import com.darkona.adventurebackpack.reference.ModInfo; import com.darkona.adventurebackpack.util.LogHelper; import com.darkona.adventurebackpack.util.Utils; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import codechicken.lib.math.MathHelper; import codechicken.lib.vec.BlockCoord; import net.minecraft.util.EnumFacing; import java.util.Random; /** * Created on 12/10/2014. * @author Javier Darkona */ public class BlockAdventureBackpack extends BlockContainer { public BlockAdventureBackpack() { super(new BackpackMaterial()); setHardness(1.0f); setStepSound(soundTypeCloth); setResistance(2000f); } /** * Pretty effects for the bookshelf ;) * * @param world * @param x * @param y * @param z * @param random */ @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random random) { if (getAssociatedTileColorName(world, x, y, z).equals("Bookshelf")) { ChunkCoordinates enchTable = Utils.findBlock3D(world, x, y, z, Blocks.enchanting_table, 2, 2); if(enchTable !=null) { if (!world.isAirBlock((enchTable.posX - x) / 2 + x, enchTable.posY, (enchTable.posZ - z) / 2 + z)) { return; } for (int o = 0; o < 4; o++) { world.spawnParticle("enchantmenttable",enchTable.posX + 0.5D,enchTable.posY + 2.0D,enchTable.posZ + 0.5D, ((x - enchTable.posX) + random.nextFloat()) - 0.5D, ((y - enchTable.posY) - random.nextFloat() - 1.0F), ((z - enchTable.posZ) + random.nextFloat()) - 0.5D); } } } } public int getMobilityFlag() { return 0; } @Override public String getHarvestTool(int metadata) { return null; } @Override public int getHarvestLevel(int metadata) { return 0; } @Override public boolean isToolEffective(String type, int metadata) { return true; } private String getAssociatedTileColorName(IBlockAccess world, int x, int y, int z) { return ((TileAdventureBackpack) world.getTileEntity(x, y, z)).getColorName(); } @Override public boolean canRenderInPass(int pass) { return true; } @Override public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { return false; } @Override public float getEnchantPowerBonus(World world, int x, int y, int z) { return getAssociatedTileColorName(world, x, y, z).equals("Bookshelf") ? 10 : 0; } @Override public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { return false; } @Override public boolean isWood(IBlockAccess world, int x, int y, int z) { return false; } @Override public boolean isLeaves(IBlockAccess world, int x, int y, int z) { return false; } @Override public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { return false; } @Override public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return 0; } @Override public boolean canHarvestBlock(EntityPlayer player, int meta) { return true; } @Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (getAssociatedTileColorName(world, x, y, z).equals("Cactus")) { entity.attackEntityFrom(DamageSource.cactus, 1.0F); } } /** * Called when a player hits the block. Args: world, x, y, z, player * * @param p_149699_1_ * @param p_149699_2_ * @param p_149699_3_ * @param p_149699_4_ * @param p_149699_5_ */ @Override public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) { BlockPos pos3 = new BlockPos(p_149699_2_, p_149699_3_, p_149699_4_); super.onBlockClicked(p_149699_1_, pos3, p_149699_5_); } /** * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata * * @param world * @param x * @param y * @param z * @param side * @param hitX * @param hitY * @param hitZ * @param meta */ @Override public IBlockState onBlockPlaced(World world, int x, int y, int z, float hitX, float hitY, float hitZ, int meta) { EntityLivingBase placer; EnumFacing facing; BlockPos pos4 = new BlockPos(x, y, z); return super.onBlockPlaced(world, pos4, facing, hitX, hitY, hitZ, meta, placer); } @Override public boolean isFlammable(IBlockAccess world, int x, int y, int z, EnumFacing face) { return false; } @Override public String getUnlocalizedName() { return "blockAdventureBackpack"; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { Icons.milkStill = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.milk"); Icons.melonJuiceStill = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.melonJuiceStill"); Icons.melonJuiceFlowing = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.melonJuiceFlowing"); Icons.mushRoomStewStill = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.mushroomStewStill"); Icons.mushRoomStewFlowing = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.mushroomStewFlowing"); } @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { if (getAssociatedTileColorName(world, x, y, z).equals("Glowstone")) { BlockPos pos5 = new BlockPos (x, y, z); return 15; } else if (world.getTileEntity(pos5) != null && world.getTileEntity(pos5) instanceof TileAdventureBackpack) { return ((TileAdventureBackpack) world.getTileEntity(pos5)).getLuminosity(); } else { return 0; } } public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) { return getAssociatedTileColorName(world, x, y, z).equals("Redstone") ? 15 : 0; } @Override public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { return getAssociatedTileColorName(world, x, y, z).equals("Redstone"); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { FMLNetworkHandler.openGui(player, AdventureBackpack.instance, GuiHandler.BACKPACK_TILE, world, x, y, z); return true; } @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { ItemStack backpack = new ItemStack(ModItems.adventureBackpack, 1); BackpackNames.setBackpackColorNameFromDamage(backpack, BackpackNames.getBackpackDamageFromName(getAssociatedTileColorName(world, x, y, z))); return backpack; } @Override public boolean hasTileEntity(int meta) { return true; } @Override public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) { int meta = blockAccess.getBlockMetadata(x, y, z); meta = (meta & 8) >= 8 ? meta - 8 : meta; meta = (meta & 4) >= 4 ? meta - 4 : meta; switch (meta) { case 0: case 2: setBlockBounds(0.0F, 0.0F, 0.4F, 1.0F, 0.6F, 0.6F); break; case 1: case 3: setBlockBounds(0.4F, 0.0F, 0.0F, 0.6F, 0.6F, 1.0F); break; } } @Override public int getRenderType() { return -1; } @Override public boolean isOpaqueCube() { return false; } @Override public boolean renderAsNormalBlock() { return false; } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { int dir = MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3; if (stack != null && stack.stackTagCompound != null && stack.stackTagCompound.hasKey("color")) { if (stack.stackTagCompound.getString("color").contains("BlockRedstone")) { dir = dir | 8; } if (stack.stackTagCompound.getString("color").contains("Lightgem")) { dir = dir | 4; } } world.setBlockMetadataWithNotify(x, y, z, dir, 3); createNewTileEntity(world, world.getBlockMetadata(x, y, z)); } @Override public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int side) { return (EnumFacing.getOrientation(side) == EnumFacing.UP); } @Override public int quantityDropped(int meta, int fortune, Random random) { return 0; } @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { setBlockBoundsBasedOnState(world, x, y, z); return super.getSelectedBoundingBoxFromPool(world, x, y, z); } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { return Blocks.WOOL.getIcon(par1,par2); } @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { setBlockBoundsBasedOnState(world, x, y, z); return super.getCollisionBoundingBoxFromPool(world, x, y, z); } @Override public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 start, Vec3 end) { setBlockBoundsBasedOnState(world, x, y, z); return super.collisionRayTrace(world, x, y, z, start, end); } @Override public boolean canReplace(World p_149705_1_, int p_149705_2_, int p_149705_3_, int p_149705_4_, int p_149705_5_, ItemStack p_149705_6_) { return false; } @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean harvest) { BlockPos pos6 = new BlockPos(x, y, z); TileEntity tile = world.getTileEntity(pos6); if (tile instanceof TileAdventureBackpack && !world.isRemote && player != null) { if ((player.isSneaking()) ? ((TileAdventureBackpack) tile).equip(world, player, x, y, z) : ((TileAdventureBackpack) tile).drop(world, player, x, y, z)) { return world.func_147480_a(x, y, z, false); } } else { return world.func_147480_a(x, y, z, false); } return false; } @Override public void breakBlock(World world, int x, int y, int z, Block block, int meta) { BlockPos pos7 = new BlockPos(x, y, z); TileEntity te = world.getTileEntity(pos7); if (te != null && te instanceof IInventory) { IInventory inventory = (IInventory) te; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlotOnClosing(i); if (stack != null) { float spawnX = x + world.rand.nextFloat(); float spawnY = y + world.rand.nextFloat(); float spawnZ = z + world.rand.nextFloat(); float mult = 0.05F; EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, stack); droppedItem.motionX = -0.5F + world.rand.nextFloat() * mult; droppedItem.motionY = 4 + world.rand.nextFloat() * mult; droppedItem.motionZ = -0.5 + world.rand.nextFloat() * mult; world.spawnEntityInWorld(droppedItem); } } } super.breakBlock(world, x, y, z, world.getBlock(x, y, z), meta); } @Override public TileEntity createTileEntity(World world, int metadata) { return new TileAdventureBackpack(); } @Override public TileEntity createNewTileEntity(World world, int metadata) { return createTileEntity(world, metadata); } @Override public boolean canDropFromExplosion(Explosion p_149659_1_) { return false; } @Override public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) { world.func_147480_a(x, y, z, false); } @Override public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { //DO NOTHING } } can anyone tell me if this code are correct?
  2. If there isn't how can I convert this part? public class BlockCampFire extends BlockContainer { private IIcon icon; public BlockCampFire() { super(Material.ROCK); this.setTickRandomly(true); this.setCreativeTab(CreativeTabAB.ADVENTURE_BACKPACK_CREATIVE_TAB); }
  3. I have searched in the google and I can't found anything equivalent to net.minecraft.util.IIcon to 1.10.2
  4. package com.darkona.adventurebackpack.block; import com.darkona.adventurebackpack.AdventureBackpack; import com.darkona.adventurebackpack.client.Icons; import com.darkona.adventurebackpack.handlers.GuiHandler; import com.darkona.adventurebackpack.init.ModItems; import com.darkona.adventurebackpack.reference.BackpackNames; import com.darkona.adventurebackpack.reference.ModInfo; import com.darkona.adventurebackpack.util.LogHelper; import com.darkona.adventurebackpack.util.Utils; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import java.util.Random; /** * Created on 12/10/2014. * @author Javier Darkona */ public class BlockAdventureBackpack extends BlockContainer { public BlockAdventureBackpack() { super(new BackpackMaterial()); setHardness(1.0f); setStepSound(soundTypeCloth); setResistance(2000f); } /** * Pretty effects for the bookshelf ;) * * @param world * @param x * @param y * @param z * @param random */ @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random random) { if (getAssociatedTileColorName(world, x, y, z).equals("Bookshelf")) { ChunkCoordinates enchTable = Utils.findBlock3D(world, x, y, z, Blocks.enchanting_table, 2, 2); if(enchTable !=null) { if (!world.isAirBlock((enchTable.posX - x) / 2 + x, enchTable.posY, (enchTable.posZ - z) / 2 + z)) { return; } for (int o = 0; o < 4; o++) { world.spawnParticle("enchantmenttable",enchTable.posX + 0.5D,enchTable.posY + 2.0D,enchTable.posZ + 0.5D, ((x - enchTable.posX) + random.nextFloat()) - 0.5D, ((y - enchTable.posY) - random.nextFloat() - 1.0F), ((z - enchTable.posZ) + random.nextFloat()) - 0.5D); } } } } public int getMobilityFlag() { return 0; } @Override public String getHarvestTool(int metadata) { return null; } @Override public int getHarvestLevel(int metadata) { return 0; } @Override public boolean isToolEffective(String type, int metadata) { return true; } private String getAssociatedTileColorName(IBlockAccess world, int x, int y, int z) { return ((TileAdventureBackpack) world.getTileEntity(x, y, z)).getColorName(); } @Override public boolean canRenderInPass(int pass) { return true; } @Override public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { return false; } @Override public float getEnchantPowerBonus(World world, int x, int y, int z) { return getAssociatedTileColorName(world, x, y, z).equals("Bookshelf") ? 10 : 0; } @Override public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { return false; } @Override public boolean isWood(IBlockAccess world, int x, int y, int z) { return false; } @Override public boolean isLeaves(IBlockAccess world, int x, int y, int z) { return false; } @Override public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { return false; } @Override public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return 0; } @Override public boolean canHarvestBlock(EntityPlayer player, int meta) { return true; } @Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (getAssociatedTileColorName(world, x, y, z).equals("Cactus")) { entity.attackEntityFrom(DamageSource.cactus, 1.0F); } } /** * Called when a player hits the block. Args: world, x, y, z, player * * @param p_149699_1_ * @param p_149699_2_ * @param p_149699_3_ * @param p_149699_4_ * @param p_149699_5_ */ @Override public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) { super.onBlockClicked(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_, p_149699_5_); } /** * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata * * @param world * @param x * @param y * @param z * @param side * @param hitX * @param hitY * @param hitZ * @param meta */ @Override public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) { return super.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, meta); } @Override public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return false; } @Override public String getUnlocalizedName() { return "blockAdventureBackpack"; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { Icons.milkStill = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.milk"); Icons.melonJuiceStill = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.melonJuiceStill"); Icons.melonJuiceFlowing = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.melonJuiceFlowing"); Icons.mushRoomStewStill = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.mushroomStewStill"); Icons.mushRoomStewFlowing = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.mushroomStewFlowing"); } @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { if (getAssociatedTileColorName(world, x, y, z).equals("Glowstone")) { return 15; } else if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack) { return ((TileAdventureBackpack) world.getTileEntity(x, y, z)).getLuminosity(); } else { return 0; } } public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) { return getAssociatedTileColorName(world, x, y, z).equals("Redstone") ? 15 : 0; } @Override public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { return getAssociatedTileColorName(world, x, y, z).equals("Redstone"); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { FMLNetworkHandler.openGui(player, AdventureBackpack.instance, GuiHandler.BACKPACK_TILE, world, x, y, z); return true; } @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { ItemStack backpack = new ItemStack(ModItems.adventureBackpack, 1); BackpackNames.setBackpackColorNameFromDamage(backpack, BackpackNames.getBackpackDamageFromName(getAssociatedTileColorName(world, x, y, z))); return backpack; } @Override public boolean hasTileEntity(int meta) { return true; } @Override public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) { int meta = blockAccess.getBlockMetadata(x, y, z); meta = (meta & 8) >= 8 ? meta - 8 : meta; meta = (meta & 4) >= 4 ? meta - 4 : meta; switch (meta) { case 0: case 2: setBlockBounds(0.0F, 0.0F, 0.4F, 1.0F, 0.6F, 0.6F); break; case 1: case 3: setBlockBounds(0.4F, 0.0F, 0.0F, 0.6F, 0.6F, 1.0F); break; } } @Override public int getRenderType() { return -1; } @Override public boolean isOpaqueCube() { return false; } @Override public boolean renderAsNormalBlock() { return false; } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { int dir = MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3; if (stack != null && stack.stackTagCompound != null && stack.stackTagCompound.hasKey("color")) { if (stack.stackTagCompound.getString("color").contains("BlockRedstone")) { dir = dir | 8; } if (stack.stackTagCompound.getString("color").contains("Lightgem")) { dir = dir | 4; } } world.setBlockMetadataWithNotify(x, y, z, dir, 3); createNewTileEntity(world, world.getBlockMetadata(x, y, z)); } @Override public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int side) { return (ForgeDirection.getOrientation(side) == ForgeDirection.UP); } @Override public int quantityDropped(int meta, int fortune, Random random) { return 0; } @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { setBlockBoundsBasedOnState(world, x, y, z); return super.getSelectedBoundingBoxFromPool(world, x, y, z); } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { return Blocks.wool.getIcon(par1,par2); } @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { setBlockBoundsBasedOnState(world, x, y, z); return super.getCollisionBoundingBoxFromPool(world, x, y, z); } @Override public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 start, Vec3 end) { setBlockBoundsBasedOnState(world, x, y, z); return super.collisionRayTrace(world, x, y, z, start, end); } @Override public boolean canReplace(World p_149705_1_, int p_149705_2_, int p_149705_3_, int p_149705_4_, int p_149705_5_, ItemStack p_149705_6_) { return false; } @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean harvest) { TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileAdventureBackpack && !world.isRemote && player != null) { if ((player.isSneaking()) ? ((TileAdventureBackpack) tile).equip(world, player, x, y, z) : ((TileAdventureBackpack) tile).drop(world, player, x, y, z)) { return world.func_147480_a(x, y, z, false); } } else { return world.func_147480_a(x, y, z, false); } return false; } @Override public void breakBlock(World world, int x, int y, int z, Block block, int meta) { TileEntity te = world.getTileEntity(x, y, z); if (te != null && te instanceof IInventory) { IInventory inventory = (IInventory) te; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlotOnClosing(i); if (stack != null) { float spawnX = x + world.rand.nextFloat(); float spawnY = y + world.rand.nextFloat(); float spawnZ = z + world.rand.nextFloat(); float mult = 0.05F; EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, stack); droppedItem.motionX = -0.5F + world.rand.nextFloat() * mult; droppedItem.motionY = 4 + world.rand.nextFloat() * mult; droppedItem.motionZ = -0.5 + world.rand.nextFloat() * mult; world.spawnEntityInWorld(droppedItem); } } } super.breakBlock(world, x, y, z, world.getBlock(x, y, z), meta); } @Override public TileEntity createTileEntity(World world, int metadata) { return new TileAdventureBackpack(); } @Override public TileEntity createNewTileEntity(World world, int metadata) { return createTileEntity(world, metadata); } @Override public boolean canDropFromExplosion(Explosion p_149659_1_) { return false; } @Override public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) { world.func_147480_a(x, y, z, false); } @Override public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { //DO NOTHING } } Can anyone help me converting this?
  5. package com.darkona.adventurebackpack.handlers; import com.darkona.adventurebackpack.block.TileAdventureBackpack; import com.darkona.adventurebackpack.client.gui.GuiAdvBackpack; import com.darkona.adventurebackpack.client.gui.GuiCopterPack; import com.darkona.adventurebackpack.client.gui.GuiSteamJetpack; import com.darkona.adventurebackpack.inventory.*; import com.darkona.adventurebackpack.util.Wearing; import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; /** * Created on 12/10/2014 * * @author Darkona */ public class GuiHandler implements IGuiHandler { public static final byte JETPACK_WEARING = 6; public static final byte JETPACK_HOLDING = 5; public static final byte COPTER_WEARING = 4; public static final byte COPTER_HOLDING = 3; public static final byte BACKPACK_HOLDING = 2; public static final byte BACKPACK_WEARING = 1; public static final byte BACKPACK_TILE = 0; public GuiHandler() { } public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case BACKPACK_TILE: if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack) { return new ContainerBackpack(player, (TileAdventureBackpack) world.getTileEntity(x, y, z), ContainerBackpack.SOURCE_TILE); } break; case BACKPACK_WEARING: if (Wearing.isWearingBackpack(player)) { return new ContainerBackpack(player, new InventoryBackpack(Wearing.getWearingBackpack(player)), ContainerBackpack.SOURCE_WEARING); } break; case BACKPACK_HOLDING: if (Wearing.isHoldingBackpack(player)) { return new ContainerBackpack(player, new InventoryBackpack(Wearing.getHoldingBackpack(player)), ContainerBackpack.SOURCE_HOLDING); } break; case COPTER_HOLDING: if (Wearing.isHoldingCopter(player)) { return new ContainerCopter(player, new InventoryCopterPack(Wearing.getHoldingCopter(player)),false); } break; case COPTER_WEARING: if (Wearing.isWearingCopter(player)) { return new ContainerCopter(player, new InventoryCopterPack(Wearing.getWearingCopter(player)), true); } break; case JETPACK_HOLDING: if (Wearing.isHoldingSteam(player)) { return new ContainerJetpack(player, new InventorySteamJetpack(Wearing.getHoldingSteam(player)),false); } break; case JETPACK_WEARING: if (Wearing.isWearingSteam(player)) { return new ContainerJetpack(player, new InventorySteamJetpack(Wearing.getWearingSteam(player)), true); } break; default: player.closeScreen(); break; } return null; } public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case BACKPACK_TILE: if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack) { return new GuiAdvBackpack(player, (TileAdventureBackpack) world.getTileEntity(x, y, z)); } break; case BACKPACK_WEARING: if (Wearing.isWearingBackpack(player)) { return new GuiAdvBackpack(player, new InventoryBackpack(Wearing.getWearingBackpack(player)), true); } break; case BACKPACK_HOLDING: if (Wearing.isHoldingBackpack(player)) { return new GuiAdvBackpack(player, new InventoryBackpack(Wearing.getHoldingBackpack(player)), false); } break; case COPTER_HOLDING: if (Wearing.isHoldingCopter(player)) { return new GuiCopterPack(player, new InventoryCopterPack(Wearing.getHoldingCopter(player)),false); } break; case COPTER_WEARING: if (Wearing.isWearingCopter(player)) { return new GuiCopterPack(player, new InventoryCopterPack(Wearing.getWearingCopter(player)), true); } break; case JETPACK_HOLDING: if (Wearing.isHoldingSteam(player)) { return new GuiSteamJetpack(player, new InventorySteamJetpack(Wearing.getHoldingSteam(player)),false); } break; case JETPACK_WEARING: if (Wearing.isWearingSteam(player)) { return new GuiSteamJetpack(player, new InventorySteamJetpack(Wearing.getWearingSteam(player)), true); } break; default: player.closeScreen(); break; } return null; } }
  6. package com.darkona.adventurebackpack; import com.darkona.adventurebackpack.config.ConfigHandler; import com.darkona.adventurebackpack.fluids.FluidEffectRegistry; import com.darkona.adventurebackpack.handlers.ClientEventHandler; import com.darkona.adventurebackpack.handlers.GeneralEventHandler; import com.darkona.adventurebackpack.handlers.GuiHandler; import com.darkona.adventurebackpack.handlers.PlayerEventHandler; import com.darkona.adventurebackpack.init.*; import com.darkona.adventurebackpack.proxy.IProxy; import com.darkona.adventurebackpack.reference.ModInfo; import com.darkona.adventurebackpack.util.LogHelper; import com.darkona.adventurebackpack.util.Utils; import com.darkona.adventurebackpack.util.calendar.ChineseCalendar; import com.darkona.adventurebackpack.util.calendar.JewishCalendar; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import java.util.Calendar; /** * Created on 10/10/2014 * * @author Javier Darkona */ @Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, guiFactory = ModInfo.GUI_FACTORY_CLASS ) public class AdventureBackpack { @SidedProxy(clientSide = ModInfo.MOD_CLIENT_PROXY, serverSide = ModInfo.MOD_SERVER_PROXY) public static IProxy proxy; @Mod.Instance(ModInfo.MOD_ID) public static AdventureBackpack instance; //Static things public static CreativeTabAB creativeTab = new CreativeTabAB(); public boolean chineseNewYear; public boolean hannukah; public String Holiday; PlayerEventHandler playerEventHandler; ClientEventHandler clientEventHandler; GeneralEventHandler generalEventHandler; GuiHandler guiHandler; @Mod.EventHandler public void preInit(net.minecraftforge.fml.common.event.FMLPreInitializationEvent event) { int year = Calendar.getInstance().get(Calendar.YEAR), month = Calendar.getInstance().get(Calendar.MONTH) + 1, day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH); //Configuration net.minecraftforge.fml.common.FMLCommonHandler.instance().bus().register(new ConfigHandler()); ConfigHandler.init(event.getSuggestedConfigurationFile()); chineseNewYear = ChineseCalendar.isChineseNewYear(year, month, day); hannukah = JewishCalendar.isHannukah(year, month, day); Holiday = Utils.getHoliday(); //ModStuff ModItems.init(); ModBlocks.init(); ModFluids.init(); FluidEffectRegistry.init(); ModEntities.init(); ModNetwork.init(); proxy.initNetwork(); // EVENTS playerEventHandler = new PlayerEventHandler(); generalEventHandler = new GeneralEventHandler(); clientEventHandler = new ClientEventHandler(); MinecraftForge.EVENT_BUS.register(generalEventHandler); MinecraftForge.EVENT_BUS.register(clientEventHandler); MinecraftForge.EVENT_BUS.register(playerEventHandler); net.minecraftforge.fml.common.FMLCommonHandler.instance().bus().register(playerEventHandler); } @Mod.EventHandler public void init(net.minecraftforge.fml.common.event.FMLInitializationEvent event) { proxy.init(); ModRecipes.init(); ModWorldGen.init(); //GUIs guiHandler = new GuiHandler(); net.minecraftforge.fml.common.network.NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler); } @Mod.EventHandler public void postInit(net.minecraftforge.fml.common.event.FMLPostInitializationEvent event) { ConfigHandler.IS_TINKERS = Loader.isModLoaded("TConstruct"); ConfigHandler.IS_THAUM = Loader.isModLoaded("Thaumcraft"); ConfigHandler.IS_TWILIGHT = Loader.isModLoaded("TwilightForest"); ConfigHandler.IS_ENVIROMINE = Loader.isModLoaded("EnviroMine"); ConfigHandler.IS_BUILDCRAFT = Loader.isModLoaded("BuildCraft|Core"); ConfigHandler.IS_RAILCRAFT = Loader.isModLoaded("Railcraft"); if (ConfigHandler.IS_BUILDCRAFT) { LogHelper.info("Buildcraft is present. Acting accordingly"); } if (ConfigHandler.IS_TWILIGHT) { LogHelper.info("Twilight Forest is present. Acting accordingly"); } ConditionalFluidEffect.init(); ModItems.conditionalInit(); ModRecipes.conditionalInit(); /* LogHelper.info("DUMPING FLUID INFORMATION"); LogHelper.info("-------------------------------------------------------------------------"); for(Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { LogHelper.info("Unlocalized name: " + fluid.getUnlocalizedName()); LogHelper.info("Name: " + fluid.getName()); LogHelper.info(""); } LogHelper.info("-------------------------------------------------------------------------"); */ /* LogHelper.info("DUMPING TILE INFORMATION"); LogHelper.info("-------------------------------------------------------------------------"); for (Block block : GameData.getBlockRegistry().typeSafeIterable()) { LogHelper.info("Block= " + block.getUnlocalizedName()); } LogHelper.info("-------------------------------------------------------------------------"); */ } }
  7. That says: "The method registerGuiHandler(Object, IGuiHandler) in the type NetworkRegistry is not applicable for the arguments (AdventureBackpack, GuiHandler)"
  8. public void init(net.minecraftforge.fml.common.event.FMLInitializationEvent event) { proxy.init(); ModRecipes.init(); ModWorldGen.init(); //GUIs guiHandler = new GuiHandler(); net.minecraftforge.fml.common.network.NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler); } I have error in net.minecraftforge.fml.common.network.NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler);.
  9. public int brightness(int side) { if((sampled & 1 << side) == 0) { BlockPos bp = pos.pos(); IBlockState b = access.getBlockState(bp); brightness[side] = access.getCombinedLight(bp, b.getBlock().getLightValue(b, access, bp)); sampled |= 1 << side; } On BlockPos bp = pos.pos(); I'm getting a error. This code os from codechickenlib 1.8 and I need it to convert and I don't know how to do it. Can anyone help me?
  10. And I don't understand this. Can anyone send me the piece of code withthe blackpos? Because I am new to this
  11. The title says all. I tried to convert a mod from 1.7.10 to 1.10.2 and I'm stuck with this error: "The method getBlock(int, int, int) is undefined for the type IBlockAccess" And I have another problem with the getLightValue: "The method getLightValue(IBlockState, IBlockAccess, BlockPos) in the type Block is not applicable for the arguments (IBlockAccess, int, int, int)" package codechicken.lib.lighting; import codechicken.lib.colour.ColourRGBA; import codechicken.lib.render.CCRenderState; import codechicken.lib.vec.BlockCoord; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; /** * Note that when using the class as a vertex transformer, the vertices are assumed to be within the BB (x, y, z) -> (x+1, y+1, z+1) */ public class LightMatrix implements CCRenderState.IVertexOperation { public static final int operationIndex = CCRenderState.registerOperation(); /** * The 9 positions in the sample array for each side, sides >= 6 are centered on sample 13 (the block itself) */ public static final int[][] ssamplem = new int[][]{ {0, 1, 2, 3, 4, 5, 6, 7, 8}, {18, 19, 20, 21, 22, 23, 24, 25, 26}, {0, 9, 18, 1, 10, 19, 2, 11, 20}, {6, 15, 24, 7, 16, 25, 8, 17, 26}, {0, 3, 6, 9, 12, 15, 18, 21, 24}, {2, 5, 8, 11, 14, 17, 20, 23, 26}, {9, 10, 11, 12, 13, 14, 15, 16, 17}, {9, 10, 11, 12, 13, 14, 15, 16, 17}, {3, 12, 21, 4, 13, 22, 5, 14, 23}, {3, 12, 21, 4, 13, 22, 5, 14, 23}, {1, 4, 7, 10, 13, 16, 19, 22, 25}, {1, 4, 7, 10, 13, 16, 19, 22, 25}, {13, 13, 13, 13, 13, 13, 13, 13, 13}}; public static final int[][] qsamplem = new int[][]{//the positions in the side sample array for each corner {0, 1, 3, 4}, {5, 1, 2, 4}, {6, 7, 3, 4}, {5, 7, 8, 4}}; public static final float[] sideao = new float[]{ 0.5F, 1F, 0.8F, 0.8F, 0.6F, 0.6F, 0.5F, 1F, 0.8F, 0.8F, 0.6F, 0.6F, 1F}; public int computed = 0; public float[][] ao = new float[13][4]; public int[][] brightness = new int[13][4]; public IBlockAccess access; public BlockCoord pos = new BlockCoord(); private int sampled = 0; private float[] aSamples = new float[27]; private int[] bSamples = new int[27]; /*static { int[][] os = new int[][]{ {0,-1,0}, {0, 1,0}, {0,0,-1}, {0,0, 1}, {-1,0,0}, { 1,0,0}}; for(int s = 0; s < 12; s++) { int[] d0 = s < 6 ? new int[]{os[s][0]+1, os[s][1]+1, os[s][2]+1} : new int[]{1, 1, 1}; int[] d1 = os[((s&0xE)+3)%6]; int[] d2 = os[((s&0xE)+5)%6]; for(int a = -1; a <= 1; a++) for(int b = -1; b <= 1; b++) ssamplem[s][(a+1)*3+b+1] = (d0[1]+d1[1]*a+d2[1]*b)*9+(d0[2]+d1[2]*a+d2[2]*b)*3+(d0[0]+d1[0]*a+d2[0]*b); } System.out.println(Arrays.deepToString(ssamplem)); }*/ public static float interpAO(float a, float b, float c, float d) { return (a + b + c + d) / 4F; } public static int interpBrightness(int a, int b, int c, int d) { if (a == 0) { a = d; } if (b == 0) { b = d; } if (c == 0) { c = d; } return (a + b + c + d) >> 2 & 0xFF00FF; } public void locate(IBlockAccess a, int x, int y, int z) { access = a; pos.set(x, y, z); computed = 0; sampled = 0; } public void sample(int i) { if ((sampled & 1 << i) == 0) { int x = pos.x + (i % 3) - 1; int y = pos.y + (i / 9) - 1; int z = pos.z + (i / 3 % 3) - 1; Block b = access.getBlock(x, y, z); bSamples[i] = access.getLightBrightnessForSkyBlocks(x, y, z, b.getLightValue(access, x, y, z)); aSamples[i] = b.getAmbientOcclusionLightValue(null); sampled |= 1 << i; } } public int[] brightness(int side) { sideSample(side); return brightness[side]; } public float[] ao(int side) { sideSample(side); return ao[side]; } public void sideSample(int side) { if ((computed & 1 << side) == 0) { int[] ssample = ssamplem[side]; for (int q = 0; q < 4; q++) { int[] qsample = qsamplem[q]; if (Minecraft.isAmbientOcclusionEnabled()) { interp(side, q, ssample[qsample[0]], ssample[qsample[1]], ssample[qsample[2]], ssample[qsample[3]]); } else { interp(side, q, ssample[4], ssample[4], ssample[4], ssample[4]); } } computed |= 1 << side; } } private void interp(int s, int q, int a, int b, int c, int d) { sample(a); sample(b); sample(c); sample(d); ao[s][q] = interpAO(aSamples[a], aSamples[b], aSamples[c], aSamples[d]) * sideao[s]; brightness[s][q] = interpBrightness(bSamples[a], bSamples[b], bSamples[c], bSamples[d]); } @Override public boolean load() { if (!CCRenderState.computeLighting) { return false; } CCRenderState.pipeline.addDependency(CCRenderState.colourAttrib); CCRenderState.pipeline.addDependency(CCRenderState.lightCoordAttrib); return true; } @Override public void operate() { LC lc = CCRenderState.lc; float[] a = ao(lc.side); float f = (a[0] * lc.fa + a[1] * lc.fb + a[2] * lc.fc + a[3] * lc.fd); int[] b = brightness(lc.side); CCRenderState.setColour(ColourRGBA.multiplyC(CCRenderState.colour, f)); CCRenderState.setBrightness((int) (b[0] * lc.fa + b[1] * lc.fb + b[2] * lc.fc + b[3] * lc.fd) & 0xFF00FF); } @Override public int operationID() { return operationIndex; } } Hope in advance!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.