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);
}
}
}
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);
}
}
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);
}
}
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));
}
}
}
}
}
}
}
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();
}
}
Aggregations