diff options
Diffstat (limited to 'src/main/java/gregtech/common')
70 files changed, 3449 insertions, 693 deletions
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 51f5e30c28..e528323da4 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -33,6 +33,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatFileWriter; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.oredict.OreDictionary; @@ -56,7 +57,8 @@ public class GT_Client extends GT_Proxy }); } - private final HashSet mCapeList = new HashSet(); + private final HashSet<String> mCapeList = new HashSet<>(); + public final static GT_PollutionRenderer mPollutionRenderer = new GT_PollutionRenderer(); private final GT_CapeRenderer mCapeRenderer; private final List mPosR; private final List mPosG; @@ -247,45 +249,6 @@ public class GT_Client extends GT_Proxy drawGrid(aEvent, false); } - //TODO less bad - //@SubscribeEvent - //public void manipulateDensity(EntityViewRenderEvent.FogDensity event) { - // if(GT_Pollution.mPlayerPollution > (GT_Mod.gregtechproxy.mPollutionSmogLimit)){ - // event.density = (0.15f*(Math.min(GT_Pollution.mPlayerPollution/((float)GT_Mod.gregtechproxy.mPollutionSourRainLimit),1.0f)))+0.1f; - // event.setCanceled(true); - // } - //} - - //@SubscribeEvent - //public void manipulateColor(EntityViewRenderEvent.FogColors event) { - // if(GT_Pollution.mPlayerPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit){ - // event.red = 140f/255f; - // event.green = 80f/255f; - // event.blue = 40f/255f; - // } - //} - - //@SubscribeEvent - //public void manipulateGrassColor(BiomeEvent.GetGrassColor event) { - // if(GT_Pollution.mPlayerPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit){ - // event.newColor = 0xD2691E; - // } - //} - - //@SubscribeEvent - //public void manipulateWaterColor(BiomeEvent.GetWaterColor event) { - // if(GT_Pollution.mPlayerPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit){ - // event.newColor = 0x556B2F; - // } - //} - - //@SubscribeEvent - //public void manipulateFoliageColor(BiomeEvent.GetFoliageColor event) { - // if(GT_Pollution.mPlayerPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit){ - // event.newColor = 0xCD853F; - // } - //} - public boolean isServerSide() { return true; } @@ -329,6 +292,8 @@ public class GT_Client extends GT_Proxy mCapeList.add(tName.toLowerCase()); } (new Thread(this)).start(); + + mPollutionRenderer.preLoad(); } public void onLoad() { @@ -730,4 +695,8 @@ public class GT_Client extends GT_Proxy return 0; } } + + public static void recieveChunkPollutionPacket(ChunkCoordIntPair chunk, int pollution) { + mPollutionRenderer.processPacket(chunk, pollution); + } } diff --git a/src/main/java/gregtech/common/GT_Pollution.java b/src/main/java/gregtech/common/GT_Pollution.java index f25c21f86a..be49e57e4a 100644 --- a/src/main/java/gregtech/common/GT_Pollution.java +++ b/src/main/java/gregtech/common/GT_Pollution.java @@ -1,12 +1,18 @@ package gregtech.common; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.network.NetworkRegistry; import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GT_Packet_Pollution; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -15,6 +21,8 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.ChunkPosition; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.ChunkWatchEvent; import java.util.ArrayList; import java.util.HashMap; @@ -64,6 +72,10 @@ public class GT_Pollution { private final World aWorld; public static int mPlayerPollution; + private static int POLLUTIONPACKET_MINVALUE = 1000; + + private static GT_PollutionEventHandler EVENT_HANDLER; + public GT_Pollution(World world){ aWorld=world; chunkData=dimensionWiseChunkData.get(aWorld.provider.dimensionId); @@ -72,6 +84,11 @@ public class GT_Pollution { dimensionWiseChunkData.put(world.provider.dimensionId,chunkData); } dimensionWisePollution.put(aWorld.provider.dimensionId,this); + + if (EVENT_HANDLER == null) { + EVENT_HANDLER = new GT_PollutionEventHandler(); + MinecraftForge.EVENT_BUS.register(EVENT_HANDLER); + } } public static void onWorldTick(TickEvent.WorldTickEvent aEvent){//called from proxy @@ -130,7 +147,9 @@ public class GT_Pollution { AxisAlignedBB chunk = AxisAlignedBB.getBoundingBox(actualPos.chunkXPos << 4, 0, actualPos.chunkZPos << 4, (actualPos.chunkXPos << 4) + 16, 256, (actualPos.chunkZPos << 4) + 16); List<EntityLivingBase> tEntitys = aWorld.getEntitiesWithinAABB(EntityLivingBase.class, chunk); for (EntityLivingBase tEnt : tEntitys) { - if (!GT_Utility.isWearingFullGasHazmat(tEnt)) { + if (tEnt instanceof EntityPlayerMP && ((EntityPlayerMP) tEnt).capabilities.isCreativeMode) + continue; + if (!(GT_Utility.isWearingFullGasHazmat(tEnt))) { switch (XSTR_INSTANCE.nextInt(3)) { default: tEnt.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, Math.min(tPollution / 1000, 1000), tPollution / 400000)); @@ -148,6 +167,8 @@ public class GT_Pollution { //AxisAlignedBB chunk = AxisAlignedBB.getBoundingBox(tPos.chunkPosX*16, 0, tPos.chunkPosZ*16, tPos.chunkPosX*16+16, 256, tPos.chunkPosZ*16+16); //List<EntityLiving> tEntitys = aWorld.getEntitiesWithinAABB(EntityLiving.class, chunk); for (EntityLivingBase tEnt : tEntitys) { + if (tEnt instanceof EntityPlayerMP && ((EntityPlayerMP) tEnt).capabilities.isCreativeMode) + continue; if (!GT_Utility.isWearingFullGasHazmat(tEnt)) { switch (XSTR_INSTANCE.nextInt(4)) { default: @@ -178,15 +199,21 @@ public class GT_Pollution { } //Write new pollution to Hashmap !!! chunkData.get(actualPos)[GTPOLLUTION] = tPollution; + + //Send new value to players nearby + if (tPollution > POLLUTIONPACKET_MINVALUE) { + NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(aWorld.provider.dimensionId, (actualPos.chunkXPos << 4), 64, (actualPos.chunkZPos << 4), 256); + GT_Values.NW.sendToAllAround(new GT_Packet_Pollution(actualPos, tPollution), point); + } } } - + private static void damageBlock(World world, int x, int y, int z, boolean sourRain){ if (world.isRemote) return; Block tBlock = world.getBlock(x, y, z); int tMeta = world.getBlockMetadata(x, y, z); if (tBlock == Blocks.air || tBlock == Blocks.stone || tBlock == Blocks.sand|| tBlock == Blocks.deadbush)return; - + if (tBlock == Blocks.leaves || tBlock == Blocks.leaves2 || tBlock.getMaterial() == Material.leaves) world.setBlockToAir(x, y, z); if (tBlock == Blocks.reeds) { @@ -199,12 +226,12 @@ public class GT_Pollution { tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0); world.setBlockToAir(x, y, z); } - if (tBlock == Blocks.waterlily || tBlock == Blocks.wheat || tBlock == Blocks.cactus || + if (tBlock == Blocks.waterlily || tBlock == Blocks.wheat || tBlock == Blocks.cactus || tBlock.getMaterial() == Material.cactus || tBlock == Blocks.melon_block || tBlock == Blocks.melon_stem) { tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0); world.setBlockToAir(x, y, z); } - if (tBlock == Blocks.red_flower || tBlock == Blocks.yellow_flower || tBlock == Blocks.carrots || + if (tBlock == Blocks.red_flower || tBlock == Blocks.yellow_flower || tBlock == Blocks.carrots || tBlock == Blocks.potatoes || tBlock == Blocks.pumpkin || tBlock == Blocks.pumpkin_stem) { tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0); world.setBlockToAir(x, y, z); @@ -218,12 +245,12 @@ public class GT_Pollution { if (tBlock == Blocks.mossy_cobblestone) world.setBlock(x, y, z, Blocks.cobblestone); if (tBlock == Blocks.grass || tBlock.getMaterial() == Material.grass ) - world.setBlock(x, y, z, Blocks.dirt); + world.setBlock(x, y, z, Blocks.dirt); if(tBlock == Blocks.farmland || tBlock == Blocks.dirt){ - world.setBlock(x, y, z, Blocks.sand); + world.setBlock(x, y, z, Blocks.sand); } - - if(sourRain && world.isRaining() && (tBlock == Blocks.stone || tBlock == Blocks.gravel || tBlock == Blocks.cobblestone) && + + if(sourRain && world.isRaining() && (tBlock == Blocks.stone || tBlock == Blocks.gravel || tBlock == Blocks.cobblestone) && world.getBlock(x, y+1, z) == Blocks.air && world.canBlockSeeTheSky(x, y, z)){ if(tBlock == Blocks.stone){world.setBlock(x, y, z, Blocks.cobblestone); } else if(tBlock == Blocks.cobblestone){world.setBlock(x, y, z, Blocks.gravel); } @@ -256,19 +283,22 @@ public class GT_Pollution { } public static int getPollution(Chunk ch){ - if(!GT_Mod.gregtechproxy.mPollution)return 0; + if(!GT_Mod.gregtechproxy.mPollution) + return 0; HashMap<ChunkCoordIntPair,int[]> dataMap=dimensionWiseChunkData.get(ch.worldObj.provider.dimensionId); if(dataMap==null || dataMap.get(ch.getChunkCoordIntPair())==null) return 0; return dataMap.get(ch.getChunkCoordIntPair())[GTPOLLUTION]; } - public static int getPollution(ChunkCoordIntPair aCh, int aDim){ - if(!GT_Mod.gregtechproxy.mPollution)return 0; - HashMap<ChunkCoordIntPair,int[]> dataMap=dimensionWiseChunkData.get(aDim); - if(dataMap==null || dataMap.get(aCh)==null) return 0; + public static int getPollution(ChunkCoordIntPair aCh, int aDim) { + if (!GT_Mod.gregtechproxy.mPollution) + return 0; + HashMap<ChunkCoordIntPair, int[]> dataMap = dimensionWiseChunkData.get(aDim); + if (dataMap == null || dataMap.get(aCh) == null) + return 0; return dataMap.get(aCh)[GTPOLLUTION]; } - + //Add compatibility with old code @Deprecated /*Don't use it... too weird way of passing position*/ public static void addPollution(World aWorld, ChunkPosition aPos, int aPollution){ @@ -276,4 +306,15 @@ public class GT_Pollution { //is just bad especially when that is both used to store ChunkPos and BlockPos depending on context addPollution(aWorld.getChunkFromBlockCoords(aPos.chunkPosX,aPos.chunkPosZ),aPollution); } + + public class GT_PollutionEventHandler { + @SubscribeEvent + public void chunkWatch(ChunkWatchEvent.Watch event) { + if (chunkData.containsKey(event.chunk)) { + int pollution = chunkData.get(event.chunk)[GTPOLLUTION]; + if (pollution > POLLUTIONPACKET_MINVALUE) + GT_Values.NW.sendToPlayer(new GT_Packet_Pollution(event.chunk, pollution), event.player); + } + } + } } diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 26b971a093..5b762d6d58 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1490,11 +1490,6 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { aEvent.player.addExhaustion(Math.max(1.0F, tCount / 666.6F)); } } - if (aEvent.player.ticksExisted % 10 == 0) { - int tPollution = 0; - tPollution = GT_Pollution.getPollution(new ChunkCoordIntPair(aEvent.player.chunkCoordX,aEvent.player.chunkCoordZ), aEvent.player.dimension); - if(aEvent.player instanceof EntityPlayerMP)GT_Values.NW.sendToPlayer(new GT_Packet_Pollution(tPollution), (EntityPlayerMP) aEvent.player); - } } } diff --git a/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java b/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java index 83dc82e6f9..41726b4fc5 100644 --- a/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java +++ b/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java @@ -8,9 +8,19 @@ import forestry.apiculture.genetics.alleles.AlleleBeeSpecies; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import java.awt.*; + public class GT_AlleleBeeSpecies extends AlleleBeeSpecies { - public GT_AlleleBeeSpecies(String uid, boolean dominant, String unlocalizedName, String authority, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor) { - super(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor, secondaryColor); + public GT_AlleleBeeSpecies(String uid, + boolean dominant, + String unlocalizedName, + String authority, + String unlocalizedDescription, + IClassification branch, + String binomial, + Color primaryColor, + Color secondaryColor) { + super(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor.getRGB(), secondaryColor.getRGB()); AlleleManager.alleleRegistry.registerAllele(this, EnumBeeChromosome.SPECIES); } diff --git a/src/main/java/gregtech/common/bees/GT_AlleleHelper.java b/src/main/java/gregtech/common/bees/GT_AlleleHelper.java index cb54f5d4a1..e1db4c2ac0 100644 --- a/src/main/java/gregtech/common/bees/GT_AlleleHelper.java +++ b/src/main/java/gregtech/common/bees/GT_AlleleHelper.java @@ -21,7 +21,7 @@ public class GT_AlleleHelper extends AlleleHelper { private static final String modId = Constants.ID; - private Map<Class, Map<?, ? extends IAllele>> alleleMaps = new HashMap<>(); + private Map<Class<?>, Map<?, ? extends IAllele>> alleleMaps = new HashMap<>(); public void init() { if (PluginManag |
