fix and improve camera system
This commit is contained in:
parent
a76c0c66e1
commit
72dc4a1305
15 changed files with 180 additions and 108 deletions
|
@ -1,5 +1,6 @@
|
|||
package common.ai;
|
||||
|
||||
import common.entity.npc.EntityCameraHolder;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.entity.types.IEntityOwnable;
|
||||
import common.pathfinding.PathEntity;
|
||||
|
@ -139,7 +140,7 @@ public abstract class EntityAITarget extends EntityAIBase
|
|||
{
|
||||
return false;
|
||||
}
|
||||
else if (!target.isEntityAlive())
|
||||
else if (!target.isEntityAlive() || target instanceof EntityCameraHolder)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
44
common/src/main/java/common/entity/npc/EntityCameraHolder.java
Executable file
44
common/src/main/java/common/entity/npc/EntityCameraHolder.java
Executable file
|
@ -0,0 +1,44 @@
|
|||
package common.entity.npc;
|
||||
|
||||
import common.entity.DamageSource;
|
||||
import common.rng.Random;
|
||||
import common.world.World;
|
||||
|
||||
public class EntityCameraHolder extends EntityNPC {
|
||||
public EntityCameraHolder(World worldIn) {
|
||||
super(worldIn);
|
||||
}
|
||||
|
||||
public int getBaseHealth(Random rand) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.NEUTRAL;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 0.1f;
|
||||
}
|
||||
|
||||
public boolean isVisibleTo(EntityNPC player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object onInitialSpawn(Object livingdata) {
|
||||
this.setCustomNameTag("Kamera");
|
||||
this.setHeight(0.1f);
|
||||
return livingdata;
|
||||
}
|
||||
|
||||
public boolean canBeCollidedWith() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getEyeHeight() {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
protected void damageEntity(DamageSource damageSrc, int damageAmount) {
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package common.entity.npc;
|
||||
|
||||
import common.init.Items;
|
||||
import common.item.ItemStack;
|
||||
import common.rng.Random;
|
||||
import common.world.World;
|
||||
|
||||
public class EntityCpu extends EntityNPC {
|
||||
public EntityCpu(World worldIn) {
|
||||
super(worldIn);
|
||||
}
|
||||
|
||||
// public boolean isAggressive() {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// public boolean isPeaceful() {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// public boolean isAggressive(Class<? extends EntityNPC> clazz) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// public boolean isPeaceful(Class<? extends EntityNPC> clazz) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// public boolean canInfight(Alignment align) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// public boolean canMurder(Alignment align) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public boolean canUseMagic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// public int getBaseEnergy(Random rand) {
|
||||
// return Integer.MAX_VALUE;
|
||||
// }
|
||||
|
||||
public int getBaseHealth(Random rand) {
|
||||
return 1024;
|
||||
}
|
||||
|
||||
// public float getHeightDeviation(Random rand) {
|
||||
// return 0.0f;
|
||||
// }
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.NEUTRAL;
|
||||
}
|
||||
|
||||
public boolean isBreedingItem(ItemStack stack) {
|
||||
return stack.getItem() == Items.nieh_fragment;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ public class EntityMage extends EntityNPC
|
|||
|
||||
public void onLivingUpdate()
|
||||
{
|
||||
if (!this.worldObj.client && !this.isPlayer())
|
||||
if (!this.worldObj.client && !this.isPlayer() && !this.dummy)
|
||||
{
|
||||
if (this.drinking)
|
||||
{
|
||||
|
|
|
@ -215,6 +215,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
public IPlayer connection;
|
||||
public IClientPlayer client;
|
||||
protected boolean slave;
|
||||
protected boolean dummy;
|
||||
|
||||
protected InventoryWarpChest warpChest;
|
||||
public ContainerPlayer inventoryContainer;
|
||||
|
@ -436,6 +437,11 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
this.renderDistWeight = 10.0D;
|
||||
}
|
||||
|
||||
public final void setPlayerDummy(TagObject tag) {
|
||||
this.dummy = true;
|
||||
this.readTags(tag);
|
||||
}
|
||||
|
||||
public final boolean isPlayer() {
|
||||
return this.connection != null || this.slave;
|
||||
}
|
||||
|
@ -2487,7 +2493,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
|
||||
public ItemStack getHeldItem()
|
||||
{
|
||||
return this.isPlayer() ? (this.getSelectedIndex() < 9 && this.getSelectedIndex() >= 0 ? this.getStackInSlot(this.getSelectedIndex()) : null) : this.heldItem;
|
||||
return this.isPlayer() || this.dummy ? (this.getSelectedIndex() < 9 && this.getSelectedIndex() >= 0 ? this.getStackInSlot(this.getSelectedIndex()) : null) : this.heldItem;
|
||||
}
|
||||
|
||||
public ItemStack[] getArmor()
|
||||
|
@ -2507,7 +2513,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
|
||||
public void setHeldItem(ItemStack stack)
|
||||
{
|
||||
if(this.isPlayer()) {
|
||||
if(this.isPlayer() || this.dummy) {
|
||||
this.setInventorySlotContents(this.getSelectedIndex(), stack);
|
||||
}
|
||||
else {
|
||||
|
@ -3340,7 +3346,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
// this.setCanPickUpLoot(true);
|
||||
this.setCombatTask();
|
||||
|
||||
if(this.isPlayer()) {
|
||||
if(this.isPlayer() || this.dummy) {
|
||||
// this.entityUniqueID = getOfflineUUID(this.user);
|
||||
// this.sleeping = tagCompund.getBoolean("Sleeping");
|
||||
// this.sleepTimer = tagCompund.getShort("SleepTimer");
|
||||
|
@ -3459,7 +3465,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
if(this.skin != null)
|
||||
tag.setByteArray("Skin", this.skin);
|
||||
|
||||
if(this.isPlayer()) {
|
||||
if(this.isPlayer() || this.dummy) {
|
||||
// tagCompound.setBoolean("Sleeping", this.sleeping);
|
||||
// tagCompound.setShort("SleepTimer", (short)this.sleepTimer);
|
||||
tag.setFloat("XpP", this.experience);
|
||||
|
@ -3511,7 +3517,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
|
||||
protected void damageArmor(int damage)
|
||||
{
|
||||
if(this.isPlayer()) {
|
||||
if(this.isPlayer() || this.dummy) {
|
||||
damage = damage / 4;
|
||||
if (damage < 1)
|
||||
damage = 1;
|
||||
|
@ -4027,7 +4033,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
*/
|
||||
protected int getExperiencePoints(EntityNPC player)
|
||||
{
|
||||
return this.isPlayer() ? 0 : this.worldObj.rand.range(2, 5);
|
||||
return this.isPlayer() || this.dummy ? 0 : this.worldObj.rand.range(2, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4168,7 +4174,8 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
protected void dropFewItems(boolean wasRecentlyHit, int lootingModifier)
|
||||
{
|
||||
if(!this.isPlayer()) {
|
||||
super.dropFewItems(wasRecentlyHit, lootingModifier);
|
||||
if(!this.dummy)
|
||||
super.dropFewItems(wasRecentlyHit, lootingModifier);
|
||||
this.dropEquipment();
|
||||
}
|
||||
}
|
||||
|
@ -4304,7 +4311,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
}
|
||||
|
||||
public boolean getCanSpawnHere() {
|
||||
return this.isPlayer() || super.getCanSpawnHere();
|
||||
return this.isPlayer() || this.dummy || super.getCanSpawnHere();
|
||||
}
|
||||
|
||||
// npc overrides
|
||||
|
@ -4321,7 +4328,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
if(this.isPlayer())
|
||||
return;
|
||||
ItemStack itemstack1 = this.getHeldItem();
|
||||
if (itemstack1 != null)
|
||||
if (itemstack1 != null && !this.dummy)
|
||||
{
|
||||
this.entityDropItem(itemstack1, 0.0F);
|
||||
}
|
||||
|
@ -4429,7 +4436,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
}
|
||||
|
||||
protected boolean canRegenerateHealth() {
|
||||
return this.isPlayer();
|
||||
return this.isPlayer() || this.dummy;
|
||||
}
|
||||
|
||||
// END PLAYER
|
||||
|
|
|
@ -29,6 +29,7 @@ import common.entity.item.EntityOrb;
|
|||
import common.entity.item.EntityTnt;
|
||||
import common.entity.item.EntityTntCart;
|
||||
import common.entity.item.EntityXp;
|
||||
import common.entity.npc.EntityCameraHolder;
|
||||
import common.entity.npc.SpeciesInfo;
|
||||
import common.entity.projectile.EntityArrow;
|
||||
import common.entity.projectile.EntityBox;
|
||||
|
@ -260,6 +261,7 @@ public abstract class EntityRegistry {
|
|||
registerEntity("Bullet", EntityBullet.class, "Kugel");
|
||||
|
||||
registerEggs();
|
||||
registerEntity("Camera", EntityCameraHolder.class, "Kamera");
|
||||
|
||||
for(ItemMobTemplate item : ItemMobTemplate.TEMPLATES) {
|
||||
item.delegateSetDisplay();
|
||||
|
|
|
@ -7,7 +7,7 @@ import common.collect.Maps;
|
|||
import common.entity.npc.EntityArachnoid;
|
||||
import common.entity.npc.EntityBloodElf;
|
||||
import common.entity.npc.EntityChaosMarine;
|
||||
import common.entity.npc.EntityCpu;
|
||||
import common.entity.npc.EntityCameraHolder;
|
||||
import common.entity.npc.EntityCultivator;
|
||||
import common.entity.npc.EntityDarkMage;
|
||||
import common.entity.npc.EntityDwarf;
|
||||
|
@ -36,6 +36,7 @@ import common.entity.npc.SpeciesInfo;
|
|||
|
||||
public abstract class SpeciesRegistry {
|
||||
public static enum ModelType {
|
||||
CAMERA("camera", 0.1f, 0.1f, 16, 16, "Kamera"),
|
||||
HUMANOID("humanoid", 0.6f, 1.8f, 64, 64, "Humanoid"),
|
||||
ARACHNOID("arachnoid", 1.4f, 1.6f, 128, 64, "Arachnoidea"),
|
||||
SLIME("slime", 1.0f, 1.0f, 64, 32, "Schleim"),
|
||||
|
@ -86,7 +87,7 @@ public abstract class SpeciesRegistry {
|
|||
}
|
||||
|
||||
static void register() {
|
||||
registerSpecies("Cpu", EntityCpu.class, null, "Test-NSC", 0x202020, 0x8000ff, "Troll:trollface", "Hacker");
|
||||
new SpeciesInfo("Camera", EntityCameraHolder.class, null, false, null, "Kamera", ModelType.CAMERA, 0x202020, 0x8000ff);
|
||||
registerSpecies("Cultivator", EntityCultivator.class, "nienrath", "Kultivator", 0x000000, 0xff0000, "Wei Wuxian", 0x000000, 0xff0000,
|
||||
"Lan Wangji", 0xffffff, 0x80e0ff, "Jiang Cheng", 0x200000, 0xaf00ff, "Shen Qingqiu", 0xffffff, 0x80ff80,
|
||||
"Luo Binghe", 0x600000, 0x000000);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue