Search in sources :

Example 1 with TileEntityBlackHoleStorage

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

the class BlockBlackHoleStorage method randomDisplayTick.

@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityBlackHoleStorage) {
        TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
        if (!storage.disableBlackHole) {
            for (int i = 0; i < 16; i++) {
                double x = pos.getX() + rand.nextFloat() - 0.5D;
                double y = pos.getY() + 0.5D;
                double z = pos.getZ() + rand.nextFloat();
                double motionX = rand.nextDouble() - 0.5D;
                double motionZ = rand.nextDouble() - 0.5D;
                MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, x + 0.5D, y, z, motionX, 1.0D, 0.0D);
                MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, x + 0.5D, y, z + 0.0D, 0.0D, 1.0D, motionZ);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with TileEntityBlackHoleStorage

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

the class BlockBlackHoleStorage method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return true;
    } else {
        TileEntity tile = world.getTileEntity(pos);
        int slot = player.inventory.currentItem;
        if (tile instanceof TileEntityBlackHoleStorage) {
            TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
            FluidActionResult result = FluidUtil.interactWithFluidHandler(player.inventory.getCurrentItem(), storage.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null), player);
            if (result.isSuccess()) {
                player.inventory.setInventorySlotContents(slot, result.result);
                if (player.inventoryContainer != null) {
                    player.inventoryContainer.detectAndSendChanges();
                }
                return true;
            } else {
                if (player.getGameProfile().getId().toString().equals(storage.ownerUUID)) {
                    if (player.isSneaking() && storage.fluidTank.getFluidAmount() > 0) {
                        Random rand = world.rand;
                        storage.drainExp(player);
                        world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.1F, 0.5F * ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.8F));
                    } else {
                        player.openGui(MorePlanetsCore.MOD_ID, -1, world, pos.getX(), pos.getY(), pos.getZ());
                    }
                } else {
                    JsonUtil json = new JsonUtil();
                    player.sendMessage(json.text(GCCoreUtil.translate("gui.bh_storage_not_owner.message")).setStyle(json.red()));
                }
            }
        }
        return true;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Random(java.util.Random) FluidActionResult(net.minecraftforge.fluids.FluidActionResult) JsonUtil(stevekung.mods.moreplanets.util.JsonUtil) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage)

Example 3 with TileEntityBlackHoleStorage

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

the class PacketSimpleMP method handleServerSide.

@Override
public void handleServerSide(EntityPlayer player) {
    EntityPlayerMP playerMP = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    World world = player.world;
    TileEntity tile;
    BlockPos pos;
    String type;
    switch(this.type) {
        case S_FIRE_EXTINGUISH:
            pos = (BlockPos) this.data.get(0);
            world.playSound(null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
            world.setBlockToAir(pos);
            break;
        case S_RESPAWN_PLAYER_NETHER:
            if (world instanceof WorldServer) {
                WorldServer worldOld = (WorldServer) world;
                WorldServer worldNew = WorldDimensionHelper.getStartWorld(worldOld);
                BlockPos spawnPos = worldNew.getTopSolidOrLiquidBlock(worldNew.getSpawnPoint());
                TeleportUtil.setWarpDimension(playerMP, worldNew, spawnPos.getX(), spawnPos.getY(), spawnPos.getZ(), WorldUtil.getProviderForNameServer(WorldTickEventHandler.startedDimensionData.planetToBack).getDimension(), true);
                player.respawnPlayer();
                player.closeScreen();
            }
            break;
        case S_BLACK_HOLE_STORAGE_OPTION:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            type = (String) this.data.get(1);
            if (tile instanceof TileEntityBlackHoleStorage) {
                TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
                switch(type) {
                    case "disable":
                        storage.disableBlackHole = !storage.disableBlackHole;
                        break;
                    case "collect_mode":
                        storage.modeInt++;
                        storage.modeInt %= 3;
                        switch(storage.modeInt) {
                            case 0:
                                storage.collectMode = "item";
                                break;
                            case 1:
                                storage.collectMode = "xp";
                                break;
                            case 2:
                                storage.collectMode = "item_and_xp";
                                break;
                        }
                        break;
                    case "use_hopper":
                        storage.useHopper = !storage.useHopper;
                        break;
                }
            }
            break;
        case S_SHIELD_VISIBLE:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                shield.setBubbleVisible((boolean) this.data.get(1));
            }
            break;
        case S_ENABLE_SHIELD:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                shield.enableShield = !shield.enableShield;
            }
            break;
        case S_ENABLE_SHIELD_DAMAGE:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                shield.enableDamage = !shield.enableDamage;
            }
            break;
        case S_SHIELD_GENERATOR_OPTION:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            int value = (int) this.data.get(1);
            type = (String) this.data.get(2);
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                switch(type) {
                    case "damage":
                        shield.shieldDamage = value;
                        break;
                    case "size":
                        shield.maxShieldSize = value;
                        break;
                }
            }
            break;
        case S_SWITCH_SHIELD_GENERATOR_GUI:
            tile = player.world.getTileEntity((BlockPos) this.data.get(0));
            boolean isConfig = (boolean) this.data.get(1);
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                PacketSimpleMP.openShieldGeneratorConfig(playerMP, shield, isConfig);
            }
            break;
        default:
            break;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityShieldGenerator(stevekung.mods.moreplanets.tileentity.TileEntityShieldGenerator) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos) WorldServer(net.minecraft.world.WorldServer) World(net.minecraft.world.World) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage)

Example 4 with TileEntityBlackHoleStorage

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

the class RenderBlackHoleStorage method renderItem.

@Override
public void renderItem(ItemStack itemStack, ItemCameraTransforms.TransformType type) {
    ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityBlackHoleStorage());
    GlStateManager.enableBlend();
}
Also used : TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage)

Example 5 with TileEntityBlackHoleStorage

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

the class BlockBlackHoleStorage method harvestBlock.

@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack heldStack) {
    player.addExhaustion(0.025F);
    if (tile instanceof TileEntityBlackHoleStorage) {
        ItemStack itemStack = new ItemStack(this);
        NBTTagCompound nbt = new NBTTagCompound();
        TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
        ItemStackHelper.saveAllItems(nbt, storage.inventory);
        nbt.setBoolean("Disable", storage.disableBlackHole);
        nbt.setBoolean("Hopper", storage.useHopper);
        nbt.setString("Mode", storage.collectMode);
        if (storage.fluidTank.getFluid() != null) {
            NBTTagCompound fluidNbt = new NBTTagCompound();
            fluidNbt.setString("FluidName", "xpjuice");
            fluidNbt.setInteger("Amount", storage.fluidTank.getFluidAmount());
            nbt.setTag("XpFluid", fluidNbt);
        }
        itemStack.setTagCompound(nbt);
        Block.spawnAsEntity(world, pos, itemStack);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage)

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