Updated to Minecraft 1.7.10 (Not yet backwards compatible with 1.7.2 so i've temporarily raised the Forge version requirement)
This commit is contained in:
parent
6cdf4b4d4a
commit
a8cba72d09
17 changed files with 580 additions and 105 deletions
|
@ -1,3 +1,3 @@
|
|||
minecraft_version=1.7.2
|
||||
forge_version=10.12.1.1110
|
||||
mod_version=2.0.1
|
||||
minecraft_version=1.7.10
|
||||
forge_version=10.13.0.1152
|
||||
mod_version=2.0.2
|
||||
|
|
14
src/api/java/ttftcuts/atg/api/ATGAPI.java
Normal file
14
src/api/java/ttftcuts/atg/api/ATGAPI.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package ttftcuts.atg.api;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ATGAPI {
|
||||
|
||||
public static boolean WorldIsATG(World world) {
|
||||
return world.provider.terrainType.getWorldTypeName() == "ATG";
|
||||
}
|
||||
|
||||
public static Optional<Integer> sealevel = Optional.absent();
|
||||
}
|
274
src/api/java/ttftcuts/atg/api/ATGBiomes.java
Normal file
274
src/api/java/ttftcuts/atg/api/ATGBiomes.java
Normal file
|
@ -0,0 +1,274 @@
|
|||
package ttftcuts.atg.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ttftcuts.atg.api.events.*;
|
||||
import ttftcuts.atg.api.events.listenable.ATGBiomeGroupAssignmentEvent.ATGGroupActivationEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TTFTCUTS
|
||||
*
|
||||
* Biome related API things! Biome groups, adding biomes to those groups and more.
|
||||
*
|
||||
*/
|
||||
public abstract class ATGBiomes {
|
||||
|
||||
public static enum BiomeType { LAND, COAST, SEA }
|
||||
|
||||
/**
|
||||
* Gets an ATG biome by name.
|
||||
*
|
||||
* @param biomeName
|
||||
* The name of the biome you want to get.
|
||||
*
|
||||
* @return the corresponding biome.
|
||||
*/
|
||||
public static BiomeGenBase getBiome(String biomeName) {
|
||||
final ATGBiomeRequestEvent event = new ATGBiomeRequestEvent(biomeName);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
if ( !event.biome.isPresent() ) {
|
||||
return null;
|
||||
}
|
||||
return event.biome.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of names corresponding to the Biome Groups which contain a specified biome.
|
||||
*
|
||||
* @param biome
|
||||
* The biome you want to find groups for.
|
||||
*
|
||||
* @return a list of names of containing Biome Groups.
|
||||
*/
|
||||
public static List<String> getGroupFromBiome(BiomeGenBase biome) {
|
||||
final ATGBiomeGroupRequestEvent event = new ATGBiomeGroupRequestEvent(biome);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.groups;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the raw height, temperature and moisture values from the generator for a specific pair of x/z coordinates.
|
||||
*
|
||||
* WARNING: This is a VERY expensive calculation and the result is NOT cached, so please use as little as possible!
|
||||
*
|
||||
* @param world
|
||||
* The world that you want to get the information for.
|
||||
*
|
||||
* @param x
|
||||
* X coordinate of the point to query.
|
||||
*
|
||||
* @param z
|
||||
* Z coordinate of the point to query.
|
||||
*
|
||||
* @return an array of three doubles corresponding to the height, temperature and moisture at the specified point in the ranges 0.0-1.0.
|
||||
*/
|
||||
public static double[] getGeneratorInfo(World world, double x, double z) {
|
||||
final ATGGeneratorInfoEvent event = new ATGGeneratorInfoEvent(world,x,z);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new biome GROUP to ATG. Not something that would usually need to be used.
|
||||
*
|
||||
* @param type
|
||||
* The biome type that this group belongs to. LAND, COAST or SEA.
|
||||
*
|
||||
* @param name
|
||||
* The name of this group.
|
||||
*
|
||||
* @param temp
|
||||
* Temperature value for this group. Same range as biome temperatures.
|
||||
*
|
||||
* @param moisture
|
||||
* Moisture value for this group. Same range as biome rainfall.
|
||||
*
|
||||
* @param height
|
||||
* Average height value for this group. Same range as biome heights.
|
||||
*
|
||||
* @param minHeight
|
||||
* Minimum height to generate this group. Above this value, it will be skipped.
|
||||
*
|
||||
* @param maxHeight
|
||||
* Maximum height to generate this group. Below this value, it will be skipped.
|
||||
*
|
||||
* @param salt
|
||||
* Biome blob generation salt. Used to offset biome boundaries from other groups to avoid strange artifacts.
|
||||
*
|
||||
* @param generate
|
||||
* Set to false to prevent this group generating in the default manner. Primarily for use with the biome group assignment events.
|
||||
*/
|
||||
public static void addBiomeGroup(BiomeType type, String name, double temp, double moisture, double height, double minHeight, double maxHeight, long salt, boolean generate) {
|
||||
ATGBiomeGroupAddEvent event = new ATGBiomeGroupAddEvent(type, name, temp, moisture, height, minHeight, maxHeight, salt, generate);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
if ( event.response == ATGBiomeGroupAddEvent.ResponseType.FAILED ) {
|
||||
// FAILED!
|
||||
}
|
||||
}
|
||||
public static void addBiomeGroup(BiomeType type, String name, double temp, double moisture, double height, double minHeight, double maxHeight, long salt) {
|
||||
addBiomeGroup(type, name, temp, moisture, height, minHeight, maxHeight, salt, true);
|
||||
}
|
||||
public static void addBiomeGroup(BiomeType type, String name, double temp, double moisture, double height, long salt) {
|
||||
addBiomeGroup(type, name, temp, moisture, height, 0.0, 1.0, salt);
|
||||
}
|
||||
public static void addBiomeGroup(BiomeType type, String name, double temp, double moisture, double height) {
|
||||
addBiomeGroup(type, name, temp, moisture, height, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modifies a biome group to make it more or less likely to be chosen by the generator.
|
||||
* Best used to ensure a height-constrained biome group generates in favour of an otherwise identically ranged group.
|
||||
*
|
||||
* @param type
|
||||
* Group type for the second parameter. LAND, COAST or SEA.
|
||||
*
|
||||
* @param name
|
||||
* Name of the group to modify.
|
||||
*
|
||||
* @param modifier
|
||||
* Modifier value. Positive makes the group more likely to be picked. Very small values can have a large effect.
|
||||
*/
|
||||
public static void modGroupSuitability(BiomeType type, String name, double modifier) {
|
||||
ATGBiomeGroupEvent event = new ATGBiomeGroupEvent( ATGBiomeGroupEvent.EventType.SUITABILITY, type, name, modifier );
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
if ( event.response == ATGBiomeGroupEvent.ResponseType.FAILED ) {
|
||||
// FAILED!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a biome with ATG.
|
||||
*
|
||||
* @param type
|
||||
* Type of the biome group this biome will inhabit. LAND, COAST or SEA.
|
||||
*
|
||||
* @param group
|
||||
* Name of the biome group this biome will inhabit.
|
||||
*
|
||||
* @param biome
|
||||
* The biome to be registered.
|
||||
*
|
||||
* @param weight
|
||||
* Generation weight for this biome. All vanilla biomes are weighted 1.0 except mushroom island.
|
||||
*/
|
||||
public static void addBiome(BiomeType type, String group, BiomeGenBase biome, double weight) {
|
||||
ATGBiomeEvent event = new ATGBiomeEvent( type, group, biome, null, weight);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace a biome in a group with a different biome.
|
||||
*
|
||||
* @param type
|
||||
* Type of the target biome group. LAND, COAST or SEA.
|
||||
*
|
||||
* @param group
|
||||
* Name of the target biome group.
|
||||
*
|
||||
* @param toReplace
|
||||
* Biome to replace in the specified group.
|
||||
*
|
||||
* @param replacement
|
||||
* Biome which will replace toReplace in the group.
|
||||
*
|
||||
* @param weight
|
||||
* Generation weight for the replacement biome.
|
||||
*/
|
||||
public static void replaceBiome(BiomeType type, String group, BiomeGenBase toReplace, BiomeGenBase replacement, double weight) {
|
||||
ATGBiomeEvent event = new ATGBiomeEvent( type, group, replacement, toReplace, weight );
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a sub-biome to a biome. Sub-biomes appear as smaller patches within their parent biome.
|
||||
*
|
||||
* @param biome
|
||||
* Parent biome.
|
||||
*
|
||||
* @param subBiome
|
||||
* Biome that will appear as a sub-biome.
|
||||
*
|
||||
* @param weight
|
||||
* Generation weight for the sub-biome. The parent biome is always weighted at 1.0, so a 1.0 weight here with a single sub-biome would be a 50/50 split.
|
||||
*/
|
||||
public static void addSubBiome(BiomeGenBase biome, BiomeGenBase subBiome, double weight) {
|
||||
ATGBiomeModEvent event = new ATGBiomeModEvent(ATGBiomeModEvent.EventType.SUBBIOME, biome, null, subBiome, weight);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an IGenMod to a biome to modify how it generates.
|
||||
*
|
||||
* @param biome
|
||||
* Biome to attach the mod to.
|
||||
*
|
||||
* @param mod
|
||||
* IGenMod object that will modify the biome.
|
||||
*/
|
||||
public static void addGenMod(BiomeGenBase biome, IGenMod mod) {
|
||||
ATGBiomeModEvent event = new ATGBiomeModEvent(ATGBiomeModEvent.EventType.GENMOD, biome, mod, null, 0);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the IGenMod assigned to a biome, or Optional.absent if there isn't one.
|
||||
*
|
||||
* @param biome
|
||||
* The biome to get the IGenMod for.
|
||||
*
|
||||
* @return an Optional corresponding to the IGenMod for the biome, or Optional.absent.
|
||||
*/
|
||||
public static Optional<IGenMod> getGenMod(BiomeGenBase biome) {
|
||||
ATGBiomeModRequestEvent event = new ATGBiomeModRequestEvent(biome);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.mod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the rock parameters for a biome, to modify how ATG boulders generate there.
|
||||
*
|
||||
* @param biome
|
||||
* The biome to set rock properties for.
|
||||
*
|
||||
* @param rockChance
|
||||
* 1 in rockChance chunks will contain a rock.
|
||||
*
|
||||
* @param bigRockChance
|
||||
* 1 in bigRockChance rocks will be large.
|
||||
*
|
||||
* @param rocksPerChunk
|
||||
* rockChance will be checked rocksPerChunk times per chunk.
|
||||
*/
|
||||
public static void setBiomeRocks(BiomeGenBase biome, int rockChance, int bigRockChance, int rocksPerChunk) {
|
||||
ATGBiomeRocksEvent event = new ATGBiomeRocksEvent(biome, rockChance, bigRockChance, rocksPerChunk);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to enable the posting of "ATGBiomeGroupAssignmentEvent"s at generation, to allow custom biome group overrides.
|
||||
* If this is not called at least once, none of those events will be sent.
|
||||
*
|
||||
* Listening for ATGBiomeGroupAssignmentEvent allows direct replacement of the biome group at every x/z coordinate pair.
|
||||
* When enabled, it slows generation by about 10% due to event volume, so it's off by default.
|
||||
*
|
||||
* Only call this if you intend to listen for those events.
|
||||
*/
|
||||
public static void enableBiomeGroupAssignmentEvent() {
|
||||
ATGGroupActivationEvent event = new ATGGroupActivationEvent();
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
}
|
11
src/api/java/ttftcuts/atg/api/IGenMod.java
Normal file
11
src/api/java/ttftcuts/atg/api/IGenMod.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package ttftcuts.atg.api;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IGenMod {
|
||||
public int modify( World world, int height, Random random, double rawHeight, int x, int z );
|
||||
|
||||
public double noiseFactor();
|
||||
}
|
27
src/api/java/ttftcuts/atg/api/events/ATGBiomeEvent.java
Normal file
27
src/api/java/ttftcuts/atg/api/events/ATGBiomeEvent.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package ttftcuts.atg.api.events;
|
||||
|
||||
import ttftcuts.atg.api.ATGBiomes.BiomeType;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ATGBiomeEvent extends Event {
|
||||
|
||||
public static enum ResponseType { NONE, ADDED, REPLACED, BAD_GROUP, FAILED };
|
||||
|
||||
public BiomeType type;
|
||||
public ResponseType response;
|
||||
public String group;
|
||||
public BiomeGenBase biome;
|
||||
public BiomeGenBase replaced;
|
||||
public double weight;
|
||||
|
||||
public ATGBiomeEvent(BiomeType type, String group, BiomeGenBase biome, BiomeGenBase replaced, double weight) {
|
||||
this.type = type;
|
||||
this.group = group;
|
||||
this.biome = biome;
|
||||
this.replaced = replaced;
|
||||
this.weight = weight;
|
||||
this.response = ResponseType.NONE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package ttftcuts.atg.api.events;
|
||||
|
||||
import ttftcuts.atg.api.ATGBiomes.BiomeType;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ATGBiomeGroupAddEvent extends Event {
|
||||
|
||||
public static enum ResponseType { NONE, OK, FAILED };
|
||||
|
||||
public BiomeType type;
|
||||
public ResponseType response;
|
||||
public String name;
|
||||
public double temp;
|
||||
public double moisture;
|
||||
public double height;
|
||||
public double minHeight;
|
||||
public double maxHeight;
|
||||
public long salt;
|
||||
public boolean generate;
|
||||
|
||||
public ATGBiomeGroupAddEvent( BiomeType type, String name, double temp, double moisture, double height, double minHeight, double maxHeight, long salt, boolean generate) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.temp = temp;
|
||||
this.moisture = moisture;
|
||||
this.height = height;
|
||||
this.minHeight = minHeight;
|
||||
this.maxHeight = maxHeight;
|
||||
this.salt = salt;
|
||||
this.generate = generate;
|
||||
this.response = ResponseType.NONE;
|
||||
}
|
||||
}
|
24
src/api/java/ttftcuts/atg/api/events/ATGBiomeGroupEvent.java
Normal file
24
src/api/java/ttftcuts/atg/api/events/ATGBiomeGroupEvent.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package ttftcuts.atg.api.events;
|
||||
|
||||
import ttftcuts.atg.api.ATGBiomes.BiomeType;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ATGBiomeGroupEvent extends Event {
|
||||
|
||||
public static enum EventType { SUITABILITY };
|
||||
public static enum ResponseType { NONE, OK, FAILED };
|
||||
|
||||
public EventType type;
|
||||
public BiomeType biomeType;
|
||||
public ResponseType response;
|
||||
public String name;
|
||||
public double modifier;
|
||||
|
||||
public ATGBiomeGroupEvent( EventType type, BiomeType biomeType, String name, double modifier ) {
|
||||
this.type = type;
|
||||
this.biomeType = biomeType;
|
||||
this.name = name;
|
||||
this.modifier = modifier;
|
||||
this.response = ResponseType.NONE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package ttftcuts.atg.api.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ATGBiomeGroupRequestEvent extends Event {
|
||||
|
||||
public BiomeGenBase biome;
|
||||
public List<String> groups;
|
||||
|
||||
public ATGBiomeGroupRequestEvent(BiomeGenBase biome) {
|
||||
this.biome = biome;
|
||||
this.groups = null;
|
||||
}
|
||||
}
|
25
src/api/java/ttftcuts/atg/api/events/ATGBiomeModEvent.java
Normal file
25
src/api/java/ttftcuts/atg/api/events/ATGBiomeModEvent.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package ttftcuts.atg.api.events;
|
||||
|
||||
import ttftcuts.atg.api.IGenMod;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ATGBiomeModEvent extends Event {
|
||||
|
||||
public static enum EventType { GENMOD, SUBBIOME }
|
||||
|
||||
public EventType type;
|
||||
public BiomeGenBase biome;
|
||||
public IGenMod mod;
|
||||
public BiomeGenBase subBiome;
|
||||
public double weight;
|
||||
|
||||
public ATGBiomeModEvent( EventType type, BiomeGenBase biome, IGenMod mod, BiomeGenBase subBiome, double weight ) {
|
||||
|
||||
this.type = type;
|
||||
this.biome = biome;
|
||||
this.subBiome = subBiome;
|
||||
this.mod = mod;
|
||||
this.weight = weight;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package ttftcuts.atg.api.events;
|
||||
|
||||
import ttftcuts.atg.api.IGenMod;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ATGBiomeModRequestEvent extends Event {
|
||||
|
||||
public BiomeGenBase biome;
|
||||
public Optional<IGenMod> mod;
|
||||
|
||||
public ATGBiomeModRequestEvent(BiomeGenBase biome) {
|
||||
this.biome = biome;
|
||||
this.mod = Optional.absent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package ttftcuts.atg.api.events;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ATGBiomeRequestEvent extends Event {
|
||||
|
||||
public String biomeName;
|
||||
public Optional<BiomeGenBase> biome;
|
||||
|
||||
public ATGBiomeRequestEvent(String biomeName) {
|
||||
this.biomeName = biomeName;
|
||||
this.biome = Optional.absent();
|
||||
}
|
||||
}
|
19
src/api/java/ttftcuts/atg/api/events/ATGBiomeRocksEvent.java
Normal file
19
src/api/java/ttftcuts/atg/api/events/ATGBiomeRocksEvent.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package ttftcuts.atg.api.events;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ATGBiomeRocksEvent extends Event {
|
||||
|
||||
public BiomeGenBase biome;
|
||||
public int rockChance;
|
||||
public int bigRockChance;
|
||||
public int rocksPerChunk;
|
||||
|
||||
public ATGBiomeRocksEvent( BiomeGenBase biome, int rockChance, int bigRockChance, int rocksPerChunk ) {
|
||||
this.biome = biome;
|
||||
this.rockChance = rockChance;
|
||||
this.bigRockChance = bigRockChance;
|
||||
this.rocksPerChunk = rocksPerChunk;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package ttftcuts.atg.api.events;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ATGGeneratorInfoEvent extends Event {
|
||||
|
||||
public World world;
|
||||
public double x;
|
||||
public double z;
|
||||
public double[] info;
|
||||
|
||||
public ATGGeneratorInfoEvent(World world, double x, double z) {
|
||||
this.world = world;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package ttftcuts.atg.api.events.listenable;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
// Listen for this to change the biold group at a point!
|
||||
public class ATGBiomeGroupAssignmentEvent extends Event {
|
||||
|
||||
public int x;
|
||||
public int z;
|
||||
public double height;
|
||||
public double temperature;
|
||||
public double moisture;
|
||||
public String group;
|
||||
public boolean modified;
|
||||
|
||||
public ATGBiomeGroupAssignmentEvent(int x, int z, double height, double temp, double moisture, String group) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.height = height;
|
||||
this.temperature = temp;
|
||||
this.moisture = moisture;
|
||||
this.group = group;
|
||||
this.modified = false;
|
||||
}
|
||||
|
||||
public void setGroup(String newgroup) {
|
||||
this.group = newgroup;
|
||||
this.modified = true;
|
||||
}
|
||||
|
||||
public static class ATGGroupActivationEvent extends Event {}
|
||||
}
|
|
@ -75,23 +75,23 @@ public class EntityDart extends EntityArrow
|
|||
//TODO: getCollisionBoundingBoxFromPool()
|
||||
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
|
||||
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ)))
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(posX, posY, posZ)))
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
++ticksInAir;
|
||||
Vec3 vec3 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
|
||||
Vec3 vec31 = worldObj.getWorldVec3Pool().getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
//TODO: rayTraceBlocks_do_do()?
|
||||
MovingObjectPosition movingobjectposition = worldObj.func_147447_a(vec3, vec31, false, true, false);
|
||||
vec3 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
|
||||
vec31 = worldObj.getWorldVec3Pool().getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
vec3 = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
vec31 = worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
vec31 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
}
|
||||
|
||||
Entity entity = null;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package biomesoplenty.common.eventhandler.misc;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -13,14 +10,20 @@ import java.net.URLConnection;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import biomesoplenty.common.utils.BOPLogger;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -29,10 +32,8 @@ public class CapeEventHandler
|
|||
private final String serverLocation = "https://raw.github.com/Glitchfiend/BiomesOPlenty/master/capes.txt";
|
||||
private final int timeout = 1000;
|
||||
|
||||
private static final Graphics TEST_GRAPHICS = new BufferedImage(128, 128,
|
||||
BufferedImage.TYPE_INT_RGB).getGraphics();
|
||||
private HashMap<String, String> cloaks = new HashMap<String, String>();
|
||||
private ArrayList<AbstractClientPlayer> capePlayers = new ArrayList<AbstractClientPlayer>();
|
||||
private ArrayList<AbstractClientPlayer> checkedPlayers = new ArrayList<AbstractClientPlayer>();
|
||||
|
||||
public static CapeEventHandler instance;
|
||||
|
||||
|
@ -53,22 +54,24 @@ public class CapeEventHandler
|
|||
if (event.entityPlayer instanceof AbstractClientPlayer)
|
||||
{
|
||||
AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) event.entityPlayer;
|
||||
|
||||
if (!capePlayers.contains(abstractClientPlayer))
|
||||
|
||||
if (!checkedPlayers.contains(abstractClientPlayer))
|
||||
{
|
||||
String cloakURL = cloaks.get(event.entityPlayer.getDisplayName());
|
||||
checkedPlayers.add(abstractClientPlayer);
|
||||
|
||||
// getSkinManager()?
|
||||
SkinManager skinManager = Minecraft.getMinecraft().func_152342_ad();
|
||||
|
||||
if (cloakURL == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String uuid = UUIDTypeAdapter.fromUUID(abstractClientPlayer.getUniqueID());
|
||||
|
||||
capePlayers.add(abstractClientPlayer);
|
||||
if (cloaks.containsKey(uuid))
|
||||
{
|
||||
MinecraftProfileTexture profileTexture = new MinecraftProfileTexture(cloaks.get(uuid));
|
||||
|
||||
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), false, new String[]{"textureUploaded", "field_110559_g"});
|
||||
|
||||
new Thread(new CloakThread(abstractClientPlayer, cloakURL)).start();
|
||||
event.renderCape = true;
|
||||
skinManager.func_152789_a(profileTexture, MinecraftProfileTexture.Type.CAPE, abstractClientPlayer);
|
||||
|
||||
event.renderCape = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,17 +94,21 @@ public class CapeEventHandler
|
|||
{
|
||||
if (!str.startsWith("--") && !str.isEmpty())
|
||||
{
|
||||
if (str.contains(":"))
|
||||
{
|
||||
String nick = str.substring(0, str.indexOf(":"));
|
||||
String link = str.substring(str.indexOf(":") + 1);
|
||||
new Thread(new CloakPreload(link)).start();
|
||||
cloaks.put(nick, link);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("[BiomesOPlenty] [capes.txt] Syntax error on line " + linetracker + ": " + str);
|
||||
}
|
||||
if (str.startsWith("*%"))
|
||||
{
|
||||
str = str.replace("*%", "");
|
||||
|
||||
if (str.contains(":"))
|
||||
{
|
||||
String uuid = str.substring(0, str.indexOf(":"));
|
||||
String link = str.substring(str.indexOf(":") + 1);
|
||||
cloaks.put(uuid, link);
|
||||
}
|
||||
else
|
||||
{
|
||||
BOPLogger.log(Level.WARN, "[capes.txt] Syntax error on line " + linetracker + ": " + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
linetracker++;
|
||||
}
|
||||
|
@ -117,66 +124,4 @@ public class CapeEventHandler
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private class CloakThread implements Runnable
|
||||
{
|
||||
AbstractClientPlayer abstractClientPlayer;
|
||||
String cloakURL;
|
||||
|
||||
public CloakThread(AbstractClientPlayer player, String cloak)
|
||||
{
|
||||
abstractClientPlayer = player;
|
||||
cloakURL = cloak;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
Image cape = new ImageIcon(new URL(cloakURL)).getImage();
|
||||
BufferedImage bo = new BufferedImage(cape.getWidth(null),
|
||||
cape.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
||||
bo.getGraphics().drawImage(cape, 0, 0, null);
|
||||
|
||||
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), bo, new String[] { "bufferedImage", "field_110560_d" });
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CloakPreload implements Runnable
|
||||
{
|
||||
String cloakURL;
|
||||
|
||||
public CloakPreload(String link)
|
||||
{
|
||||
cloakURL = link;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
TEST_GRAPHICS
|
||||
.drawImage(new ImageIcon(new URL(cloakURL)).getImage(),
|
||||
0, 0, null);
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshCapes()
|
||||
{
|
||||
cloaks.clear();
|
||||
capePlayers.clear();
|
||||
buildCloakURLDatabase();
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ public class PositionUtils
|
|||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double)f;
|
||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double)f + (double)(world.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight()); // isRemote check to revert changes to ray trace position due to adding the eye height clientside and player yOffset differences
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double)f;
|
||||
Vec3 vec3 = world.getWorldVec3Pool().getVecFromPool(d0, d1, d2);
|
||||
Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
|
||||
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
|
||||
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
|
||||
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
||||
|
|
Loading…
Reference in a new issue