Merge branch 'dev'

This commit is contained in:
KAMKEEL committed 2022-10-03 18:37:51 -04:00
commit 331d3e9f09
39 files changed
+362 -1786

No files matched your search

+1
View File
@@ -10,3 +10,4 @@ eclipse
bin
.metadata
*.bak
classes
+102 -2
View File
@@ -15,9 +15,16 @@ buildscript {
}
}
configurations {
embed
compile.extendsFrom(embed)
shade
compile.extendsFrom(shade)
}
apply plugin: 'forge'
version = "1.6.1"
version = "1.6.2"
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus"
@@ -64,4 +71,97 @@ processResources
}
}
sourceSets {main { output.resourcesDir = output.classesDir }}
sourceSets {main { output.resourcesDir = output.classesDir }}
jar {
manifest {
attributes(
'FMLAT': "customnpcs_at.cfg",
)
}
}
//##########################################################################################################
//######################################## Mixin Part ################################################
//##########################################################################################################
//Add
//--tweakClass org.spongepowered.asm.launch.MixinTweaker --mixin customnpcs.mixins.json
//to your client and server program arguments if working in a dev environment.
def yourMixinConfig = 'customnpcs.mixins.json'
def refMapForYourConfig = 'customnpcs.refmap.json'
def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar'
repositories {
maven {
name = "sponge"
url = "https://repo.spongepowered.org/maven/"
}
}
dependencies {
embed('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
}
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + refMapForYourConfig
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
jar {
configurations.shade.each { dep ->
from(project.zipTree(dep)){
exclude 'META-INF', 'META-INF/**'
}
}
from refMap
manifest {
attributes.put("TweakClass", "org.spongepowered.asm.launch.MixinTweaker")
attributes.put("FMLCorePluginContainsFMLMod", true)
attributes.put("ForceLoadAsMod", true)
attributes.put("MixinConfigs", yourMixinConfig)
}
// embed libraries in jar
from configurations.embed.collect {
exclude '**/LICENSE.txt'
it.isDirectory() ? it : zipTree(it)
}
}
reobf {
addExtraSrgFile mixinSrg
}
afterEvaluate {
def fixedRelPathToAP = relativePathToMixinAP
if(fixedRelPathToAP.startsWith('./') || fixedRelPathToAP.startsWith('.\\')){
fixedRelPathToAP = fixedRelPathToAP.substring(2)
} else if(fixedRelPathToAP.startsWith('/') || fixedRelPathToAP.startsWith('\\')){
fixedRelPathToAP = fixedRelPathToAP.substring(1)
}
tasks.compileJava {
println "Path: " + projectDir.absolutePath
options.compilerArgs += [
// There's a bug in the AnnotationProcessor for 0.7.11 that will generate the annotations pointing to the parent class instead of subclass
// resulting in the mixin not being applied. This is fixed in 0.8, however 0.8 needs guava > 21.0, and minecraft ships with 17.0.
// So as a hacky workaround... ship with 0.7.11, but use the AP from 0.8 for compiling
"-processorpath", projectDir.absolutePath + '/' + fixedRelPathToAP,
"-processor", "org.spongepowered.tools.obfuscation.MixinObfuscationProcessorInjection,org.spongepowered.tools.obfuscation.MixinObfuscationProcessorTargets",
"-Xlint:-sunapi", "-XDenableSunApiLintControl", "-XDignore.symbol.file",
"-AreobfSrgFile=${tasks.reobf.srg}", "-AoutSrgFile=${mixinSrg}", "-AoutRefMapFile=${refMap}"
]
}
}
sourceSets {
main {
ext.refMap = refMapForYourConfig
}
}
+1 -1
View File
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+1 -1
View File
@@ -34,7 +34,7 @@ import java.util.ArrayList;
import java.util.Set;
import java.util.UUID;
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.6.1")
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.6.2")
public class CustomNpcs {
@ConfigProp(info = "Disable Chat Bubbles")
+1 -2
View File
@@ -32,8 +32,7 @@ public class DataAI {
public EnumNavType tacticalVariant = EnumNavType.Default;
public int useRangeMelee = 0;
public int tacticalRadius = 8;
// Fly Change
public int movementType = 0;
public double flySpeed = 1.0D;
public double flyGravity = 0.0D;
@@ -139,6 +139,7 @@ public class DataDisplay {
if (!nbttagcompound.hasKey("SkinOverlayData") && !glowTexture.isEmpty()) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("SkinOverlayID", 0); //unique glow texture ID
(new SkinOverlay(glowTexture)).writeToNBT(compound);
if (!nbttagcompound.hasKey("SkinOverlayData")) {
@@ -330,6 +330,9 @@ public class NoppesUtilPlayer {
Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT());
}
public static void questCompletion(EntityPlayerMP player, int questId) {
if(player == null)
return;
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = playerData.questData;
QuestData data = questData.activeQuests.get(questId);
@@ -349,7 +352,10 @@ public class NoppesUtilPlayer {
while(var8.hasNext()) {
ItemStack item = (ItemStack)var8.next();
if (item.stackSize > 0) {
list.add(NpcAPI.Instance().getIItemStack(item));
IItemStack iStack = NpcAPI.Instance().getIItemStack(item);
if (iStack != null){
list.add(iStack);
}
}
}
@@ -146,6 +146,9 @@ public class PacketHandlerServer{
String trackedQuestString = Server.readString(buffer);
if (trackedQuestString != null && trackedQuestString.contains(":")) {
String[] splitString = trackedQuestString.split(":");
if(splitString.length < 2){
return;
}
String categoryName = splitString[0];
String questName = splitString[1];
@@ -1,5 +1,6 @@
package noppes.npcs;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -297,7 +298,8 @@ public class ServerEventsHandler {
boolean change = false;
String entityName = EntityList.getEntityString(entity);
for(QuestData data : questData.activeQuests.values()){
ArrayList<QuestData> activeQuestValues = new ArrayList<>(questData.activeQuests.values());
for(QuestData data : activeQuestValues){
if(data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
continue;
if(data.quest.type == EnumQuestType.AreaKill && all){
@@ -50,7 +50,7 @@ public class EntityAIWander extends EntityAIBase
else{
this.xPosition = vec.xCoord;
this.yPosition = vec.yCoord;
// FLY CHANGE
if(entity.canFly())
this.yPosition = entity.getStartYPos() + entity.getRNG().nextFloat() * 0.75 * entity.ai.walkingRange;
this.zPosition = vec.zCoord;
@@ -1,73 +0,0 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import noppes.npcs.entity.EntityNPCInterface;
public class FlyNodeProcessor extends NodeProcessor{
public PathPoint getPathPointTo(Entity p_176161_1_)
{
return this.openPoint(MathHelper.floor_double(p_176161_1_.boundingBox.minX), MathHelper.floor_double(p_176161_1_.boundingBox.minY + 0.5D), MathHelper.floor_double(p_176161_1_.boundingBox.minZ));
}
public PathPoint getPathPointToCoords(Entity p_176160_1_, double p_176160_2_, double p_176160_4_, double p_176160_6_)
{
return this.openPoint(MathHelper.floor_double(p_176160_2_ - (double)(p_176160_1_.width / 2.0F)), MathHelper.floor_double(p_176160_4_ + 0.5D), MathHelper.floor_double(p_176160_6_ - (double)(p_176160_1_.width / 2.0F)));
}
public int findPathOptions(PathPoint[] p_176164_1_, Entity p_176164_2_, PathPoint p_176164_3_, PathPoint p_176164_4_, float p_176164_5_)
{
int i = 0;
EnumFacing[] aenumfacing = EnumFacing.values();
int j = aenumfacing.length;
for (int k = 0; k < j; ++k)
{
EnumFacing enumfacing = aenumfacing[k];
PathPoint pathpoint2 = this.getSafePoint(p_176164_2_, p_176164_3_.xCoord + enumfacing.getFrontOffsetX(), p_176164_3_.yCoord + enumfacing.getFrontOffsetY(), p_176164_3_.zCoord + enumfacing.getFrontOffsetZ());
if (pathpoint2 != null && !pathpoint2.isFirst && pathpoint2.distanceTo(p_176164_4_) < p_176164_5_)
{
p_176164_1_[i++] = pathpoint2;
}
}
return i;
}
private PathPoint getSafePoint(Entity p_176185_1_, int p_176185_2_, int p_176185_3_, int p_176185_4_)
{
int l = this.func_176186_b(p_176185_1_, p_176185_2_, p_176185_3_, p_176185_4_);
return l == -1 ? this.openPoint(p_176185_2_, p_176185_3_, p_176185_4_) : null;
}
private int func_176186_b(Entity entityIn, int x, int y, int z)
{
for (int i = x; i < x + this.entitySizeX; ++i)
{
for (int j = y; j < y + this.entitySizeY; ++j)
{
for (int k = z; k < z + this.entitySizeZ; ++k)
{
Block block = this.blockaccess.getBlock(i, j, k);
if(block.getMaterial() == Material.water && entityIn instanceof EntityNPCInterface && ((EntityNPCInterface)entityIn).ai.canSwim)
continue;
if (block.getMaterial() != Material.air)
{
return 0;
}
}
}
}
return -1;
}
}
@@ -6,8 +6,6 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import noppes.npcs.entity.EntityNPCInterface;
// Fly Change
public class FlyingMoveHelper extends EntityMoveHelper{
private final EntityNPCInterface entity;
@@ -37,6 +35,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{
double d2 = this.posZ - this.entity.posZ;
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
double d5 = MathHelper.sqrt_double(d4);
speed = Math.min(d5/5.0D,speed);
double heightOffGround = 0;
if(this.entity.ai.hasFlyLimit) {
@@ -1,146 +0,0 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.Path;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
public class NPCPathFinder extends PathFinder
{
public IBlockAccess worldMap;
public Path path = new Path();
public NPCPathPoint[] pathOptions = new NPCPathPoint[32];
private final NodeProcessor nodeProcessor;
public NPCPathFinder(NodeProcessor nodeProcessorIn)
{
super(nodeProcessorIn.blockaccess, true, true, false, false);
this.nodeProcessor = nodeProcessorIn;
}
/**
* Creates a path from one entity to another within a minimum distance
*/
public PathEntity createEntityPathTo(Entity p_75856_1_, Entity p_75856_2_, float p_75856_3_)
{
return this.createEntityPathTo(p_75856_1_, p_75856_2_.posX, p_75856_2_.boundingBox.minY, p_75856_2_.posZ, p_75856_3_);
}
/**
* Creates a path from an entity to a specified location within a minimum distance
*/
public PathEntity createEntityPathTo(Entity p_75859_1_, int p_75859_2_, int p_75859_3_, int p_75859_4_, float p_75859_5_)
{
return this.createEntityPathTo(p_75859_1_, (double)((float)p_75859_2_ + 0.5F), (double)((float)p_75859_3_ + 0.5F), (double)((float)p_75859_4_ + 0.5F), p_75859_5_);
}
/**
* Internal implementation of creating a path from an entity to a point
*/
public PathEntity createEntityPathTo(Entity p_75857_1_, double p_75857_2_, double p_75857_4_, double p_75857_6_, float p_75857_8_)
{
this.path.clearPath();
this.nodeProcessor.initProcessor(worldMap, p_75857_1_);
NPCPathPoint pathpoint = (NPCPathPoint) this.nodeProcessor.getPathPointTo(p_75857_1_);
NPCPathPoint pathpoint1 = (NPCPathPoint) this.nodeProcessor.getPathPointToCoords(p_75857_1_, p_75857_2_, p_75857_4_, p_75857_6_);
PathEntity pathentity = this.addToPath(p_75857_1_, pathpoint, pathpoint1, p_75857_8_);
this.nodeProcessor.postProcess();
return pathentity;
}
public PathEntity addToPath(Entity entityIn, NPCPathPoint pathpointStart, NPCPathPoint pathpointEnd, float maxDistance)
{
pathpointStart.totalPathDistance = 0.0F;
pathpointStart.distanceToNext = pathpointStart.distanceToSquared(pathpointEnd);
pathpointStart.distanceToTarget = pathpointStart.distanceToNext;
this.path.clearPath();
this.path.addPoint(pathpointStart);
NPCPathPoint pathpoint = pathpointStart;
while (!this.path.isPathEmpty())
{
NPCPathPoint pathpoint1 = (NPCPathPoint) this.path.dequeue();
if (pathpoint1.equals(pathpointEnd))
{
return this.createEntityPath(pathpointStart, pathpointEnd);
}
if (pathpoint1.distanceToSquared(pathpointEnd) < pathpoint.distanceToSquared(pathpointEnd))
{
pathpoint = pathpoint1;
}
pathpoint1.isFirst = true;
int i = this.nodeProcessor.findPathOptions(this.pathOptions, entityIn, pathpoint1, pathpointEnd, maxDistance);
for (int j = 0; j < i; ++j)
{
NPCPathPoint pathpoint2 = (NPCPathPoint) this.pathOptions[j];
float f = pathpoint1.totalPathDistance + pathpoint1.distanceToSquared(pathpoint2);
if (f < maxDistance * 2.0F && (!pathpoint2.isAssigned() || f < pathpoint2.totalPathDistance))
{
pathpoint2.previous = pathpoint1;
pathpoint2.totalPathDistance = f;
pathpoint2.distanceToNext = pathpoint2.distanceToSquared(pathpointEnd);
if (pathpoint2.isAssigned())
{
this.path.changeDistance(pathpoint2, pathpoint2.totalPathDistance + pathpoint2.distanceToNext);
}
else
{
pathpoint2.distanceToTarget = pathpoint2.totalPathDistance + pathpoint2.distanceToNext;
this.path.addPoint(pathpoint2);
}
}
}
}
if (pathpoint == pathpointStart)
{
return null;
}
else
{
return this.createEntityPath(pathpointStart, pathpoint);
}
}
/**
* Returns a new PathEntity for a given start and end point
*/
private PathEntity createEntityPath(NPCPathPoint p_75853_1_, NPCPathPoint p_75853_2_)
{
int i = 1;
NPCPathPoint pathpoint2;
for (pathpoint2 = p_75853_2_; pathpoint2.previous != null; pathpoint2 = (NPCPathPoint) pathpoint2.previous)
{
++i;
}
NPCPathPoint[] apathpoint = new NPCPathPoint[i];
pathpoint2 = p_75853_2_;
--i;
for (apathpoint[i] = p_75853_2_; pathpoint2.previous != null; apathpoint[i] = pathpoint2)
{
pathpoint2 = (NPCPathPoint) pathpoint2.previous;
--i;
}
return new PathEntity(apathpoint);
}
}
@@ -1,23 +0,0 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
public class NPCPathPoint extends PathPoint
{
/** The index of this point in its assigned path */
public int index = -1;
/** The distance along the path to this point */
public float totalPathDistance;
/** The linear distance to the next point */
public float distanceToNext;
/** The distance to the target */
public float distanceToTarget;
public PathPoint previous;
public NPCPathPoint(int p_i2135_1_, int p_i2135_2_, int p_i2135_3_)
{
super(p_i2135_1_, p_i2135_2_,p_i2135_3_);
}
}
@@ -1,50 +0,0 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.entity.Entity;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.IntHashMap;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
public abstract class NodeProcessor
{
public IBlockAccess blockaccess;
public IntHashMap pointMap = new IntHashMap();
public int entitySizeX;
public int entitySizeY;
public int entitySizeZ;
public void initProcessor(IBlockAccess iblockaccessIn, Entity entityIn)
{
this.blockaccess = iblockaccessIn;
this.pointMap.clearMap();
this.entitySizeX = MathHelper.floor_float(entityIn.width + 1.0F);
this.entitySizeY = MathHelper.floor_float(entityIn.height + 1.0F);
this.entitySizeZ = MathHelper.floor_float(entityIn.width + 1.0F);
}
public void postProcess()
{
}
public PathPoint openPoint(int x, int y, int z)
{
int i = NPCPathPoint.makeHash(x, y, z);
NPCPathPoint pathpoint = (NPCPathPoint)this.pointMap.lookup(i);
if (pathpoint == null)
{
pathpoint = new NPCPathPoint(x, y, z);
this.pointMap.addKey(i, pathpoint);
}
return pathpoint;
}
public abstract PathPoint getPathPointTo(Entity entityIn);
public abstract PathPoint getPathPointToCoords(Entity entityIn, double x, double y, double target);
public abstract int findPathOptions(PathPoint[] pathOptions, Entity entityIn, PathPoint currentPoint, PathPoint targetPoint, float maxDistance);
}
@@ -261,7 +261,7 @@ public class PathNavigateFlying extends PathNavigate {
}
}
if (this.totalTicks - this.ticksAtLastPos > 10)
if (this.totalTicks - this.ticksAtLastPos > 100)
{
if (vec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
{
@@ -1,299 +0,0 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import noppes.npcs.util.Vec3NPC;
public class PathNavigateGround extends PathNavigateNPC
{
protected WalkNodeProcessor nodeProcessor;
private boolean shouldAvoidSun;
public PathNavigateGround(EntityLiving entitylivingIn, World worldIn)
{
super(entitylivingIn, worldIn);
}
protected PathFinder getPathFinder()
{
this.nodeProcessor = new WalkNodeProcessor();
this.nodeProcessor.setEnterDoors(true);
return new NPCPathFinder(this.nodeProcessor);
}
/**
* If on ground or swimming and can swim
*/
protected boolean canNavigate()
{
return this.theEntity.onGround || this.getCanSwim() && this.isInLiquid() || this.theEntity.isRiding() && this.theEntity instanceof EntityZombie && this.theEntity.ridingEntity instanceof EntityChicken;
}
protected Vec3 getEntityPosition()
{
return new Vec3NPC(this.theEntity.posX, (double)this.getPathablePosY(), this.theEntity.posZ);
}
/**
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
*/
private int getPathablePosY()
{
if (this.theEntity.isInWater() && this.getCanSwim())
{
int i = (int)this.theEntity.boundingBox.minY;
Block block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
int j = 0;
while (block == Blocks.flowing_water || block == Blocks.water)
{
++i;
block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
++j;
if (j > 16)
{
return (int)this.theEntity.boundingBox.minY;
}
}
return i;
}
else
{
return (int)(this.theEntity.boundingBox.minY + 0.5D);
}
}
/**
* Trims path data from the end to the first sun covered block
*/
protected void removeSunnyPath()
{
super.removeSunnyPath();
if (this.shouldAvoidSun)
{
if (this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ)))
{
return;
}
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
{
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))
{
this.currentPath.setCurrentPathLength(i - 1);
return;
}
}
}
}
/**
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
* pos1, pos2, entityXSize, entityYSize, entityZSize
*/
protected boolean isDirectPathBetweenPoints(Vec3 posVec31, Vec3 posVec32, int sizeX, int sizeY, int sizeZ)
{
int i = MathHelper.floor_double(posVec31.xCoord);
int j = MathHelper.floor_double(posVec31.zCoord);
double d0 = posVec32.xCoord - posVec31.xCoord;
double d1 = posVec32.zCoord - posVec31.zCoord;
double d2 = d0 * d0 + d1 * d1;
if (d2 < 1.0E-8D)
{
return false;
}
else
{
double d3 = 1.0D / Math.sqrt(d2);
d0 = d0 * d3;
d1 = d1 * d3;
sizeX = sizeX + 2;
sizeZ = sizeZ + 2;
if (!this.isSafeToStandAt(i, (int)posVec31.yCoord, j, sizeX, sizeY, sizeZ, posVec31, d0, d1))
{
return false;
}
else
{
sizeX = sizeX - 2;
sizeZ = sizeZ - 2;
double d4 = 1.0D / Math.abs(d0);
double d5 = 1.0D / Math.abs(d1);
double d6 = (double)(i * 1) - posVec31.xCoord;
double d7 = (double)(j * 1) - posVec31.zCoord;
if (d0 >= 0.0D)
{
++d6;
}
if (d1 >= 0.0D)
{
++d7;
}
d6 = d6 / d0;
d7 = d7 / d1;
int k = d0 < 0.0D ? -1 : 1;
int l = d1 < 0.0D ? -1 : 1;
int i1 = MathHelper.floor_double(posVec32.xCoord);
int j1 = MathHelper.floor_double(posVec32.zCoord);
int k1 = i1 - i;
int l1 = j1 - j;
while (k1 * k > 0 || l1 * l > 0)
{
if (d6 < d7)
{
d6 += d4;
i += k;
k1 = i1 - i;
}
else
{
d7 += d5;
j += l;
l1 = j1 - j;
}
if (!this.isSafeToStandAt(i, (int)posVec31.yCoord, j, sizeX, sizeY, sizeZ, posVec31, d0, d1))
{
return false;
}
}
return true;
}
}
}
/**
* Returns true when an entity could stand at a position, including solid blocks under the entire entity.
*/
private boolean isSafeToStandAt(int x, int y, int z, int sizeX, int sizeY, int sizeZ, Vec3 vec31, double p_179683_8_, double p_179683_10_)
{
int i = x - sizeX / 2;
int j = z - sizeZ / 2;
if (!this.isPositionClear(i, y, j, sizeX, sizeY, sizeZ, vec31, p_179683_8_, p_179683_10_))
{
return false;
}
else
{
for (int k = i; k < i + sizeX; ++k)
{
for (int l = j; l < j + sizeZ; ++l)
{
double d0 = (double)k + 0.5D - vec31.xCoord;
double d1 = (double)l + 0.5D - vec31.zCoord;
if (d0 * p_179683_8_ + d1 * p_179683_10_ >= 0.0D)
{
Block block = this.worldObj.getBlock(k, y - 1, l);
Material material = block.getMaterial();
if (material == Material.air)
{
return false;
}
if (material == Material.water && !this.theEntity.isInWater())
{
return false;
}
if (material == Material.lava)
{
return false;
}
}
}
}
return true;
}
}
/**
* Returns true if an entity does not collide with any solid blocks at the position.
*/
private boolean isPositionClear(int p_179692_1_, int p_179692_2_, int p_179692_3_, int p_179692_4_, int p_179692_5_, int p_179692_6_, Vec3 p_179692_7_, double p_179692_8_, double p_179692_10_)
{
for (BlockPos blockpos : BlockPos.getAllInBox(new BlockPos(p_179692_1_, p_179692_2_, p_179692_3_), new BlockPos(p_179692_1_ + p_179692_4_ - 1, p_179692_2_ + p_179692_5_ - 1, p_179692_3_ + p_179692_6_ - 1)))
{
double d0 = (double)blockpos.getX() + 0.5D - p_179692_7_.xCoord;
double d1 = (double)blockpos.getZ() + 0.5D - p_179692_7_.zCoord;
if (d0 * p_179692_8_ + d1 * p_179692_10_ >= 0.0D)
{
Block block = this.worldObj.getBlock(blockpos.getX(), blockpos.getY(), blockpos.getZ());
if (!block.getBlocksMovement(this.worldObj, blockpos.getX(), blockpos.getY(), blockpos.getZ()))
{
return false;
}
}
}
return true;
}
public void setAvoidsWater(boolean avoidsWater)
{
this.nodeProcessor.setAvoidsWater(avoidsWater);
}
public boolean getAvoidsWater()
{
return this.nodeProcessor.getAvoidsWater();
}
public void setBreakDoors(boolean canBreakDoors)
{
this.nodeProcessor.setBreakDoors(canBreakDoors);
}
public void setEnterDoors(boolean par1)
{
this.nodeProcessor.setEnterDoors(par1);
}
public boolean getEnterDoors()
{
return this.nodeProcessor.getEnterDoors();
}
public void setCanSwim(boolean canSwim)
{
this.nodeProcessor.setCanSwim(canSwim);
}
public boolean getCanSwim()
{
return this.nodeProcessor.getCanSwim();
}
public void setAvoidSun(boolean par1)
{
this.shouldAvoidSun = par1;
}
}
@@ -1,88 +0,0 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class PathNavigateNPC extends PathNavigate
{
protected EntityLiving theEntity;
protected World worldObj;
/** The PathEntity being followed. */
protected PathEntity currentPath;
/** Time, in number of ticks, following the current path */
protected int totalTicks;
/** The time when the last position check was done (to detect successful movement) */
protected int ticksAtLastPos;
/** Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck') */
protected Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
public PathNavigateNPC(EntityLiving p_i1671_1_, World p_i1671_2_)
{
super(p_i1671_1_, p_i1671_2_);
this.theEntity = p_i1671_1_;
this.worldObj = p_i1671_2_;
}
/** Gets Current Path of NPC **/
public PathEntity getPath()
{
return this.currentPath;
}
/** Returns true if the entity is in water or lava, false otherwise **/
protected boolean isInLiquid()
{
return this.theEntity.isInWater() || this.theEntity.handleLavaMovement();
}
/** Trims path data from the end to the first sun covered block **/
protected void removeSunnyPath()
{
if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ)))
{
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
{
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))
{
this.currentPath.setCurrentPathLength(i - 1);
return;
}
}
}
}
/**
* Checks if entity haven't been moved when last checked and if so, clears current {@link
* net.minecraft.pathfinding.PathEntity}
*/
protected void checkForStuck(Vec3 positionVec3)
{
if (this.totalTicks - this.ticksAtLastPos > 100)
{
if (positionVec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
{
this.clearPathEntity();
}
this.ticksAtLastPos = this.totalTicks;
this.lastPosCheck = positionVec3;
}
}
}
@@ -1,80 +0,0 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.entity.EntityLiving;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import noppes.npcs.ai.pathfinder.NPCPathFinder;
import noppes.npcs.ai.pathfinder.PathNavigateNPC;
import noppes.npcs.ai.pathfinder.SwimNodeProcessor;
import noppes.npcs.util.Vec3NPC;
public class PathNavigateSwimmer extends PathNavigateNPC
{
public PathNavigateSwimmer(EntityLiving entitylivingIn, World worldIn)
{
super(entitylivingIn, worldIn);
}
protected PathFinder getPathFinder()
{
return new NPCPathFinder(new SwimNodeProcessor());
}
/**
* If on ground or swimming and can swim
*/
protected boolean canNavigate()
{
return this.isInLiquid();
}
protected Vec3 getEntityPosition()
{
return new Vec3NPC(this.theEntity.posX, this.theEntity.posY + (double)this.theEntity.height * 0.5D, this.theEntity.posZ);
}
protected void pathFollow()
{
Vec3 vec3 = this.getEntityPosition();
float f = this.theEntity.width * this.theEntity.width;
int i = 6;
if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, this.currentPath.getCurrentPathIndex())) < (double)f)
{
this.currentPath.incrementPathIndex();
}
for (int j = Math.min(this.currentPath.getCurrentPathIndex() + i, this.currentPath.getCurrentPathLength() - 1); j > this.currentPath.getCurrentPathIndex(); --j)
{
Vec3 vec31 = this.currentPath.getVectorFromIndex(this.theEntity, j);
if (vec31.squareDistanceTo(vec3) <= 36.0D && this.isDirectPathBetweenPoints(vec3, vec31, 0, 0, 0))
{
this.currentPath.setCurrentPathIndex(j);
break;
}
}
this.checkForStuck(vec3);
}
/**
* Trims path data from the end to the first sun covered block
*/
protected void removeSunnyPath()
{
super.removeSunnyPath();
}
/**
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
* pos1, pos2, entityXSize, entityYSize, entityZSize
*/
protected boolean isDirectPathBetweenPoints(Vec3 posVec31, Vec3 posVec32, int sizeX, int sizeY, int sizeZ)
{
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(posVec31, new Vec3NPC(posVec32.xCoord, posVec32.yCoord + (double)this.theEntity.height * 0.5D, posVec32.zCoord), false, true, false);
return movingobjectposition == null || movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.MISS;
}
}
@@ -1,93 +0,0 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
public class SwimNodeProcessor extends NodeProcessor
{
public void initProcessor(IBlockAccess iblockaccessIn, Entity entityIn)
{
super.initProcessor(iblockaccessIn, entityIn);
}
/**
* This method is called when all nodes have been processed and PathEntity is created.
* {@link net.minecraft.world.pathfinder.WalkNodeProcessor WalkNodeProcessor} uses this to change its field {@link
* net.minecraft.world.pathfinder.WalkNodeProcessor#avoidsWater avoidsWater}
*/
public void postProcess()
{
super.postProcess();
}
/**
* Returns given entity's position as PathPoint
*/
public PathPoint getPathPointTo(Entity entityIn)
{
return this.openPoint(MathHelper.floor_double(entityIn.boundingBox.minX), MathHelper.floor_double(entityIn.boundingBox.minY + 0.5D), MathHelper.floor_double(entityIn.boundingBox.minZ));
}
/**
* Returns PathPoint for given coordinates
*/
public PathPoint getPathPointToCoords(Entity entityIn, double x, double y, double target)
{
return this.openPoint(MathHelper.floor_double(x - (double)(entityIn.width / 2.0F)), MathHelper.floor_double(y + 0.5D), MathHelper.floor_double(target - (double)(entityIn.width / 2.0F)));
}
public int findPathOptions(PathPoint[] pathOptions, Entity entityIn, PathPoint currentPoint, PathPoint targetPoint, float maxDistance)
{
int i = 0;
for (EnumFacing enumfacing : EnumFacing.values())
{
PathPoint pathpoint = this.getSafePoint(entityIn, currentPoint.xCoord + enumfacing.getFrontOffsetX(), currentPoint.yCoord + enumfacing.getFrontOffsetY(), currentPoint.zCoord + enumfacing.getFrontOffsetZ());
if (pathpoint != null && !pathpoint.isFirst && pathpoint.distanceTo(targetPoint) < maxDistance)
{
pathOptions[i++] = pathpoint;
}
}
return i;
}
/**
* Returns a point that the entity can safely move to
*/
private PathPoint getSafePoint(Entity entityIn, int x, int y, int z)
{
int i = this.func_176186_b(entityIn, x, y, z);
return i == -1 ? this.openPoint(x, y, z) : null;
}
private int func_176186_b(Entity entityIn, int x, int y, int z)
{
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int i = x; i < x + this.entitySizeX; ++i)
{
for (int j = y; j < y + this.entitySizeY; ++j)
{
for (int k = z; k < z + this.entitySizeZ; ++k)
{
Block block = this.blockaccess.getBlock(i, j, k);
if (block.getMaterial() != Material.water)
{
return 0;
}
}
}
}
return -1;
}
}
@@ -1,303 +0,0 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
public class WalkNodeProcessor extends NodeProcessor
{
private boolean canEnterDoors;
private boolean canBreakDoors;
private boolean avoidsWater;
private boolean canSwim;
private boolean shouldAvoidWater;
public void initProcessor(IBlockAccess iblockaccessIn, Entity entityIn)
{
super.initProcessor(iblockaccessIn, entityIn);
this.shouldAvoidWater = this.avoidsWater;
}
/**
* This method is called when all nodes have been processed and PathEntity is created.
* {@link noppes.npcs.ai.pathfinder.WalkNodeProcessor WalkNodeProcessor} uses this to change its field {@link
* noppes.npcs.ai.pathfinder.WalkNodeProcessor#avoidsWater avoidsWater}
*/
public void postProcess()
{
super.postProcess();
this.avoidsWater = this.shouldAvoidWater;
}
/**
* Returns given entity's position as PathPoint
*/
public PathPoint getPathPointTo(Entity entityIn)
{
int i;
if (this.canSwim && entityIn.isInWater())
{
i = (int)entityIn.boundingBox.minY;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor_double(entityIn.posX), i, MathHelper.floor_double(entityIn.posZ));
for (Block block = this.blockaccess.getBlock(blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ()); block == Blocks.flowing_water || block == Blocks.water; block = this.blockaccess.getBlock(blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ()))
{
++i;
blockpos$mutableblockpos.set(MathHelper.floor_double(entityIn.posX), i, MathHelper.floor_double(entityIn.posZ));
}
this.avoidsWater = false;
}
else
{
i = MathHelper.floor_double(entityIn.boundingBox.minY + 0.5D);
}
return this.openPoint(MathHelper.floor_double(entityIn.boundingBox.minX), i, MathHelper.floor_double(entityIn.boundingBox.minZ));
}
/**
* Returns PathPoint for given coordinates
*/
public PathPoint getPathPointToCoords(Entity entityIn, double x, double y, double target)
{
return this.openPoint(MathHelper.floor_double(x - (double)(entityIn.width / 2.0F)), MathHelper.floor_double(y), MathHelper.floor_double(target - (double)(entityIn.width / 2.0F)));
}
public int findPathOptions(PathPoint[] pathOptions, Entity entityIn, PathPoint currentPoint, PathPoint targetPoint, float maxDistance)
{
int i = 0;
int j = 0;
if (this.getVerticalOffset(entityIn, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord) == 1)
{
j = 1;
}
PathPoint pathpoint = this.getSafePoint(entityIn, currentPoint.xCoord, currentPoint.yCoord, currentPoint.zCoord + 1, j);
PathPoint pathpoint1 = this.getSafePoint(entityIn, currentPoint.xCoord - 1, currentPoint.yCoord, currentPoint.zCoord, j);
PathPoint pathpoint2 = this.getSafePoint(entityIn, currentPoint.xCoord + 1, currentPoint.yCoord, currentPoint.zCoord, j);
PathPoint pathpoint3 = this.getSafePoint(entityIn, currentPoint.xCoord, currentPoint.yCoord, currentPoint.zCoord - 1, j);
if (pathpoint != null && !pathpoint.isFirst && pathpoint.distanceTo(targetPoint) < maxDistance)
{
pathOptions[i++] = pathpoint;
}
if (pathpoint1 != null && !pathpoint1.isFirst && pathpoint1.distanceTo(targetPoint) < maxDistance)
{
pathOptions[i++] = pathpoint1;
}
if (pathpoint2 != null && !pathpoint2.isFirst && pathpoint2.distanceTo(targetPoint) < maxDistance)
{
pathOptions[i++] = pathpoint2;
}
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(targetPoint) < maxDistance)
{
pathOptions[i++] = pathpoint3;
}
return i;
}
/**
* Returns a point that the entity can safely move to
*/
private PathPoint getSafePoint(Entity entityIn, int x, int y, int z, int p_176171_5_)
{
PathPoint pathpoint = null;
int i = this.getVerticalOffset(entityIn, x, y, z);
if (i == 2)
{
return this.openPoint(x, y, z);
}
else
{
if (i == 1)
{
pathpoint = this.openPoint(x, y, z);
}
if (pathpoint == null && p_176171_5_ > 0 && i != -3 && i != -4 && this.getVerticalOffset(entityIn, x, y + p_176171_5_, z) == 1)
{
pathpoint = this.openPoint(x, y + p_176171_5_, z);
y += p_176171_5_;
}
if (pathpoint != null)
{
int j = 0;
int k;
for (k = 0; y > 0; pathpoint = this.openPoint(x, y, z))
{
k = this.getVerticalOffset(entityIn, x, y - 1, z);
if (this.avoidsWater && k == -1)
{
return null;
}
if (k != 1)
{
break;
}
if (j++ >= entityIn.getMaxSafePointTries())
{
return null;
}
--y;
if (y <= 0)
{
return null;
}
}
if (k == -2)
{
return null;
}
}
return pathpoint;
}
}
/**
* Checks if an entity collides with blocks at a position.
* Returns 1 if clear, 0 for colliding with any solid block, -1 for water(if avoids water),
* -2 for lava, -3 for fence and wall, -4 for closed trapdoor, 2 if otherwise clear except for open trapdoor or
* water(if not avoiding)
*/
private int getVerticalOffset(Entity entityIn, int x, int y, int z)
{
return func_176170_a(this.blockaccess, entityIn, x, y, z, this.entitySizeX, this.entitySizeY, this.entitySizeZ, this.avoidsWater, this.canBreakDoors, this.canEnterDoors);
}
public static int func_176170_a(IBlockAccess blockaccessIn, Entity entityIn, int x, int y, int z, int sizeX, int sizeY, int sizeZ, boolean avoidWater, boolean breakDoors, boolean enterDoors)
{
boolean flag = false;
BlockPos blockpos = new BlockPos(entityIn);
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int i = x; i < x + sizeX; ++i)
{
for (int j = y; j < y + sizeY; ++j)
{
for (int k = z; k < z + sizeZ; ++k)
{
blockpos$mutableblockpos.set(i, j, k);
Block block = blockaccessIn.getBlock(blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ());
if (block.getMaterial() != Material.air)
{
if (block != Blocks.trapdoor)
{
if (block != Blocks.flowing_water && block != Blocks.water)
{
if (!enterDoors && block instanceof BlockDoor && block.getMaterial() == Material.wood)
{
return 0;
}
}
else
{
if (avoidWater)
{
return -1;
}
flag = true;
}
}
else
{
flag = true;
}
if (entityIn.worldObj.getBlock(blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ()) instanceof BlockRailBase)
{
if (!(entityIn.worldObj.getBlock(blockpos.getX(), blockpos.getY(), blockpos.getZ()) instanceof BlockRailBase) && !(entityIn.worldObj.getBlock(blockpos.down().getX(), blockpos.down().getY(), blockpos.down().getZ()) instanceof BlockRailBase))
{
return -3;
}
}
else if (!block.getBlocksMovement(blockaccessIn, blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ()) && (!breakDoors || !(block instanceof BlockDoor) || block.getMaterial() != Material.wood))
{
if (block instanceof BlockFence || block instanceof BlockFenceGate || block instanceof BlockWall)
{
return -3;
}
if (block == Blocks.trapdoor)
{
return -4;
}
Material material = block.getMaterial();
if (material != Material.lava)
{
return 0;
}
if (!entityIn.handleLavaMovement())
{
return -2;
}
}
}
}
}
}
return flag ? 2 : 1;
}
public void setEnterDoors(boolean canEnterDoorsIn)
{
this.canEnterDoors = canEnterDoorsIn;
}
public void setBreakDoors(boolean canBreakDoorsIn)
{
this.canBreakDoors = canBreakDoorsIn;
}
public void setAvoidsWater(boolean avoidsWaterIn)
{
this.avoidsWater = avoidsWaterIn;
}
public void setCanSwim(boolean canSwimIn)
{
this.canSwim = canSwimIn;
}
public boolean getEnterDoors()
{
return this.canEnterDoors;
}
public boolean getCanSwim()
{
return this.canSwim;
}
public boolean getAvoidsWater()
{
return this.avoidsWater;
}
}
@@ -46,7 +46,9 @@ public class TileWaypoint extends TileEntity {
for(EntityPlayer player : toCheck){
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = playerData.questData;
for(QuestData data : questData.activeQuests.values()){
ArrayList<QuestData> activeQuestValues = new ArrayList<>(questData.activeQuests.values());
for(QuestData data : activeQuestValues){
if(data.quest.type != EnumQuestType.Location)
continue;
QuestLocation quest = (QuestLocation) data.quest.questInterface;
@@ -19,9 +19,7 @@ import noppes.npcs.controllers.data.SkinOverlay;
public class Client {
public static OverlayQuestTracking questTrackingOverlay = null;
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
public static HashMap<UUID, Long> entitySkinOverlayTicks = new HashMap<>();
public static void sendData(EnumPacketServer enu, Object... obs) {
ByteBuf buffer = Unpooled.buffer();
@@ -1,7 +1,6 @@
package noppes.npcs.client;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.player.EntityPlayer;
@@ -11,15 +10,15 @@ import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.renderer.RenderCNPCPlayer;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class ClientEventHandler {
private final RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer();
public static final RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer();
public static HashMap<Integer,Long> disabledButtonTimes = new HashMap<>();
public static float partialHandTicks;
@SubscribeEvent
public void onMouse(MouseEvent event) {
@@ -105,29 +104,12 @@ public class ClientEventHandler {
}
}
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
Minecraft mc = Minecraft.getMinecraft();
if (hasOverlays(mc.thePlayer)) {
if (mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused() && event.phase == TickEvent.Phase.END) {
renderCNPCPlayer.itemRenderer.updateEquippedItem();
renderCNPCPlayer.updateFovModifierHand();
}
}
}
@SubscribeEvent
public void onRenderHand(RenderHandEvent event) {
if (hasOverlays(Minecraft.getMinecraft().thePlayer)) {
GL11.glPushMatrix();
event.setCanceled(true);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
renderCNPCPlayer.renderHand(event.partialTicks, event.renderPass);
GL11.glPopMatrix();
}
partialHandTicks = event.partialTicks;
}
private boolean hasOverlays(EntityPlayer player) {
public static boolean hasOverlays(EntityPlayer player) {
return Client.skinOverlays.containsKey(player.getUniqueID()) && Client.skinOverlays.get(player.getUniqueID()).values().size() > 0;
}
}
@@ -18,6 +18,8 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import static noppes.npcs.client.ClientEventHandler.renderCNPCPlayer;
public class ClientTickHandler{
private World prevWorld;
private boolean otherContainer = false;
@@ -27,9 +29,13 @@ public class ClientTickHandler{
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onClientTick(TickEvent.ClientTickEvent event){
if(event.phase == Phase.END)
return;
Minecraft mc = Minecraft.getMinecraft();
if(event.phase == Phase.END) {
if (mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused() && ClientEventHandler.hasOverlays(mc.thePlayer)) {
renderCNPCPlayer.itemRenderer.updateEquippedItem();
}
return;
}
if(mc.thePlayer != null && mc.thePlayer.openContainer instanceof ContainerPlayer){
if(otherContainer){
NoppesUtilPlayer.sendData(EnumPlayerPacket.CheckQuestCompletion);
@@ -29,7 +29,6 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
this.addLabel(new GuiNpcLabel(0, "movement.type", guiLeft + 4, y + 5));
this.addButton(new GuiNpcButton(0, guiLeft + 80, y, 100, 20, EnumMovingType.names(), ai.movingType.ordinal()));
// Fly Change
this.addButton(new GuiNpcButton(15, guiLeft + 80, y += 22, 100, 20, new String[]{"movement.ground","movement.flying"}, ai.movementType));
if(ai.movementType == 1){
@@ -87,10 +87,13 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
calculateRowHeight();
this.scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
this.drawDefaultBackground = dialog.darkenScreen;
optionStart = scaledResolution.getScaledHeight() - (options.size()) * (ClientProxy.Font.height() + dialog.optionSpaceY) - 20;
setOptionOffset();
}
public void setOptionOffset() {
optionStart = scaledResolution.getScaledHeight() - (options.size()) * (ClientProxy.Font.height() + dialog.optionSpaceY) - 20;
}
public void grabMouse(boolean grab){
if(grab && !isGrabbed){
Minecraft.getMinecraft().mouseHelper.grabMouseCursor();
@@ -154,6 +157,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
super.drawScreen(i, j, f);
setOptionOffset();
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
@@ -602,7 +606,6 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
textPauseTime = 0;
NoppesUtil.clickSound();
}
private void closed(){
grabMouse(false);
@@ -850,8 +850,6 @@ public class ModelMPM extends ModelNPCMale{
GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
GL11.glColor4f(1, 1, 1, alpha);
super.renderCloak(0.0625F);
GL11.glPopMatrix();
}
@@ -1,41 +1,21 @@
package noppes.npcs.client.renderer;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.*;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.MapData;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*;
public class RenderCNPCHand extends ItemRenderer {
private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
private static final ResourceLocation RES_MAP_BACKGROUND = new ResourceLocation("textures/map/map_background.png");
private static final ResourceLocation RES_UNDERWATER_OVERLAY = new ResourceLocation("textures/misc/underwater.png");
/** A reference to the Minecraft object. */
private Minecraft mc;
private ItemStack itemToRender;
/** How far the current item has been equipped (0 disequipped and 1 fully up) */
private float equippedProgress;
private float prevEquippedProgress;
private RenderBlocks renderBlocksIr = new RenderBlocks();
/** The index of the currently held item (0-8, or -1 if not yet updated) */
private int equippedItemSlot = -1;
@@ -44,207 +24,10 @@ public class RenderCNPCHand extends ItemRenderer {
this.mc = mc;
}
public void renderItem(EntityLivingBase p_78443_1_, ItemStack p_78443_2_, int p_78443_3_)
{
this.renderItem(p_78443_1_, p_78443_2_, p_78443_3_, EQUIPPED);
}
public void renderItem(EntityLivingBase p_78443_1_, ItemStack p_78443_2_, int p_78443_3_, IItemRenderer.ItemRenderType type)
{
GL11.glPushMatrix();
TextureManager texturemanager = this.mc.getTextureManager();
Item item = p_78443_2_.getItem();
Block block = Block.getBlockFromItem(item);
if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0)
{
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_CULL_FACE);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
}
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(p_78443_2_, type);
if (customRenderer != null)
{
texturemanager.bindTexture(texturemanager.getResourceLocation(p_78443_2_.getItemSpriteNumber()));
ForgeHooksClient.renderEquippedItem(type, customRenderer, renderBlocksIr, p_78443_1_, p_78443_2_);
}
else
if (p_78443_2_.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType()))
{
texturemanager.bindTexture(texturemanager.getResourceLocation(0));
if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0)
{
GL11.glDepthMask(false);
this.renderBlocksIr.renderBlockAsItem(block, p_78443_2_.getItemDamage(), 1.0F);
GL11.glDepthMask(true);
}
else
{
this.renderBlocksIr.renderBlockAsItem(block, p_78443_2_.getItemDamage(), 1.0F);
}
}
else
{
IIcon iicon = p_78443_1_.getItemIcon(p_78443_2_, p_78443_3_);
if (iicon == null)
{
GL11.glPopMatrix();
return;
}
texturemanager.bindTexture(texturemanager.getResourceLocation(p_78443_2_.getItemSpriteNumber()));
TextureUtil.func_152777_a(false, false, 1.0F);
Tessellator tessellator = Tessellator.instance;
float f = iicon.getMinU();
float f1 = iicon.getMaxU();
float f2 = iicon.getMinV();
float f3 = iicon.getMaxV();
float f4 = 0.0F;
float f5 = 0.3F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glTranslatef(-f4, -f5, 0.0F);
float f6 = 1.5F;
GL11.glScalef(f6, f6, f6);
GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
renderItemIn2D(tessellator, f1, f2, f, f3, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F);
if (p_78443_2_.hasEffect(p_78443_3_))
{
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
texturemanager.bindTexture(RES_ITEM_GLINT);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(768, 1, 1, 0);
float f7 = 0.76F;
GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
float f8 = 0.125F;
GL11.glScalef(f8, f8, f8);
float f9 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
GL11.glTranslatef(f9, 0.0F, 0.0F);
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glScalef(f8, f8, f8);
f9 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
GL11.glTranslatef(-f9, 0.0F, 0.0F);
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
texturemanager.bindTexture(texturemanager.getResourceLocation(p_78443_2_.getItemSpriteNumber()));
TextureUtil.func_147945_b();
}
if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0)
{
GL11.glDisable(GL11.GL_BLEND);
}
GL11.glPopMatrix();
}
/**
* Renders an item held in hand as a 2D texture with thickness
*/
public static void renderItemIn2D(Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int p_78439_5_, int p_78439_6_, float p_78439_7_)
{
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(0.0F, 0.0F, 1.0F);
p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)p_78439_1_, (double)p_78439_4_);
p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)p_78439_3_, (double)p_78439_4_);
p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)p_78439_3_, (double)p_78439_2_);
p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)p_78439_1_, (double)p_78439_2_);
p_78439_0_.draw();
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(0.0F, 0.0F, -1.0F);
p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_2_);
p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_2_);
p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_4_);
p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_4_);
p_78439_0_.draw();
float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)p_78439_5_;
float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)p_78439_6_;
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(-1.0F, 0.0F, 0.0F);
int k;
float f7;
float f8;
for (k = 0; k < p_78439_5_; ++k)
{
f7 = (float)k / (float)p_78439_5_;
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
p_78439_0_.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_);
p_78439_0_.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)p_78439_4_);
p_78439_0_.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)p_78439_2_);
p_78439_0_.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_);
}
p_78439_0_.draw();
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(1.0F, 0.0F, 0.0F);
float f9;
for (k = 0; k < p_78439_5_; ++k)
{
f7 = (float)k / (float)p_78439_5_;
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
f9 = f7 + 1.0F / (float)p_78439_5_;
p_78439_0_.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_);
p_78439_0_.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)p_78439_2_);
p_78439_0_.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)p_78439_4_);
p_78439_0_.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_);
}
p_78439_0_.draw();
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(0.0F, 1.0F, 0.0F);
for (k = 0; k < p_78439_6_; ++k)
{
f7 = (float)k / (float)p_78439_6_;
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
f9 = f7 + 1.0F / (float)p_78439_6_;
p_78439_0_.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)p_78439_1_, (double)f8);
p_78439_0_.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)p_78439_3_, (double)f8);
p_78439_0_.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8);
p_78439_0_.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8);
}
p_78439_0_.draw();
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(0.0F, -1.0F, 0.0F);
for (k = 0; k < p_78439_6_; ++k)
{
f7 = (float)k / (float)p_78439_6_;
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
p_78439_0_.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)p_78439_3_, (double)f8);
p_78439_0_.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)p_78439_1_, (double)f8);
p_78439_0_.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8);
p_78439_0_.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8);
}
p_78439_0_.draw();
}
/**
* Renders the active item in the player's hand when in first person mode. Args: partialTickTime
*/
public void renderItemInFirstPerson(float partialTickTime)
public void renderOverlayInFirstPerson(float partialTickTime)
{
float f1 = this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTickTime;
EntityClientPlayerMP entityclientplayermp = this.mc.thePlayer;
@@ -254,22 +37,14 @@ public class RenderCNPCHand extends ItemRenderer {
GL11.glRotatef(entityclientplayermp.prevRotationYaw + (entityclientplayermp.rotationYaw - entityclientplayermp.prevRotationYaw) * partialTickTime, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
EntityPlayerSP entityplayersp = (EntityPlayerSP)entityclientplayermp;
float f3 = entityplayersp.prevRenderArmPitch + (entityplayersp.renderArmPitch - entityplayersp.prevRenderArmPitch) * partialTickTime;
float f4 = entityplayersp.prevRenderArmYaw + (entityplayersp.renderArmYaw - entityplayersp.prevRenderArmYaw) * partialTickTime;
float f3 = ((EntityPlayerSP)entityclientplayermp).prevRenderArmPitch + (((EntityPlayerSP)entityclientplayermp).renderArmPitch - ((EntityPlayerSP)entityclientplayermp).prevRenderArmPitch) * partialTickTime;
float f4 = ((EntityPlayerSP)entityclientplayermp).prevRenderArmYaw + (((EntityPlayerSP)entityclientplayermp).renderArmYaw - ((EntityPlayerSP)entityclientplayermp).prevRenderArmYaw) * partialTickTime;
GL11.glRotatef((entityclientplayermp.rotationPitch - f3) * 0.1F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef((entityclientplayermp.rotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F);
ItemStack itemstack = this.itemToRender;
RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer();
if (itemstack != null && itemstack.getItem() instanceof ItemCloth)
{
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
}
int i = this.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ), 0);
int j = i % 65536;
int k = i / 65536;
@@ -279,227 +54,10 @@ public class RenderCNPCHand extends ItemRenderer {
float f6;
float f7;
if (itemstack != null)
{
int l = itemstack.getItem().getColorFromItemStack(itemstack, 0);
f5 = (float)(l >> 16 & 255) / 255.0F;
f6 = (float)(l >> 8 & 255) / 255.0F;
f7 = (float)(l & 255) / 255.0F;
GL11.glColor4f(f5, f6, f7, 1.0F);
}
else
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
float f8;
float f9;
float f10;
float f13;
Render render;
RenderPlayer renderplayer;
if (itemstack != null && itemstack.getItem() instanceof ItemMap)
{
GL11.glPushMatrix();
f13 = 0.8F;
f5 = entityclientplayermp.getSwingProgress(partialTickTime);
f6 = MathHelper.sin(f5 * (float)Math.PI);
f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI);
GL11.glTranslatef(-f7 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.2F, -f6 * 0.2F);
f5 = 1.0F - f2 / 45.0F + 0.1F;
if (f5 < 0.0F)
{
f5 = 0.0F;
}
if (f5 > 1.0F)
{
f5 = 1.0F;
}
f5 = -MathHelper.cos(f5 * (float)Math.PI) * 0.5F + 0.5F;
GL11.glTranslatef(0.0F, 0.0F * f13 - (1.0F - f1) * 1.2F - f5 * 0.5F + 0.04F, -0.9F * f13);
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(f5 * -85.0F, 0.0F, 0.0F, 1.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
this.mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin());
for (int i1 = 0; i1 < 2; ++i1)
{
int j1 = i1 * 2 - 1;
GL11.glPushMatrix();
GL11.glTranslatef(-0.0F, -0.6F, 1.1F * (float)j1);
GL11.glRotatef((float)(-45 * j1), 1.0F, 0.0F, 0.0F);
GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(59.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef((float)(-65 * j1), 0.0F, 1.0F, 0.0F);
render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer);
renderplayer = (RenderPlayer)render;
f10 = 1.0F;
GL11.glScalef(f10, f10, f10);
renderCNPCPlayer.renderFirstPersonArm(this.mc.thePlayer,partialTickTime);
GL11.glPopMatrix();
}
f6 = entityclientplayermp.getSwingProgress(partialTickTime);
f7 = MathHelper.sin(f6 * f6 * (float)Math.PI);
f8 = MathHelper.sin(MathHelper.sqrt_float(f6) * (float)Math.PI);
GL11.glRotatef(-f7 * 20.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-f8 * 20.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-f8 * 80.0F, 1.0F, 0.0F, 0.0F);
f9 = 0.38F;
GL11.glScalef(f9, f9, f9);
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(-1.0F, -1.0F, 0.0F);
f10 = 0.015625F;
GL11.glScalef(f10, f10, f10);
this.mc.getTextureManager().bindTexture(RES_MAP_BACKGROUND);
Tessellator tessellator = Tessellator.instance;
GL11.glNormal3f(0.0F, 0.0F, -1.0F);
tessellator.startDrawingQuads();
byte b0 = 7;
tessellator.addVertexWithUV((double)(0 - b0), (double)(128 + b0), 0.0D, 0.0D, 1.0D);
tessellator.addVertexWithUV((double)(128 + b0), (double)(128 + b0), 0.0D, 1.0D, 1.0D);
tessellator.addVertexWithUV((double)(128 + b0), (double)(0 - b0), 0.0D, 1.0D, 0.0D);
tessellator.addVertexWithUV((double)(0 - b0), (double)(0 - b0), 0.0D, 0.0D, 0.0D);
tessellator.draw();
IItemRenderer custom = MinecraftForgeClient.getItemRenderer(itemstack, FIRST_PERSON_MAP);
MapData mapdata = ((ItemMap)itemstack.getItem()).getMapData(itemstack, this.mc.theWorld);
if (custom == null)
{
if (mapdata != null)
{
this.mc.entityRenderer.getMapItemRenderer().func_148250_a(mapdata, false);
}
}
else
{
custom.renderItem(FIRST_PERSON_MAP, itemstack, mc.thePlayer, mc.getTextureManager(), mapdata);
}
GL11.glPopMatrix();
}
else if (itemstack != null)
{
GL11.glPushMatrix();
f13 = 0.8F;
if (entityclientplayermp.getItemInUseCount() > 0)
{
EnumAction enumaction = itemstack.getItemUseAction();
if (enumaction == EnumAction.eat || enumaction == EnumAction.drink)
{
f6 = (float)entityclientplayermp.getItemInUseCount() - partialTickTime + 1.0F;
f7 = 1.0F - f6 / (float)itemstack.getMaxItemUseDuration();
f8 = 1.0F - f7;
f8 = f8 * f8 * f8;
f8 = f8 * f8 * f8;
f8 = f8 * f8 * f8;
f9 = 1.0F - f8;
GL11.glTranslatef(0.0F, MathHelper.abs(MathHelper.cos(f6 / 4.0F * (float)Math.PI) * 0.1F) * (float)((double)f7 > 0.2D ? 1 : 0), 0.0F);
GL11.glTranslatef(f9 * 0.6F, -f9 * 0.5F, 0.0F);
GL11.glRotatef(f9 * 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(f9 * 10.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(f9 * 30.0F, 0.0F, 0.0F, 1.0F);
}
}
else
{
f5 = entityclientplayermp.getSwingProgress(partialTickTime);
f6 = MathHelper.sin(f5 * (float)Math.PI);
f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI);
GL11.glTranslatef(-f7 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.2F, -f6 * 0.2F);
}
GL11.glTranslatef(0.7F * f13, -0.65F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
f5 = entityclientplayermp.getSwingProgress(partialTickTime);
f6 = MathHelper.sin(f5 * f5 * (float)Math.PI);
f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI);
GL11.glRotatef(-f6 * 20.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-f7 * 20.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-f7 * 80.0F, 1.0F, 0.0F, 0.0F);
f8 = 0.4F;
GL11.glScalef(f8, f8, f8);
float f11;
float f12;
if (entityclientplayermp.getItemInUseCount() > 0)
{
EnumAction enumaction1 = itemstack.getItemUseAction();
if (enumaction1 == EnumAction.block)
{
GL11.glTranslatef(-0.5F, 0.2F, 0.0F);
GL11.glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-80.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F);
}
else if (enumaction1 == EnumAction.bow)
{
GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-12.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-8.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(-0.9F, 0.2F, 0.0F);
f10 = (float)itemstack.getMaxItemUseDuration() - ((float)entityclientplayermp.getItemInUseCount() - partialTickTime + 1.0F);
f11 = f10 / 20.0F;
f11 = (f11 * f11 + f11 * 2.0F) / 3.0F;
if (f11 > 1.0F)
{
f11 = 1.0F;
}
if (f11 > 0.1F)
{
GL11.glTranslatef(0.0F, MathHelper.sin((f10 - 0.1F) * 1.3F) * 0.01F * (f11 - 0.1F), 0.0F);
}
GL11.glTranslatef(0.0F, 0.0F, f11 * 0.1F);
GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(0.0F, 0.5F, 0.0F);
f12 = 1.0F + f11 * 0.2F;
GL11.glScalef(1.0F, 1.0F, f12);
GL11.glTranslatef(0.0F, -0.5F, 0.0F);
GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
}
}
if (itemstack.getItem().shouldRotateAroundWhenRendering())
{
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
}
if (itemstack.getItem().requiresMultipleRenderPasses())
{
this.renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON);
for (int x = 1; x < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); x++)
{
int k1 = itemstack.getItem().getColorFromItemStack(itemstack, x);
f10 = (float)(k1 >> 16 & 255) / 255.0F;
f11 = (float)(k1 >> 8 & 255) / 255.0F;
f12 = (float)(k1 & 255) / 255.0F;
GL11.glColor4f(1.0F * f10, 1.0F * f11, 1.0F * f12, 1.0F);
this.renderItem(entityclientplayermp, itemstack, x, EQUIPPED_FIRST_PERSON);
}
}
else
{
this.renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON);
}
GL11.glPopMatrix();
}
else if (!entityclientplayermp.isInvisible())
if (itemstack == null && !entityclientplayermp.isInvisible())
{
GL11.glPushMatrix();
f13 = 0.8F;
@@ -515,7 +73,6 @@ public class RenderCNPCHand extends ItemRenderer {
f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI);
GL11.glRotatef(f7 * 70.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-f6 * 20.0F, 0.0F, 0.0F, 1.0F);
this.mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin());
GL11.glTranslatef(-1.0F, 3.6F, 3.5F);
GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F);
@@ -523,19 +80,12 @@ public class RenderCNPCHand extends ItemRenderer {
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef(5.6F, 0.0F, 0.0F);
render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer);
renderplayer = (RenderPlayer)render;
f10 = 1.0F;
GL11.glScalef(f10, f10, f10);
renderCNPCPlayer.renderFirstPersonArm(this.mc.thePlayer,partialTickTime);
renderCNPCPlayer.renderFirstPersonArmOverlay(this.mc.thePlayer);
GL11.glPopMatrix();
}
if (itemstack != null && itemstack.getItem() instanceof ItemCloth)
{
GL11.glDisable(GL11.GL_BLEND);
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
}
@@ -572,7 +122,7 @@ public class RenderCNPCHand extends ItemRenderer {
f2 = f;
}
this.equippedProgress += f2/2.0F;
this.equippedProgress += f2;
if (this.equippedProgress < 0.1F)
{
@@ -580,20 +130,4 @@ public class RenderCNPCHand extends ItemRenderer {
this.equippedItemSlot = entityclientplayermp.inventory.currentItem;
}
}
/**
* Resets equippedProgress
*/
public void resetEquippedProgress()
{
this.equippedProgress = 0.0F;
}
/**
* Resets equippedProgress
*/
public void resetEquippedProgress2()
{
this.equippedProgress = 0.0F;
}
}
@@ -3,7 +3,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.ActiveRenderInfo;
@@ -15,21 +14,17 @@ import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderPlayerEvent;
import noppes.npcs.client.Client;
import noppes.npcs.client.ClientEventHandler;
import noppes.npcs.controllers.data.SkinOverlay;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Project;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
public class RenderCNPCPlayer extends RenderPlayer {
public RenderCNPCHand itemRenderer = new RenderCNPCHand(Minecraft.getMinecraft());
@@ -60,13 +55,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
return false;
}
if (!Client.entitySkinOverlayTicks.containsKey(player.getUniqueID())) {
Client.entitySkinOverlayTicks.put(player.getUniqueID(), 1L);
} else {
long ticks = Client.entitySkinOverlayTicks.get(player.getUniqueID());
Client.entitySkinOverlayTicks.put(player.getUniqueID(), ticks + 1);
}
float partialTickTime = Client.entitySkinOverlayTicks.get(player.getUniqueID());
float partialTickTime = ClientEventHandler.partialHandTicks;
// Overlay & Glow
GL11.glEnable(GL11.GL_BLEND);
@@ -196,20 +185,13 @@ public class RenderCNPCPlayer extends RenderPlayer {
if (mc.gameSettings.thirdPersonView == 0 && !mc.renderViewEntity.isPlayerSleeping() && !mc.gameSettings.hideGUI && !mc.playerController.enableEverythingIsScrewedUpMode())
{
itemRenderer.updateEquippedItem();
entityRenderer.enableLightmap((double)partialTicks);
itemRenderer.renderItemInFirstPerson(partialTicks);
itemRenderer.renderOverlayInFirstPerson(partialTicks);
entityRenderer.disableLightmap((double)partialTicks);
}
GL11.glPopMatrix();
if (mc.gameSettings.thirdPersonView == 0 && !mc.renderViewEntity.isPlayerSleeping())
{
entityRenderer.itemRenderer.renderOverlays(partialTicks);
hurtCameraEffect(partialTicks);
}
if (mc.gameSettings.viewBobbing)
{
setupViewBobbing(partialTicks);
@@ -245,32 +227,6 @@ public class RenderCNPCPlayer extends RenderPlayer {
return f1 + this.prevDebugCamFOV + (this.debugCamFOV - this.prevDebugCamFOV) * p_78481_1_;
}
public void updateFovModifierHand()
{
Minecraft mc = Minecraft.getMinecraft();
if (mc.renderViewEntity instanceof EntityPlayerSP)
{
EntityPlayerSP entityplayersp = (EntityPlayerSP)mc.renderViewEntity;
this.fovMultiplierTemp = entityplayersp.getFOVMultiplier();
}
else
{
this.fovMultiplierTemp = mc.thePlayer.getFOVMultiplier();
}
this.fovModifierHandPrev = this.fovModifierHand;
this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F;
if (this.fovModifierHand > 1.5F)
{
this.fovModifierHand = 1.5F;
}
if (this.fovModifierHand < 0.1F)
{
this.fovModifierHand = 0.1F;
}
}
private void hurtCameraEffect(float p_78482_1_)
{
Minecraft mc = Minecraft.getMinecraft();
@@ -312,13 +268,9 @@ public class RenderCNPCPlayer extends RenderPlayer {
}
}
public void renderFirstPersonArm(EntityPlayer player, float partialTickTime)
public void renderFirstPersonArmOverlay(EntityPlayer player)
{
Render render = RenderManager.instance.getEntityRenderObject(player);
RenderPlayer renderplayer = (RenderPlayer)render;
renderplayer.renderFirstPersonArm(player);
float gender = 1.0F;
float gender = -1;
try {
Class<?> RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA");
gender = (float) RenderPlayerJBRA.getMethod("genGet").invoke(null);
@@ -342,7 +294,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY,
overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ
))
continue;;
continue;
if (gender >= 2.0F) {
GL11.glRotatef(7F, 0, 0, 1);
@@ -360,48 +312,100 @@ public class RenderCNPCPlayer extends RenderPlayer {
public void renderDBCModel(RenderPlayerEvent.Specials.Post event) {
EntityPlayer player = event.entityPlayer;
try {
Class<?> RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA");
Class<?> ModelBipedDBC = Class.forName("JinRyuu.JBRA.ModelBipedDBC");
Class<?> ModelBipedBody = Class.forName("JinRyuu.JRMCore.entity.ModelBipedBody");
Class<?> RenderPlayerJBRA = null;
Class<?> ModelBipedDBC = null;
Class<?> ModelBipedBody = null;
Method renderDBC = null;
Field rot1 = null,rot2 = null,rot3 = null,rot4 = null,rot5 = null,rot6 = null;
Object m = null;
ModelRenderer bipedHead = null,bipedBody = null,bipedRA = null,bipedLA = null,bipedRL = null,bipedLL = null;
ModelRenderer Brightarm = null,Bleftarm = null,rightleg = null,leftleg = null,body = null,hip = null;
ModelRenderer waist = null,bottom = null,Bbreast = null,Bbreast2 = null,breast = null,breast2 = null;
float childScl = 0.0F;
Object m = RenderPlayerJBRA.getField("modelMain").get(event.renderer);
ModelBipedBody.getField("onGround").set(m, (int) player.getSwingProgress(event.partialRenderTick));
try {
RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA");
ModelBipedDBC = Class.forName("JinRyuu.JBRA.ModelBipedDBC");
ModelBipedBody = Class.forName("JinRyuu.JRMCore.entity.ModelBipedBody");
renderDBC = ModelBipedBody.getMethod("render",Entity.class,float.class,float.class,float.class,float.class,float.class,float.class);
rot1 = ModelBipedDBC.getField("rot1");
rot2 = ModelBipedDBC.getField("rot2");
rot3 = ModelBipedDBC.getField("rot3");
rot4 = ModelBipedDBC.getField("rot4");
rot5 = ModelBipedDBC.getField("rot5");
rot6 = ModelBipedDBC.getField("rot6");
m = RenderPlayerJBRA.getField("modelMain").get(event.renderer);
ModelBipedBody.getField("isRiding").set(m, player.isRiding());
ModelBipedBody.getField("isChild").set(m, player.isChild());
ModelBipedBody.getField("isSneak").set(m, player.isSneaking());
ModelBipedBody.getField("y").set(null, ModelBipedDBC.getField("y").get(null));
ModelRenderer bipedHead = (ModelRenderer) ModelBipedBody.getField("bipedHead").get(m);
ModelRenderer bipedBody = (ModelRenderer) ModelBipedBody.getField("bipedBody").get(m);
ModelRenderer bipedRA = (ModelRenderer) ModelBipedBody.getField("bipedRightArm").get(m);
ModelRenderer bipedLA = (ModelRenderer) ModelBipedBody.getField("bipedLeftArm").get(m);
ModelRenderer bipedRL = (ModelRenderer) ModelBipedBody.getField("bipedRightLeg").get(m);
ModelRenderer bipedLL = (ModelRenderer) ModelBipedBody.getField("bipedLeftLeg").get(m);
bipedHead = (ModelRenderer) ModelBipedBody.getField("bipedHead").get(m);
bipedBody = (ModelRenderer) ModelBipedBody.getField("bipedBody").get(m);
bipedRA = (ModelRenderer) ModelBipedBody.getField("bipedRightArm").get(m);
bipedLA = (ModelRenderer) ModelBipedBody.getField("bipedLeftArm").get(m);
bipedRL = (ModelRenderer) ModelBipedBody.getField("bipedRightLeg").get(m);
bipedLL = (ModelRenderer) ModelBipedBody.getField("bipedLeftLeg").get(m);
Brightarm = (ModelRenderer) ModelBipedBody.getField("Brightarm").get(m);
Bleftarm = (ModelRenderer) ModelBipedBody.getField("Bleftarm").get(m);
rightleg = (ModelRenderer) ModelBipedBody.getField("rightleg").get(m);
leftleg = (ModelRenderer) ModelBipedBody.getField("leftleg").get(m);
body = (ModelRenderer) ModelBipedBody.getField("body").get(m);
hip = (ModelRenderer) ModelBipedBody.getField("hip").get(m);
waist = (ModelRenderer) ModelBipedBody.getField("waist").get(m);
bottom = (ModelRenderer) ModelBipedBody.getField("bottom").get(m);
Bbreast = (ModelRenderer) ModelBipedBody.getField("Bbreast").get(m);
Bbreast2 = (ModelRenderer) ModelBipedBody.getField("Bbreast2").get(m);
breast = (ModelRenderer) ModelBipedBody.getField("breast").get(m);
breast2 = (ModelRenderer) ModelBipedBody.getField("breast2").get(m);
childScl = (float) RenderPlayerJBRA.getMethod("childSclGet").invoke(null);
} catch (Exception ignored) {}
ModelRenderer Brightarm = (ModelRenderer) ModelBipedBody.getField("Brightarm").get(m);
ModelRenderer Bleftarm = (ModelRenderer) ModelBipedBody.getField("Bleftarm").get(m);
ModelRenderer rightleg = (ModelRenderer) ModelBipedBody.getField("rightleg").get(m);
ModelRenderer leftleg = (ModelRenderer) ModelBipedBody.getField("leftleg").get(m);
ModelRenderer body = (ModelRenderer) ModelBipedBody.getField("body").get(m);
ModelRenderer hip = (ModelRenderer) ModelBipedBody.getField("hip").get(m);
ModelRenderer waist = (ModelRenderer) ModelBipedBody.getField("waist").get(m);
ModelRenderer bottom = (ModelRenderer) ModelBipedBody.getField("bottom").get(m);
ModelRenderer Bbreast = (ModelRenderer) ModelBipedBody.getField("Bbreast").get(m);
ModelRenderer Bbreast2 = (ModelRenderer) ModelBipedBody.getField("Bbreast2").get(m);
ModelRenderer breast = (ModelRenderer) ModelBipedBody.getField("breast").get(m);
ModelRenderer breast2 = (ModelRenderer) ModelBipedBody.getField("breast2").get(m);
float childScl = (float) RenderPlayerJBRA.getMethod("childSclGet").invoke(null);
try {
RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA");
ModelBipedDBC = Class.forName("JinRyuu.JBRA.ModelBipedDBC");
ModelBipedBody = Class.forName("JinRyuu.JRMCore.entity.ModelBipedBody");
Method renderDBC = ModelBipedBody.getMethod("render",Entity.class,float.class,float.class,float.class,float.class,float.class,float.class);
Field rot1 = ModelBipedDBC.getField("rot1");
Field rot2 = ModelBipedDBC.getField("rot2");
Field rot3 = ModelBipedDBC.getField("rot3");
Field rot4 = ModelBipedDBC.getField("rot4");
Field rot5 = ModelBipedDBC.getField("rot5");
Field rot6 = ModelBipedDBC.getField("rot6");
renderDBC = ModelBipedBody.getMethod("func_78088_a",Entity.class,float.class,float.class,float.class,float.class,float.class,float.class);
rot1 = ModelBipedDBC.getField("rot1");
rot2 = ModelBipedDBC.getField("rot2");
rot3 = ModelBipedDBC.getField("rot3");
rot4 = ModelBipedDBC.getField("rot4");
rot5 = ModelBipedDBC.getField("rot5");
rot6 = ModelBipedDBC.getField("rot6");
m = RenderPlayerJBRA.getField("modelMain").get(event.renderer);
ModelBipedBody.getField("field_78093_q").set(m, player.isRiding());
ModelBipedBody.getField("field_78091_s").set(m, player.isChild());
ModelBipedBody.getField("field_78117_n").set(m, player.isSneaking());
ModelBipedBody.getField("y").set(null, ModelBipedDBC.getField("y").get(null));
bipedHead = (ModelRenderer) ModelBipedBody.getField("field_78116_c").get(m);
bipedBody = (ModelRenderer) ModelBipedBody.getField("field_78115_e").get(m);
bipedRA = (ModelRenderer) ModelBipedBody.getField("field_78112_f").get(m);
bipedLA = (ModelRenderer) ModelBipedBody.getField("field_78113_g").get(m);
bipedRL = (ModelRenderer) ModelBipedBody.getField("field_78123_h").get(m);
bipedLL = (ModelRenderer) ModelBipedBody.getField("field_78124_i").get(m);
Brightarm = (ModelRenderer) ModelBipedBody.getField("Brightarm").get(m);
Bleftarm = (ModelRenderer) ModelBipedBody.getField("Bleftarm").get(m);
rightleg = (ModelRenderer) ModelBipedBody.getField("rightleg").get(m);
leftleg = (ModelRenderer) ModelBipedBody.getField("leftleg").get(m);
body = (ModelRenderer) ModelBipedBody.getField("body").get(m);
hip = (ModelRenderer) ModelBipedBody.getField("hip").get(m);
waist = (ModelRenderer) ModelBipedBody.getField("waist").get(m);
bottom = (ModelRenderer) ModelBipedBody.getField("bottom").get(m);
Bbreast = (ModelRenderer) ModelBipedBody.getField("Bbreast").get(m);
Bbreast2 = (ModelRenderer) ModelBipedBody.getField("Bbreast2").get(m);
breast = (ModelRenderer) ModelBipedBody.getField("breast").get(m);
breast2 = (ModelRenderer) ModelBipedBody.getField("breast2").get(m);
childScl = (float) RenderPlayerJBRA.getMethod("childSclGet").invoke(null);
} catch (Exception ignored) {}
try {
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
if (overlayData.texture.isEmpty())
@@ -423,8 +427,8 @@ public class RenderCNPCPlayer extends RenderPlayer {
continue;
bipedHead.isHidden = true;
renderDBC.invoke(m, player,
(float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m),
(float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m)
(float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m),
(float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m)
);
bipedHead.isHidden = false;
@@ -487,8 +491,6 @@ public class RenderCNPCPlayer extends RenderPlayer {
postRenderOverlay();
}
}
} catch (Exception ignored) {
postRenderOverlay();
}
} catch (Exception ignored) {}
}
}
@@ -238,7 +238,9 @@ public class RenderNPCHumanMale extends RenderNPCInterface
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
Class<?> clazz = itemstack2.getItem().getClass();
boolean pluginMod = itemstack2.getItem().getUnlocalizedName().contains("plug:");
if (itemstack2.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack2.getItem()).getRenderType())))
{
var6 = 0.5F;
@@ -248,7 +250,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(-var6, -var6, var6);
}
else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
else if (itemstack2.getItem() instanceof ItemBow && (customRenderer == null || pluginMod))
{
var6 = 0.625F;
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
@@ -257,7 +259,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
}
else if (itemstack2.getItem().isFull3D())
else if (itemstack2.getItem().isFull3D() && (customRenderer == null || pluginMod))
{
var6 = 0.625F;
@@ -280,6 +282,14 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
}
else if(is3D){
var6 = 0.5F;
GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
var6 *= 0.75F;
GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(-var6, -var6, var6);
}
else
{
var6 = 0.375F;
@@ -335,6 +345,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
Class<?> clazz = itemstack2.getItem().getClass();
boolean pluginMod = itemstack2.getItem().getUnlocalizedName().contains("plug:");
if(clazz.getSimpleName().equals("ItemShield") || clazz.getSimpleName().equals("ItemRotatedShield") || clazz.getSimpleName().equals("ItemClaw"))
GL11.glTranslatef(0.30f, 0, 0f);
@@ -347,7 +358,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(var6, -var6, var6);
}
else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
else if (itemstack2.getItem() instanceof ItemBow && (customRenderer == null || pluginMod))
{
var6 = 0.625F;
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
@@ -10,7 +10,7 @@ public class SkinOverlay implements ISkinOverlay {
public ResourceLocation location = null;
public String texture;
public boolean glow = true;
public boolean blend = false;
public boolean blend = true;
public float alpha = 1.0F;
public float size = 1.0F;
@@ -397,6 +397,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
return true;
}
@Override
public PathNavigate getNavigator() {
if(canFly())
return this.flyNavigator;
@@ -405,6 +406,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
}
}
@Override
public EntityMoveHelper getMoveHelper() {
if(canFly())
return this.flyMoveHelper;
@@ -413,6 +415,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
}
}
@Override
protected void updateAITasks()
{
if (this.isInWater() || this.stats.drowningType != 2) {
@@ -72,12 +72,12 @@ public class ItemSoulstoneFilled extends Item {
Entity entity = EntityList.createEntityFromNBT(compound, world);
if(entity == null)
return false;
entity.setPosition(x + 0.5, y - 0.5, z + 0.5);
entity.setPosition(x + 0.5, y + 1 + 0.2F, z + 0.5);
if(entity instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) entity;
npc.ai.startPos = new int[]{x, y, z};
npc.setHealth(npc.getMaxHealth());
npc.setPosition((float)x + 0.5F, npc.getStartYPos() - 0.5, (float)z + 0.5F);
npc.setPosition((float)x + 0.5F, npc.getStartYPos(), (float)z + 0.5F);
npc.advanced.soulStonePlayerName = player.getDisplayName();
npc.advanced.soulStoneInit = true;
if(npc.advanced.role == EnumRoleType.Companion && player != null){
@@ -0,0 +1,50 @@
package noppes.npcs.mixin;
import org.spongepowered.asm.lib.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class CustomNPCsMixinPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {
}
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return true;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}
@Override
public List<String> getMixins() {
List<String> mixins = new ArrayList<>();
mixins.add("MixinEntityRenderer");
return mixins;
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
}
@@ -0,0 +1,26 @@
package noppes.npcs.mixin;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.client.ClientEventHandler;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(value = EntityRenderer.class)
public class MixinEntityRenderer {
@Inject(method = "renderWorld", at = @At(value = "RETURN"))
private void renderFirstPersonOverlays(float p_78476_1_, long p_78476_2_, CallbackInfo callbackInfo)
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (ClientEventHandler.hasOverlays(player)) {
GL11.glPushMatrix();
ClientEventHandler.renderCNPCPlayer.renderHand(p_78476_1_,0);
GL11.glPopMatrix();
}
}
}
@@ -23,20 +23,15 @@ public class ScriptBlock implements IBlock {
protected final IWorld world;
protected final Block block;
protected final BlockPos pos;
protected final ScriptBlockPos bPos;
protected TileEntity tile;
protected final IPos bPos;
protected ITileEntity tile;
public ScriptBlock(World world, Block block, BlockPos pos) {
this.world = NpcAPI.Instance().getIWorld((WorldServer)world);
this.world = NpcAPI.Instance().getIWorld(world);
this.block = block;
this.pos = pos;
this.bPos = new ScriptBlockPos(pos);
this.setTile(world.getTileEntity(pos.getX(),pos.getY(), pos.getZ()));
}
protected void setTile(TileEntity tile) {
world.setTileEntity(pos.getX(),pos.getY(), pos.getZ(),new ScriptTileEntity(tile));
this.tile = tile;
this.tile = new ScriptTileEntity<>(world.getTileEntity(pos.getX(),pos.getY(), pos.getZ()));
}
public IPos getPos() {
@@ -79,14 +74,14 @@ public class ScriptBlock implements IBlock {
}
public boolean isContainer() {
return this.tile != null && this.tile instanceof IInventory && ((IInventory) this.tile).getSizeInventory() > 0;
return this.tile != null && this.tile.getMCTileEntity() != null && this.tile.getMCTileEntity() instanceof IInventory && ((IInventory) this.tile.getMCTileEntity()).getSizeInventory() > 0;
}
public IContainer getContainer() {
if(!this.isContainer()) {
throw new CustomNPCsException("This block is not a container", new Object[0]);
} else {
return NpcAPI.Instance().getIContainer((IInventory)this.tile);
return NpcAPI.Instance().getIContainer((IInventory)this.tile.getMCTileEntity());
}
}
@@ -95,7 +90,7 @@ public class ScriptBlock implements IBlock {
}
public String getDisplayName() {
return this.tile == null?this.getName():this.tile.blockType.getItemIconName();
return this.tile == null || this.tile.getMCTileEntity() == null ? this.getName():this.tile.getMCTileEntity().blockType.getItemIconName();
}
public IWorld getWorld() {
@@ -115,21 +110,21 @@ public class ScriptBlock implements IBlock {
}
public ITileEntity getTileEntity() {
return new ScriptTileEntity(this.tile);
return this.tile;
}
public void setTileEntity(ITileEntity tileEntity){
world.setTileEntity(pos.getX(),pos.getY(), pos.getZ(),tileEntity);
this.tile = tileEntity.getMCTileEntity();
this.tile = tileEntity;
}
public TileEntity getMCTileEntity() {
return this.tile;
return this.tile.getMCTileEntity();
}
public INbt getTileEntityNBT() {
NBTTagCompound compound = new NBTTagCompound();
this.tile.writeToNBT(compound);
this.tile.getMCTileEntity().writeToNBT(compound);
return NpcAPI.Instance().getINbt(compound);
}
@@ -0,0 +1,2 @@
#EntityRenderer
public net.minecraft.client.renderer.EntityRenderer func_78476_b(FI)V # renderHand
@@ -0,0 +1,9 @@
{
"required": true,
"minVersion": "0.7.11",
"package": "noppes.npcs.mixin",
"plugin": "noppes.npcs.mixin.CustomNPCsMixinPlugin",
"refmap": "customnpcs.refmap.json",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
}