Skip to content
Permalink
Browse files

Fixed capabilities: tactical hud nightvision, broadcast channels, imp…

…regnation
  • Loading branch information...
Ri5ux committed Apr 1, 2019
1 parent 60695e3 commit 4092dc0d4909b61cc7b2f8740085e744a07d930f
@@ -33,8 +33,8 @@
@Override
public void pre(FMLPreInitializationEvent event)
{
CapabilityManager.INSTANCE.register(IOrganism.class, new Organism(), Organism.class);
CapabilityManager.INSTANCE.register(ISpecialPlayer.class, new SpecialPlayer(), SpecialPlayer.class);
CapabilityManager.INSTANCE.register(IOrganism.class, new Organism(), new Organism.Factory());
CapabilityManager.INSTANCE.register(ISpecialPlayer.class, new SpecialPlayer(), new SpecialPlayer.Factory());
}

@SubscribeEvent
@@ -50,8 +50,6 @@ public void attachCapability(AttachCapabilitiesEvent<Entity> event)
}
}

///////////////////////////////////////////////////////////////////////

@SubscribeEvent
public void onEntityTrackEvent(PlayerEvent.StartTracking event)
{
@@ -1,5 +1,7 @@
package org.avp.world.capabilities;

import java.util.concurrent.Callable;

import org.avp.AliensVsPredator;
import org.avp.client.render.TacticalHUDRenderEvent;
import org.avp.entities.living.species.SpeciesAlien;
@@ -55,7 +57,7 @@ public boolean hasCapability(Capability<?> capability, EnumFacing facing)
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
{
return hasCapability(capability, facing) ? CAPABILITY.<T> cast(this.instance) : null;
return hasCapability(capability, facing) ? CAPABILITY.<T>cast(this.instance) : null;
}

@Override
@@ -100,6 +102,15 @@ public default void heal(EntityLivingBase living)

public static class Organism implements IOrganism, IStorage<IOrganism>
{
public static class Factory implements Callable<IOrganism>
{
@Override
public IOrganism call() throws Exception
{
return new Organism();
}
}

private Embryo embryo;
private int heartRate;

@@ -221,13 +232,13 @@ else if (living.motionX + living.motionZ > 0)
public void syncWithServer(EntityLivingBase living)
{
if (living != null)
AliensVsPredator.network().sendToServer(new OrganismServerSync(living.getEntityId(), (NBTTagCompound) Provider.CAPABILITY.getStorage().writeNBT(Provider.CAPABILITY, this, null)));
AliensVsPredator.network().sendToServer(new OrganismServerSync(living.getEntityId(), (NBTTagCompound) Provider.CAPABILITY.getStorage().writeNBT(Provider.CAPABILITY, this, null)));
}

public void syncWithClients(EntityLivingBase living)
{
if (living != null)
AliensVsPredator.network().sendToAll(new OrganismClientSync(living.getEntityId(), (NBTTagCompound) Provider.CAPABILITY.getStorage().writeNBT(Provider.CAPABILITY, this, null)));
AliensVsPredator.network().sendToAll(new OrganismClientSync(living.getEntityId(), (NBTTagCompound) Provider.CAPABILITY.getStorage().writeNBT(Provider.CAPABILITY, this, null)));
}

@Override
@@ -1,8 +1,11 @@
package org.avp.world.capabilities;

import java.util.concurrent.Callable;

import org.avp.AliensVsPredator;
import org.avp.packets.client.OrganismClientSync;
import org.avp.packets.server.OrganismServerSync;
import org.avp.world.capabilities.ISpecialPlayer.SpecialPlayer;
import org.avp.world.playermode.PlayerMode;

import net.minecraft.entity.EntityLivingBase;
@@ -56,7 +59,7 @@ public boolean hasCapability(Capability<?> capability, EnumFacing facing)
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
{
return hasCapability(capability, facing) ? CAPABILITY.<T> cast(this.instance) : null;
return hasCapability(capability, facing) ? CAPABILITY.<T>cast(this.instance) : null;
}

@Override
@@ -74,20 +77,29 @@ public void deserializeNBT(NBTBase nbt)

public static class SpecialPlayer implements ISpecialPlayer, IStorage<ISpecialPlayer>
{
public static class Factory implements Callable<ISpecialPlayer>
{
@Override
public ISpecialPlayer call() throws Exception
{
return new SpecialPlayer();
}
}

public static final String IDENTIFIER = "SpecialPlayer";
private static final String ID_INT_BROADCAST_RADIUS = "broadcastRadius";
private static final String ID_STRING_BROADCAST_CHANNEL = "broadcastChannel";
private static final String ID_BOOLEAN_ENTITY_CULLING = "entityCulling";
private static final String ID_BOOLEAN_NIGHTVISION = "nightvisionEnabled";
private static final String ID_BOOLEAN_CAN_CLIMB = "canClimb";
public int broadcastRadius;
private String broadcastChannel;
private boolean entityCulling;
private boolean nightvisionEnabled;
private boolean canClimb;
private PlayerMode playerMode = PlayerMode.NORMAL;

public int broadcastRadius;
private String broadcastChannel;
private boolean entityCulling;
private boolean nightvisionEnabled;
private boolean canClimb;
private PlayerMode playerMode = PlayerMode.NORMAL;

public SpecialPlayer()
{
this.broadcastChannel = "Default";
@@ -167,7 +179,7 @@ public void syncWithClients(EntityLivingBase living)
public NBTBase writeNBT(Capability<ISpecialPlayer> capability, ISpecialPlayer instance, EnumFacing side)
{
NBTTagCompound tag = new NBTTagCompound();

tag.setInteger(ID_INT_BROADCAST_RADIUS, instance.getBroadcastRadius());
tag.setString(ID_STRING_BROADCAST_CHANNEL, instance.getBroadcastChannel());
tag.setBoolean(ID_BOOLEAN_ENTITY_CULLING, instance.isEntityCullingEnabled());
@@ -183,7 +195,7 @@ public void readNBT(Capability<ISpecialPlayer> capability, ISpecialPlayer instan
if (nbt instanceof NBTTagCompound)
{
NBTTagCompound tag = (NBTTagCompound) nbt;

instance.setBroadcastChannel(tag.getString(ID_STRING_BROADCAST_CHANNEL));
instance.setBroadcastRadius(tag.getInteger(ID_INT_BROADCAST_RADIUS));
instance.setEntityCullingEnabled(tag.getBoolean(ID_BOOLEAN_ENTITY_CULLING));

0 comments on commit 4092dc0

Please sign in to comment.
You can’t perform that action at this time.