mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Added inventory rendering for changeling disguises
This commit is contained in:
parent
c01a01a417
commit
a3f12e4ea7
8 changed files with 79 additions and 13 deletions
|
@ -13,6 +13,8 @@ import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
|
|||
import com.minelittlepony.unicopia.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.player.IView;
|
||||
import com.minelittlepony.unicopia.player.PlayerSpeciesList;
|
||||
import com.minelittlepony.unicopia.spell.IMagicEffect;
|
||||
import com.minelittlepony.unicopia.spell.SpellDisguise;
|
||||
import com.minelittlepony.util.gui.ButtonGridLayout;
|
||||
import com.minelittlepony.util.gui.UButton;
|
||||
|
||||
|
@ -21,7 +23,10 @@ import net.minecraft.client.audio.PositionedSoundRecord;
|
|||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiOptions;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.world.IInteractionObject;
|
||||
|
@ -160,8 +165,37 @@ public class UnicopiaClient extends UClient {
|
|||
@SubscribeEvent
|
||||
public static void preEntityRender(RenderLivingEvent.Pre<?> event) {
|
||||
if (event.getEntity() instanceof EntityPlayer) {
|
||||
if (PlayerSpeciesList.instance().getPlayer((EntityPlayer)event.getEntity()).isInvisible()) {
|
||||
IPlayer iplayer = PlayerSpeciesList.instance().getPlayer((EntityPlayer)event.getEntity());
|
||||
|
||||
if (iplayer.isInvisible()) {
|
||||
event.setCanceled(true);
|
||||
|
||||
// This fixes lighting errors on the armour slots.
|
||||
// #MahjongPls
|
||||
// @FUF(reason = "Forge should fix this. Cancelling their event skips neccessary state resetting at the end of the render method")
|
||||
GlStateManager.enableAlpha();
|
||||
}
|
||||
|
||||
if (iplayer.hasEffect()) {
|
||||
RenderManager renderMan = Minecraft.getMinecraft().getRenderManager();
|
||||
|
||||
if (renderMan.isRenderShadow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// I assume we're in the inventory now.
|
||||
IMagicEffect effect = iplayer.getEffect();
|
||||
if (!effect.getDead() && effect instanceof SpellDisguise) {
|
||||
effect.update(iplayer);
|
||||
|
||||
Entity e = ((SpellDisguise)effect).getDisguise();
|
||||
|
||||
// Check for a disguise and render it in our place.
|
||||
if (e != null) {
|
||||
e.setInvisible(false);
|
||||
renderMan.renderEntity(e, 0, 0, 0, 0, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +247,7 @@ public class UnicopiaClient extends UClient {
|
|||
if (event.phase == Phase.END) {
|
||||
EntityPlayer player = UClient.instance().getPlayer();
|
||||
|
||||
if (player != null) {
|
||||
if (player != null && !player.isDead) {
|
||||
Race newRace = getclientPlayerRace();
|
||||
|
||||
if (newRace != clientPlayerRace) {
|
||||
|
|
|
@ -52,11 +52,6 @@ public class EntityRainbow extends EntityWeatherEffect {
|
|||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return super.getRenderBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundCategory getSoundCategory() {
|
||||
return SoundCategory.WEATHER;
|
||||
|
|
|
@ -95,6 +95,11 @@ public class EntitySpell extends EntityLiving implements IMagicals, ICaster<Enti
|
|||
return effectDelegate.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect() {
|
||||
return effectDelegate.has();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
super.entityInit();
|
||||
|
|
|
@ -10,6 +10,13 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.DataParameter;
|
||||
|
||||
/**
|
||||
* Synchronisation class for spell effects.
|
||||
* Since we can't have our own serializers, we have to intelligently
|
||||
* determine whether to update it from an nbt tag.
|
||||
*
|
||||
* @param <T> The owning entity
|
||||
*/
|
||||
public class EffectSync<T extends EntityLivingBase> {
|
||||
|
||||
@Nullable
|
||||
|
@ -25,7 +32,27 @@ public class EffectSync<T extends EntityLivingBase> {
|
|||
}
|
||||
|
||||
public boolean has() {
|
||||
return get() != null;
|
||||
NBTTagCompound comp = owned.getEntity().getDataManager().get(param);
|
||||
|
||||
if (comp == null || !comp.hasKey("effect_id")) {
|
||||
if (effect != null) {
|
||||
effect.setDead();
|
||||
effect = null;
|
||||
}
|
||||
} else {
|
||||
String id = comp.getString("effect_id");
|
||||
|
||||
if (effect == null || !effect.getName().contentEquals(id)) {
|
||||
if (effect != null) {
|
||||
effect.setDead();
|
||||
}
|
||||
effect = SpellRegistry.instance().createEffectFromNBT(comp);
|
||||
} else if (!owned.getEntity().world.isRemote && effect.isDirty()) {
|
||||
set(effect);
|
||||
}
|
||||
}
|
||||
|
||||
return effect != null;
|
||||
}
|
||||
|
||||
public IMagicEffect get() {
|
||||
|
|
|
@ -333,6 +333,11 @@ class PlayerCapabilities implements IPlayer {
|
|||
sendCapabilities(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect() {
|
||||
return effectDelegate.has();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IMagicEffect getEffect() {
|
||||
|
|
|
@ -23,8 +23,6 @@ public class RenderRainbow extends Render<EntityRainbow> {
|
|||
private static final ResourceLocation TEXTURE = new ResourceLocation("unicopia", "textures/environment/rainbow.png");
|
||||
|
||||
public void doRender(EntityRainbow entity, double x, double y, double z, float entityYaw, float partialTicks) {
|
||||
|
||||
|
||||
float distance = Minecraft.getMinecraft().getRenderViewEntity().getDistance(entity);
|
||||
float maxDistance = 16 * Minecraft.getMinecraft().gameSettings.renderDistanceChunks;
|
||||
double r = entity.getRadius();
|
||||
|
|
|
@ -24,9 +24,7 @@ public interface ICaster<E extends EntityLivingBase> extends IOwned<E>, ILevelle
|
|||
@Nullable
|
||||
IMagicEffect getEffect();
|
||||
|
||||
default boolean hasEffect() {
|
||||
return getEffect() != null;
|
||||
}
|
||||
boolean hasEffect();
|
||||
|
||||
/**
|
||||
* Gets the entity directly responsible for casting.
|
||||
|
|
|
@ -46,6 +46,10 @@ public class SpellDisguise extends AbstractSpell {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public Entity getDisguise() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public SpellDisguise setDisguise(@Nullable Entity entity) {
|
||||
if (entity == this.entity) {
|
||||
entity = null;
|
||||
|
|
Loading…
Reference in a new issue