Search in sources :

Example 6 with TileEntityBlackHoleStorage

use of stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage in project MorePlanets by SteveKunG.

the class BlockBlackHoleStorage method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack itemStack) {
    TileEntity tile = world.getTileEntity(pos);
    world.setBlockState(pos, this.getDefaultState());
    if (!world.isRemote) {
        if (placer instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) placer;
            EntityBlackHoleStorage blackHole = new EntityBlackHoleStorage(world);
            blackHole.setTileEntityPos(pos);
            blackHole.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() + 2, pos.getZ() + 0.5D, 0.0F, 0.0F);
            world.spawnEntity(blackHole);
            world.playSound(null, pos.getX() + 0.5D, pos.getY() + 2, pos.getZ() + 0.5D, MPSounds.BLACK_HOLE_CREATED, SoundCategory.BLOCKS, 1.0F, 1.0F);
            if (tile instanceof TileEntityBlackHoleStorage) {
                TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
                storage.ownerUUID = player.getGameProfile().getId().toString();
                if (itemStack.hasTagCompound()) {
                    storage.inventory = NonNullList.withSize(storage.getSizeInventory(), ItemStack.EMPTY);
                    storage.disableBlackHole = itemStack.getTagCompound().getBoolean("Disable");
                    storage.useHopper = itemStack.getTagCompound().getBoolean("Hopper");
                    storage.collectMode = itemStack.getTagCompound().getString("Mode");
                    ItemStackHelper.loadAllItems(itemStack.getTagCompound(), storage.inventory);
                    // TODO: Remove in 1.13
                    if (itemStack.getTagCompound().hasKey("XP")) {
                        NBTTagCompound fluidNbt = new NBTTagCompound();
                        fluidNbt.setString("FluidName", "xpjuice");
                        fluidNbt.setInteger("Amount", itemStack.getTagCompound().getInteger("XP"));
                        storage.fluidTank.readFromNBT(fluidNbt);
                    } else {
                        storage.fluidTank.readFromNBT(itemStack.getTagCompound().getCompoundTag("XpFluid"));
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage) EntityBlackHoleStorage(stevekung.mods.moreplanets.entity.EntityBlackHoleStorage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage)

Example 7 with TileEntityBlackHoleStorage

use of stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage in project MorePlanets by SteveKunG.

the class TileEntityItemStackRendererMP method renderByItem.

@Override
public void renderByItem(ItemStack itemStack) {
    Block block = Block.getBlockFromItem(itemStack.getItem());
    if (block == DionaBlocks.DIONA_ANCIENT_CHEST) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityDionaAncientChest());
    } else if (block == DionaBlocks.DIONA_TREASURE_CHEST) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityDionaTreasureChest());
    } else if (block == ChalosBlocks.CHALOS_ANCIENT_CHEST) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityChalosAncientChest());
    } else if (block == ChalosBlocks.CHALOS_TREASURE_CHEST) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityChalosTreasureChest());
    } else if (block == DionaBlocks.ZELIUS_EGG) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityZeliusEgg());
        GlStateManager.enableBlend();
    } else if (block == DionaBlocks.LARGE_INFECTED_CRYSTALLIZE) {
        TileEntityLargeInfectedCrystallizeRenderer.INSTANCE.render();
    } else if (block == MPBlocks.DARK_ENERGY_RECEIVER) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityDarkEnergyReceiver());
    } else if (itemStack.getItem() == DionaItems.INFECTED_CRYSTALLIZE_BOMB) {
        RenderInfectedCrystallizeBomb.INSTANCE.render();
    } else if (block == NibiruBlocks.NIBIRU_ANCIENT_CHEST) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityNibiruAncientChest());
    } else if (block == NibiruBlocks.NIBIRU_TREASURE_CHEST) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityNibiruTreasureChest());
    } else if (block == ChalosBlocks.CHEESE_SPORE_CHEST) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityCheeseSporeChest());
    } else if (block == NibiruBlocks.INFECTED_CHEST) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityInfectedChest());
    } else if (block == NibiruBlocks.MULTALIC_CRYSTAL) {
        TileEntityMultalicCrystalRenderer.INSTANCE.render();
    } else if (block == DionaBlocks.DARK_ENERGY_CORE) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityDarkEnergyCore());
        GlStateManager.enableBlend();
    } else if (block == NibiruBlocks.ALIEN_BERRY_CHEST) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityAlienBerryChest());
    } else if (block == NibiruBlocks.JUICER_EGG) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityJuicerEgg());
        TileEntityJuicerEggRenderer.renderItem(null, true);
    } else if (block == NibiruBlocks.NUCLEAR_WASTE_TANK) {
        TileEntityNuclearWasteTankRenderer.INSTANCE.render();
    } else if (block == NibiruBlocks.VEIN_FRAME) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityVeinFrame());
        GlStateManager.enableBlend();
    } else if (block == DionaBlocks.DARK_ENERGY_GENERATOR) {
        TileEntityDarkEnergyGeneratorRenderer.INSTANCE.render();
    } else if (block == MPBlocks.BLACK_HOLE_STORAGE) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityBlackHoleStorage());
        GlStateManager.enableBlend();
    } else if (block == MPBlocks.ALIEN_DEFENDER_BEACON) {
        ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityAlienDefenderBeacon());
        GlStateManager.enableBlend();
        GlStateManager.enableCull();
    } else if (block == MPBlocks.SHIELD_GENERATOR) {
        TileEntityShieldGeneratorRenderer.INSTANCE.render();
    } else {
        this.old.renderByItem(itemStack);
    }
}
Also used : TileEntityCheeseSporeChest(stevekung.mods.moreplanets.module.planets.chalos.tileentity.TileEntityCheeseSporeChest) TileEntityChalosTreasureChest(stevekung.mods.moreplanets.module.planets.chalos.tileentity.TileEntityChalosTreasureChest) TileEntityDionaTreasureChest(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDionaTreasureChest) TileEntityDarkEnergyReceiver(stevekung.mods.moreplanets.tileentity.TileEntityDarkEnergyReceiver) TileEntityDionaAncientChest(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDionaAncientChest) TileEntityDarkEnergyCore(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyCore) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage) TileEntityChalosAncientChest(stevekung.mods.moreplanets.module.planets.chalos.tileentity.TileEntityChalosAncientChest) Block(net.minecraft.block.Block) TileEntityAlienDefenderBeacon(stevekung.mods.moreplanets.tileentity.TileEntityAlienDefenderBeacon) TileEntityZeliusEgg(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityZeliusEgg)

Example 8 with TileEntityBlackHoleStorage

use of stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage in project MorePlanets by SteveKunG.

the class EntityBlackHoleStorage method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.move(MoverType.SELF, 0.0D, 0.0D, 0.0D);
    if (this.mainTilePos != null) {
        TileEntity tile = this.world.getTileEntity(this.mainTilePos);
        if (tile == null || !(tile instanceof TileEntityBlackHoleStorage)) {
            this.setDead();
        }
    }
    if (!this.isDisable()) {
        boolean collectAll = this.getCollectMode().equals("item_and_xp");
        if (this.getCollectMode().equals("item") || collectAll) {
            int range = 12;
            List<EntityItem> entitiesAroundBH = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.posX - range, this.posY - range, this.posZ - range, this.posX + range, this.posY + range, this.posZ + range));
            for (EntityItem entity : entitiesAroundBH) {
                double motionX = this.posX - entity.posX;
                double motionY = this.posY - entity.posY + 0.5D;
                double motionZ = this.posZ - entity.posZ;
                entity.motionX = motionX * 0.1F;
                entity.motionY = motionY * 0.1F;
                entity.motionZ = motionZ * 0.1F;
            }
        }
        if (this.getCollectMode().equals("xp") || collectAll) {
            int range = 12;
            List<EntityXPOrb> entitiesAroundBH = this.world.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(this.posX - range, this.posY - range, this.posZ - range, this.posX + range, this.posY + range, this.posZ + range));
            for (EntityXPOrb entity : entitiesAroundBH) {
                double motionX = this.posX - entity.posX;
                double motionY = this.posY - entity.posY + 0.5D;
                double motionZ = this.posZ - entity.posZ;
                entity.motionX = motionX * 0.1F;
                entity.motionY = motionY * 0.1F;
                entity.motionZ = motionZ * 0.1F;
                entity.delayBeforeCanPickup = 5;
            }
        }
        if (this.world.isRemote) {
            for (int i = 0; i < 16; ++i) {
                double d0 = this.posX + this.rand.nextFloat();
                double d1 = this.posY + this.rand.nextFloat();
                double d2 = this.posZ + this.rand.nextFloat();
                double d3 = (this.rand.nextFloat() - 0.5D) * 0.5D;
                double d4 = (this.rand.nextFloat() - 0.5D) * 0.5D;
                double d5 = (this.rand.nextFloat() - 0.5D) * 0.5D;
                int j = this.rand.nextInt(2) * 2 - 1;
                d0 = this.posX + 0.25D * j;
                d3 = this.rand.nextFloat() * 2.0F * j;
                d2 = this.posZ + 0.25D * j;
                d5 = this.rand.nextFloat() * 2.0F * j;
                MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, d0, d1, d2, d3, d4, d5);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityItem(net.minecraft.entity.item.EntityItem) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Aggregations

TileEntityBlackHoleStorage (stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage)8 TileEntity (net.minecraft.tileentity.TileEntity)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 Random (java.util.Random)1 Block (net.minecraft.block.Block)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityXPOrb (net.minecraft.entity.item.EntityXPOrb)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ItemStack (net.minecraft.item.ItemStack)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 WorldServer (net.minecraft.world.WorldServer)1 FluidActionResult (net.minecraftforge.fluids.FluidActionResult)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 EntityBlackHoleStorage (stevekung.mods.moreplanets.entity.EntityBlackHoleStorage)1 TileEntityChalosAncientChest (stevekung.mods.moreplanets.module.planets.chalos.tileentity.TileEntityChalosAncientChest)1 TileEntityChalosTreasureChest (stevekung.mods.moreplanets.module.planets.chalos.tileentity.TileEntityChalosTreasureChest)1 TileEntityCheeseSporeChest (stevekung.mods.moreplanets.module.planets.chalos.tileentity.TileEntityCheeseSporeChest)1