Search in sources :

Example 1 with TileEntityDarkEnergyReceiver

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

the class BlockDarkEnergyReceiver method harvestBlock.

@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack itemStack) {
    ItemStack machine = new ItemStack(this);
    player.addExhaustion(0.025F);
    if (tile instanceof TileEntityDarkEnergyReceiver) {
        TileEntityDarkEnergyReceiver electric = (TileEntityDarkEnergyReceiver) tile;
        if (electric.getEnergyStoredGC() > 0) {
            machine.setTagCompound(new NBTTagCompound());
            machine.getTagCompound().setFloat("EnergyStored", electric.getEnergyStoredGC());
        }
        if (!electric.successful && !electric.failed) {
            Block.spawnAsEntity(world, pos, machine);
        }
    }
}
Also used : TileEntityDarkEnergyReceiver(stevekung.mods.moreplanets.tileentity.TileEntityDarkEnergyReceiver) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 2 with TileEntityDarkEnergyReceiver

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

the class BlockDarkEnergyReceiver 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 TileEntityDarkEnergyReceiver) {
        TileEntityDarkEnergyReceiver dark = (TileEntityDarkEnergyReceiver) tile;
        if (dark.activated && !dark.successful) {
            for (int i = 0; i < 32; ++i) {
                double d0 = pos.getX() + rand.nextFloat();
                double d1 = pos.getY() + rand.nextFloat();
                double d2 = pos.getZ() + rand.nextFloat();
                double d3 = (rand.nextFloat() - 0.5D) * 0.5D;
                double d4 = (rand.nextFloat() - 0.5D) * 0.5D;
                double d5 = (rand.nextFloat() - 0.5D) * 0.5D;
                int j = rand.nextInt(2) * 2 - 1;
                d2 = pos.getZ() + 0.5D + 0.25D * j;
                d5 = rand.nextFloat() * 2.0F * j;
                MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, d0, d1, d2, d3, d4, d5);
            }
            for (int i = 0; i < 32; ++i) {
                double d0 = pos.getX() + rand.nextFloat();
                double d1 = pos.getY() + rand.nextFloat();
                double d2 = pos.getZ() + rand.nextFloat();
                double d3 = (rand.nextFloat() - 0.5D) * 0.5D;
                double d4 = (rand.nextFloat() - 0.5D) * 0.5D;
                double d5 = (rand.nextFloat() - 0.5D) * 0.5D;
                int j = rand.nextInt(2) * 2 - 1;
                d0 = pos.getX() + 0.5D + 0.25D * j;
                d3 = rand.nextFloat() * 2.0F * j;
                MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, d0, d1, d2, d3, d4, d5);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityDarkEnergyReceiver(stevekung.mods.moreplanets.tileentity.TileEntityDarkEnergyReceiver) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with TileEntityDarkEnergyReceiver

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

the class BlockDarkEnergyReceiver method breakBlock.

@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityDarkEnergyReceiver) {
        TileEntityDarkEnergyReceiver receiver = (TileEntityDarkEnergyReceiver) tile;
        receiver.onDestroy(tile);
        GalacticraftCore.packetPipeline.sendToDimension(new PacketSimpleMP(EnumSimplePacketMP.C_REMOVE_GUIDE_POS, world.provider.getDimension(), receiver.getPos()), world.provider.getDimension());
    }
    super.breakBlock(world, pos, state);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityDarkEnergyReceiver(stevekung.mods.moreplanets.tileentity.TileEntityDarkEnergyReceiver) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP)

Example 4 with TileEntityDarkEnergyReceiver

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

the class BlockDarkEnergyReceiver method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return true;
    } else {
        if (player.isSneaking()) {
            if (world.getTileEntity(pos) instanceof TileEntityDarkEnergyReceiver) {
                TileEntityDarkEnergyReceiver tile = (TileEntityDarkEnergyReceiver) world.getTileEntity(pos);
                if (TileEntityDarkEnergyReceiver.checkValidMultiblock(pos, world)) {
                    for (Map.Entry<BlockPos, IBlockState> list : TileEntityDarkEnergyReceiver.multiBlockLists.entrySet()) {
                        BlockPos blockpos = list.getKey();
                        IBlockState blockstate = list.getValue();
                        BlockPos newPos = pos.add(blockpos);
                        JsonUtil json = new JsonUtil();
                        if (world.getBlockState(newPos) != blockstate) {
                            Item item = Item.getItemFromBlock(blockstate.getBlock());
                            String name = item.getItemStackDisplayName(new ItemStack(item, 1, blockstate.getBlock().getMetaFromState(blockstate)));
                            player.sendMessage(json.text("Missing block " + name + " at " + newPos.getX() + " " + newPos.getY() + " " + newPos.getZ()).setStyle(json.red()));
                        }
                    }
                } else {
                    if (!tile.disabled) {
                        if (tile.getEnergyStoredGC() > 20000.0F) {
                            if (!tile.isActivated()) {
                                tile.setActivated(true);
                                tile.getWorld().playSound(player, tile.getPos(), MPSounds.MACHINE_START, SoundCategory.BLOCKS, 1.0F, 1.0F);
                                player.sendMessage(new JsonUtil().text(GCCoreUtil.translate("gui.dark_energy_success.message")).setStyle(new JsonUtil().colorFromConfig("green")));
                                return true;
                            } else {
                                player.sendMessage(new JsonUtil().text(GCCoreUtil.translate("gui.dark_energy_already_active.message")).setStyle(new JsonUtil().red()));
                                return false;
                            }
                        } else {
                            if (!tile.isActivated()) {
                                player.sendMessage(new JsonUtil().text(GCCoreUtil.translate("gui.dark_energy_no_power.message")).setStyle(new JsonUtil().red()));
                                return false;
                            }
                        }
                    } else {
                        player.sendMessage(new JsonUtil().text(GCCoreUtil.translate("gui.dark_energy_disabled.message")).setStyle(new JsonUtil().red()));
                        return false;
                    }
                }
            }
        } else {
            if (world.getTileEntity(pos) instanceof TileEntityDarkEnergyReceiver) {
                TileEntityDarkEnergyReceiver tile = (TileEntityDarkEnergyReceiver) world.getTileEntity(pos);
                if (tile.failedTick > 0 && !tile.successful) {
                    int failedTick = 600 - tile.failedTick;
                    String s = "s";
                    if (failedTick < 40) {
                        s = "";
                    }
                    player.sendMessage(new JsonUtil().text(GCCoreUtil.translateWithFormat("gui.dark_energy_malfunction.message", this.ticksToElapsedTime(failedTick)) + " second" + s + "!").setStyle(new JsonUtil().red()));
                    return false;
                } else {
                    if (!tile.failed) {
                        player.openGui(MorePlanetsCore.MOD_ID, -1, world, pos.getX(), pos.getY(), pos.getZ());
                    }
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) TileEntityDarkEnergyReceiver(stevekung.mods.moreplanets.tileentity.TileEntityDarkEnergyReceiver) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) JsonUtil(stevekung.mods.moreplanets.util.JsonUtil)

Example 5 with TileEntityDarkEnergyReceiver

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

the class BlockDarkEnergyReceiver method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack heldStack) {
    int angle = MathHelper.floor(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    int change = EnumFacing.getHorizontal(angle).getOpposite().getHorizontalIndex();
    int direction = 0;
    if (change == 0) {
        direction = 180;
    }
    if (change == 1) {
        direction = -90;
    }
    if (change == 2) {
        direction = 0;
    }
    if (change == 3) {
        direction = 90;
    }
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityDarkEnergyReceiver) {
        TileEntityDarkEnergyReceiver energy = (TileEntityDarkEnergyReceiver) world.getTileEntity(pos);
        energy.onCreate(world, pos);
        energy.setFacing(direction);
        if (heldStack.hasTagCompound() && heldStack.getTagCompound().hasKey("EnergyStored")) {
            energy.storage.setEnergyStored(heldStack.getTagCompound().getFloat("EnergyStored"));
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityDarkEnergyReceiver(stevekung.mods.moreplanets.tileentity.TileEntityDarkEnergyReceiver)

Aggregations

TileEntityDarkEnergyReceiver (stevekung.mods.moreplanets.tileentity.TileEntityDarkEnergyReceiver)7 TileEntity (net.minecraft.tileentity.TileEntity)4 ItemStack (net.minecraft.item.ItemStack)3 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 Item (net.minecraft.item.Item)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 BlockPos (net.minecraft.util.math.BlockPos)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)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 TileEntityDarkEnergyCore (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyCore)1 TileEntityDionaAncientChest (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDionaAncientChest)1 TileEntityDionaTreasureChest (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDionaTreasureChest)1 TileEntityZeliusEgg (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityZeliusEgg)1 PacketSimpleMP (stevekung.mods.moreplanets.network.PacketSimpleMP)1 TileEntityAlienDefenderBeacon (stevekung.mods.moreplanets.tileentity.TileEntityAlienDefenderBeacon)1