mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Gaia head can now be worn. Closes #305
This commit is contained in:
3 files changed
+127
No files matched your search
@@ -67,6 +67,7 @@ import vazkii.botania.client.fx.FXWisp;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexiconEntry;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexiconIndex;
|
||||
import vazkii.botania.client.render.entity.LayerGaiaHead;
|
||||
import vazkii.botania.client.render.entity.RenderBabylonWeapon;
|
||||
import vazkii.botania.client.render.entity.RenderCorporeaSpark;
|
||||
import vazkii.botania.client.render.entity.RenderDoppleganger;
|
||||
@@ -277,10 +278,12 @@ public class ClientProxy extends CommonProxy {
|
||||
render = skinMap.get("default");
|
||||
render.addLayer(new ContributorFancinessHandler());
|
||||
render.addLayer(new BaubleRenderHandler());
|
||||
render.addLayer(new LayerGaiaHead(render.getMainModel().bipedHead));
|
||||
|
||||
render = skinMap.get("slim");
|
||||
render.addLayer(new ContributorFancinessHandler());
|
||||
render.addLayer(new BaubleRenderHandler());
|
||||
render.addLayer(new LayerGaiaHead(render.getMainModel().bipedHead));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package vazkii.botania.client.render.entity;
|
||||
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.render.tile.RenderTileGaiaHead;
|
||||
import vazkii.botania.common.block.tile.TileGaiaHead;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class LayerGaiaHead implements LayerRenderer<EntityPlayer> {
|
||||
|
||||
private final ModelRenderer modelRenderer;
|
||||
|
||||
public LayerGaiaHead(ModelRenderer modelRenderer)
|
||||
{
|
||||
this.modelRenderer = modelRenderer;
|
||||
}
|
||||
|
||||
// Copied from LayerCustomHead, edits noted
|
||||
@Override
|
||||
public void doRenderLayer(@Nonnull EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
|
||||
ItemStack itemstack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||
|
||||
if (itemstack != null && itemstack.getItem() == ModItems.gaiaHead) // Botania - check for head
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
GlStateManager.translate(0.0F, 0.2F, 0.0F);
|
||||
}
|
||||
|
||||
/*boolean flag = player instanceof EntityVillager || player instanceof EntityZombie && ((EntityZombie)player).isVillager();
|
||||
|
||||
if (player.isChild() && !(player instanceof EntityVillager))
|
||||
{
|
||||
float f = 2.0F;
|
||||
float f1 = 1.4F;
|
||||
GlStateManager.translate(0.0F, 0.5F * scale, 0.0F);
|
||||
GlStateManager.scale(f1 / f, f1 / f, f1 / f);
|
||||
GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
|
||||
} Botania - N/A */
|
||||
|
||||
this.modelRenderer.postRender(0.0625F);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
float f2 = 1.1875F;
|
||||
GlStateManager.scale(f2, -f2, -f2);
|
||||
|
||||
// Botania - remove if check for skull and else branch. Check done above.
|
||||
|
||||
/*if (flag)
|
||||
{
|
||||
GlStateManager.translate(0.0F, 0.0625F, 0.0F);
|
||||
} Botania - N/A */
|
||||
|
||||
/*GameProfile gameprofile = null;
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound nbttagcompound = itemstack.getTagCompound();
|
||||
|
||||
if (nbttagcompound.hasKey("SkullOwner", 10))
|
||||
{
|
||||
gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
|
||||
}
|
||||
else if (nbttagcompound.hasKey("SkullOwner", 8))
|
||||
{
|
||||
String s = nbttagcompound.getString("SkullOwner");
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(s))
|
||||
{
|
||||
gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, s));
|
||||
nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
|
||||
}
|
||||
}
|
||||
} Botania - Don't do skin stuff */
|
||||
|
||||
// Botania - use gaia TESR
|
||||
ShaderHelper.useShader(ShaderHelper.doppleganger, RenderDoppleganger.defaultCallback);
|
||||
((RenderTileGaiaHead) (TileEntitySpecialRenderer) TileEntityRendererDispatcher.instance.getSpecialRendererByClass(TileGaiaHead.class))
|
||||
.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), null, -1, limbSwing);
|
||||
ShaderHelper.releaseShader();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombineTextures() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,12 @@ package vazkii.botania.common.item;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSkull;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
@@ -24,6 +28,8 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
@@ -31,10 +37,26 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemGaiaHead extends ItemMod {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static final ModelBiped EMPTY = new ModelBiped();
|
||||
|
||||
public ItemGaiaHead() {
|
||||
super(LibItemNames.GAIA_HEAD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, EntityEquipmentSlot armorType, Entity entity) {
|
||||
return armorType == EntityEquipmentSlot.HEAD;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nonnull
|
||||
@Override
|
||||
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) {
|
||||
EMPTY.setInvisible(true);
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
// Copied from vanila skull itemBlock. Relevant edits are indicated.
|
||||
@Nonnull
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user