Search in sources :

Example 86 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.

the class GeneralEventHandler method onBreakSpeed.

@SubscribeEvent
public void onBreakSpeed(BreakSpeed event) {
    Block block = event.getState().getBlock();
    EntityPlayer player = event.getEntityPlayer();
    if (this.isShears(player)) {
        if (block == FronosBlocks.CANDY_CANE_1 || block == FronosBlocks.CANDY_CANE_2) {
            event.setNewSpeed(7.5F);
        }
    }
}
Also used : Block(net.minecraft.block.Block) IFireBlock(stevekung.mods.moreplanets.util.blocks.IFireBlock) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 87 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.

the class GeneralEventHandler method onCraftItem.

@SubscribeEvent
public void onCraftItem(ItemCraftedEvent event) {
    Item item = event.crafting.getItem();
    Block block = Block.getBlockFromItem(item);
    if (block == ChalosBlocks.CHALOS_CRAFTING_TABLE || block == NibiruBlocks.NIBIRU_CRAFTING_TABLE) {
    // event.player.addStat(AchievementList.BUILD_WORK_BENCH);
    }
    if (item == NibiruItems.NIBIRU_STONE_PICKAXE) {
    // event.player.addStat(AchievementList.BUILD_BETTER_PICKAXE);
    }
    if (block == NibiruBlocks.NIBIRU_FURNACE || block == NibiruBlocks.TERRASTONE_FURNACE) {
    // event.player.addStat(AchievementList.BUILD_FURNACE);
    }
}
Also used : Item(net.minecraft.item.Item) Block(net.minecraft.block.Block) IFireBlock(stevekung.mods.moreplanets.util.blocks.IFireBlock) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 88 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.

the class GeneralEventHandler method onLeftClickBlock.

@SubscribeEvent
public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
    BlockPos firePos = event.getPos().offset(event.getFace());
    if (event.getWorld().getBlockState(firePos).getBlock() instanceof IFireBlock) {
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMP(EnumSimplePacketMP.S_FIRE_EXTINGUISH, GCCoreUtil.getDimensionID(event.getWorld()), firePos));
        event.setCanceled(true);
    }
}
Also used : IFireBlock(stevekung.mods.moreplanets.util.blocks.IFireBlock) BlockPos(net.minecraft.util.math.BlockPos) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 89 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.

the class WorldTickEventHandler method onServerTick.

@SubscribeEvent
public void onServerTick(ServerTickEvent event) {
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (server == null) {
        return;
    }
    if (event.phase == Phase.START) {
        if (WorldTickEventHandler.startedDimensionData == null) {
            World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(0);
            WorldTickEventHandler.startedDimensionData = (WorldDataStartedDimension) world.getMapStorage().getOrLoadData(WorldDataStartedDimension.class, WorldDataStartedDimension.saveDataID);
            if (WorldTickEventHandler.startedDimensionData == null) {
                WorldTickEventHandler.startedDimensionData = new WorldDataStartedDimension(WorldDataStartedDimension.saveDataID);
                world.getMapStorage().setData(WorldDataStartedDimension.saveDataID, WorldTickEventHandler.startedDimensionData);
            }
        }
    }
    if (event.phase == Phase.END) {
        World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(ConfigManagerMP.idDimensionDiona);
        if (world.provider instanceof WorldProviderDiona) {
            if (world instanceof WorldServer) {
                WorldServer worldServer = (WorldServer) world;
                for (Iterator<Chunk> iterator = world.getPersistentChunkIterable(worldServer.getPlayerChunkMap().getChunkIterator()); iterator.hasNext(); world.profiler.endSection()) {
                    Chunk chunk = iterator.next();
                    int j = chunk.x * 16;
                    int k = chunk.z * 16;
                    if (world.rand.nextInt(75000) == 0) {
                        this.updateLCG = this.updateLCG * 3 + 1013904223;
                        int l = this.updateLCG >> 2;
                        BlockPos blockpos = this.adjustPosToNearbyEntity(world, new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)));
                        if (this.canBeamStrike(world, blockpos)) {
                            EntityAlienBeam beam = new EntityAlienBeam(world);
                            beam.setLocationAndAngles(blockpos.getX(), blockpos.getY(), blockpos.getZ(), 0.0F, 0.0F);
                            world.spawnEntity(beam);
                        }
                    }
                }
            }
        }
        world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(ConfigManagerMP.idDimensionNibiru);
        if (world.provider instanceof WorldProviderNibiru) {
            if (world instanceof WorldServer) {
                WorldServer worldServer = (WorldServer) world;
                for (Iterator<Chunk> iterator = world.getPersistentChunkIterable(worldServer.getPlayerChunkMap().getChunkIterator()); iterator.hasNext(); world.profiler.endSection()) {
                    Chunk chunk = iterator.next();
                    int j = chunk.x * 16;
                    int k = chunk.z * 16;
                    boolean flag = world.isRaining();
                    boolean flag1 = world.isThundering();
                    if (world.provider.canDoLightning(chunk) && flag && flag1 && world.rand.nextInt(1000) == 0) {
                        this.updateLCG = this.updateLCG * 3 + 1013904223;
                        int l = this.updateLCG >> 2;
                        BlockPos blockpos = this.adjustPosToNearbyEntity(world, new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)));
                        if (world.isRainingAt(blockpos)) {
                            world.spawnEntity(new EntityNibiruLightningBolt(world, blockpos.getX(), blockpos.getY(), blockpos.getZ(), true));
                        }
                    }
                    if (world.rand.nextInt(16) == 0) {
                        this.updateLCG = this.updateLCG * 3 + 1013904223;
                        int j2 = this.updateLCG >> 2;
                        BlockPos blockpos1 = world.getPrecipitationHeight(new BlockPos(j + (j2 & 15), 0, k + (j2 >> 8 & 15)));
                        BlockPos blockpos2 = blockpos1.down();
                        if (world.canBlockFreezeNoWater(blockpos2)) {
                            world.setBlockState(blockpos2, NibiruBlocks.INFECTED_ICE.getDefaultState());
                        }
                        if (flag && world.canSnowAt(blockpos1, true)) {
                            world.setBlockState(blockpos1, NibiruBlocks.INFECTED_SNOW_LAYER.getDefaultState());
                        }
                        if (flag && world.getBiome(blockpos2).canRain()) {
                            world.getBlockState(blockpos2).getBlock().fillWithRain(world, blockpos2);
                        }
                    }
                    if (world.getBiome(new BlockPos(j, 0, k)) == MPBiomes.INFECTED_DESERT || world.getBiome(new BlockPos(j, 0, k)) == MPBiomes.INFECTED_EXTREME_HILLS) {
                        if (world.rand.nextInt(250000) == 0) {
                            this.updateLCG = this.updateLCG * 3 + 1013904223;
                            int l = this.updateLCG >> 2;
                            BlockPos blockpos = this.adjustPosToNearbyEntity(world, new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)));
                            world.spawnEntity(new EntityNibiruLightningBolt(world, blockpos.getX(), blockpos.getY(), blockpos.getZ(), false));
                        }
                    }
                }
            }
        }
    }
}
Also used : WorldProviderNibiru(stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru) WorldServer(net.minecraft.world.WorldServer) EntityAlienBeam(stevekung.mods.moreplanets.module.planets.diona.entity.EntityAlienBeam) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk) WorldDataStartedDimension(stevekung.mods.moreplanets.core.data.WorldDataStartedDimension) MinecraftServer(net.minecraft.server.MinecraftServer) WorldProviderDiona(stevekung.mods.moreplanets.module.planets.diona.dimension.WorldProviderDiona) BlockPos(net.minecraft.util.math.BlockPos) EntityNibiruLightningBolt(stevekung.mods.moreplanets.module.planets.nibiru.entity.weather.EntityNibiruLightningBolt) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 90 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.

the class ClientEventHandler method onRenderLiving.

@SubscribeEvent
public void onRenderLiving(RenderLivingEvent.Post event) {
    EntityLivingBase living = event.getEntity();
    if (ClientEventHandler.entityId.contains(String.valueOf(living.getEntityId())) || living.isPotionActive(MPPotions.INFECTED_CRYSTALLIZE)) {
        GlStateManager.disableLighting();
        TextureMap texturemap = this.mc.getTextureMapBlocks();
        TextureAtlasSprite textureatlassprite = texturemap.getAtlasSprite("moreplanets:blocks/infected_crystallize");
        GlStateManager.pushMatrix();
        GlStateManager.translate((float) event.getX(), (float) event.getY(), (float) event.getZ());
        float f = living.width * 1.4F;
        GlStateManager.scale(f, f, f);
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder worldrenderer = tessellator.getBuffer();
        float f1 = 0.5F;
        float f2 = 0.0F;
        float f3 = living.height / f;
        float f4 = (float) (living.posY - living.getEntityBoundingBox().minY);
        GlStateManager.rotate(-event.getRenderer().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, 0.0F, -0.3F + (int) f3 * 0.02F);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        float f5 = 0.0F;
        int i = 0;
        worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
        while (f3 > 0.0F) {
            event.getRenderer().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            float f6 = textureatlassprite.getMinU();
            float f7 = textureatlassprite.getMinV();
            float f8 = textureatlassprite.getMaxU();
            float f9 = textureatlassprite.getMaxV();
            if (i / 2 % 2 == 0) {
                float f10 = f8;
                f8 = f6;
                f6 = f10;
            }
            worldrenderer.pos(f1 - f2, 0.0F - f4, f5).tex(f8, f9).endVertex();
            worldrenderer.pos(-f1 - f2, 0.0F - f4, f5).tex(f6, f9).endVertex();
            worldrenderer.pos(-f1 - f2, 1.4F - f4, f5).tex(f6, f7).endVertex();
            worldrenderer.pos(f1 - f2, 1.4F - f4, f5).tex(f8, f7).endVertex();
            f3 -= 0.45F;
            f4 -= 0.45F;
            f1 *= 0.9F;
            f5 += 0.03F;
            ++i;
        }
        tessellator.draw();
        GlStateManager.popMatrix();
        GlStateManager.enableLighting();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) TextureMap(net.minecraft.client.renderer.texture.TextureMap) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EntityLivingBase(net.minecraft.entity.EntityLivingBase) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1135 ItemStack (net.minecraft.item.ItemStack)316 EntityPlayer (net.minecraft.entity.player.EntityPlayer)314 World (net.minecraft.world.World)196 BlockPos (net.minecraft.util.math.BlockPos)179 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)136 IBlockState (net.minecraft.block.state.IBlockState)120 ResourceLocation (net.minecraft.util.ResourceLocation)102 Entity (net.minecraft.entity.Entity)93 Block (net.minecraft.block.Block)86 EntityLivingBase (net.minecraft.entity.EntityLivingBase)84 Minecraft (net.minecraft.client.Minecraft)72 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)66 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)64 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)55 Item (net.minecraft.item.Item)53 EntityItem (net.minecraft.entity.item.EntityItem)48 TileEntity (net.minecraft.tileentity.TileEntity)46 TextComponentString (net.minecraft.util.text.TextComponentString)42 Random (java.util.Random)37