use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class RenderItemBowSkin method renderItem.
@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
if (canRenderModel(stack) & type != ItemRenderType.INVENTORY) {
if (type != ItemRenderType.ENTITY) {
GL11.glPopMatrix();
// GL11.glPopMatrix();
// GL11.glRotatef(-135, 0, 1, 0);
// GL11.glRotatef(-10, 0, 0, 1);
}
GL11.glPushMatrix();
AbstractClientPlayer player = null;
int useCount = 0;
boolean hasArrow = false;
if (data.length >= 2) {
if (data[1] instanceof AbstractClientPlayer & data[0] instanceof RenderBlocks) {
RenderBlocks renderBlocks = (RenderBlocks) data[0];
player = (AbstractClientPlayer) data[1];
useCount = player.getItemInUseDuration();
hasArrow = player.inventory.hasItem(Items.arrow);
IEntityEquipment entityEquipment = SkinModelRenderer.INSTANCE.getPlayerCustomEquipmentData(player);
if (!hasArrow) {
if (player.capabilities.isCreativeMode) {
hasArrow = true;
}
}
}
}
float scale = 0.0625F;
float angle = (float) (((double) System.currentTimeMillis() / 5) % 360F);
switch(type) {
case EQUIPPED:
GL11.glScalef(1F, -1F, 1F);
GL11.glScalef(1.6F, 1.6F, 1.6F);
GL11.glRotatef(-135, 0, 1, 0);
GL11.glRotatef(10, 0, 0, 1);
GL11.glRotatef(-20, 1, 0, 0);
GL11.glRotatef(90, 0, 1, 0);
GL11.glTranslatef(0F * scale, -6F * scale, 1F * scale);
break;
case ENTITY:
GL11.glRotatef(180, 0, 0, 1);
GL11.glTranslatef(0F, -10F * scale, 0F);
break;
case EQUIPPED_FIRST_PERSON:
GL11.glScalef(1.6F, 1.6F, 1.6F);
GL11.glRotatef(-135, 0, 1, 0);
GL11.glRotatef(180, 0, 0, 1);
GL11.glRotatef(-90, 0, 1, 0);
// Back tilt
GL11.glRotatef(-17, 1, 0, 0);
GL11.glRotatef(2, 0, 0, 1);
GL11.glTranslatef(0F * scale, -2F * scale, 1F * scale);
if (useCount > 0) {
GL11.glTranslatef(-5 * scale, 3 * scale, 1 * scale);
GL11.glRotatef(-6, 1, 0, 0);
GL11.glRotatef(-16, 0, 1, 0);
GL11.glRotatef(2, 0, 0, 1);
}
break;
default:
break;
}
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
ModRenderHelper.enableAlphaBlend();
ModelSkinBow model = SkinModelRenderer.INSTANCE.customBow;
model.frame = getAnimationFrame(useCount);
SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
model.render(player, skin, false, skinPointer.getSkinDye(), null, false, 0, false);
if (hasArrow & useCount > 0) {
GL11.glTranslatef(1 * scale, 1 * scale, -12 * scale);
int tarPart = getAnimationFrame(useCount);
if (skin.getParts().get(tarPart).getMarkerBlocks().size() > 0) {
CubeMarkerData cmd = skin.getParts().get(tarPart).getMarkerBlocks().get(0);
ForgeDirection dir = ForgeDirection.getOrientation(cmd.meta - 1);
GL11.glTranslatef((-dir.offsetX + cmd.x) * scale, (-dir.offsetY + cmd.y) * scale, (dir.offsetZ + cmd.z) * scale);
// Shift the arrow a little to stop z fighting.
GL11.glTranslatef(-0.01F * scale, 0.01F * scale, -0.01F * scale);
SkinPart skinPartArrow = skin.getPart("armourers:bow.arrow");
if (skinPartArrow != null) {
SkinPartRenderer.INSTANCE.renderPart(skinPartArrow, scale, skinPointer.getSkinDye(), null, false);
} else {
ModelArrow.MODEL.render(scale, false);
}
}
}
GL11.glPopAttrib();
GL11.glPopMatrix();
if (type != ItemRenderType.ENTITY) {
// GL11.glPushMatrix();
GL11.glPushMatrix();
}
} else {
if (itemRenderer != null) {
itemRenderer.renderItem(type, stack, data);
} else {
renderNomalIcon(stack);
}
}
}
use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class RenderItemSwordSkin method renderItem.
@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
if (canRenderModel(stack) & type != ItemRenderType.INVENTORY) {
if (type != ItemRenderType.ENTITY) {
GL11.glPopMatrix();
GL11.glRotatef(-135, 0, 1, 0);
GL11.glRotatef(-10, 0, 0, 1);
}
GL11.glPushMatrix();
GL11.glScalef(1F, -1F, 1F);
GL11.glScalef(1.6F, 1.6F, 1.6F);
boolean isBlocking = false;
if (data.length >= 2) {
if (data[1] instanceof AbstractClientPlayer & data[0] instanceof RenderBlocks) {
RenderBlocks renderBlocks = (RenderBlocks) data[0];
AbstractClientPlayer player = (AbstractClientPlayer) data[1];
isBlocking = player.isBlocking();
}
}
float scale = 0.0625F;
switch(type) {
case EQUIPPED:
GL11.glTranslatef(2F * scale, -1F * scale, 0F * scale);
if (isBlocking) {
GL11.glTranslatef(-0F * scale, 2F * scale, 1F * scale);
}
GL11.glRotatef(90F, 0F, 1F, 0F);
break;
case ENTITY:
GL11.glScalef(-1F, 1F, 1F);
GL11.glTranslatef(0F, -10F * scale, 0F);
break;
case EQUIPPED_FIRST_PERSON:
GL11.glScalef(-1F, 1F, 1F);
GL11.glRotatef(-90F, 0F, 1F, 0F);
break;
default:
break;
}
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
ModRenderHelper.enableAlphaBlend();
ModAddonManager.onWeaponRender(type, EventState.PRE);
SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
if (skin != null) {
ItemStackRenderHelper.renderSkinWithHelper(skin, skinPointer, false, false);
}
ModAddonManager.onWeaponRender(type, EventState.POST);
GL11.glPopAttrib();
GL11.glPopMatrix();
if (type != ItemRenderType.ENTITY) {
GL11.glPushMatrix();
}
} else {
if (itemRenderer != null) {
itemRenderer.renderItem(type, stack, data);
} else {
renderNomalIcon(stack);
}
}
}
use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class ItemStackRenderHelper method renderItemAsArmourModel.
@Deprecated
public static void renderItemAsArmourModel(ItemStack stack, boolean showSkinPaint) {
if (SkinNBTHelper.stackHasSkinData(stack)) {
SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
renderItemModelFromSkinPointer(skinPointer, showSkinPaint, false);
}
}
use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class SkinPreviewHandler method onDrawScreenPost.
@SubscribeEvent
public void onDrawScreenPost(DrawScreenEvent.Pre event) {
if (!ConfigHandlerClient.skinPreEnabled) {
return;
}
if (ConfigHandlerClient.skinPreLocFollowMouse) {
return;
}
SkinPointer skinPointer = lastSkinPointer;
List<String> list = lastList;
lastSkinPointer = null;
lastList = null;
if (skinPointer != null & list != null) {
Minecraft mc = Minecraft.getMinecraft();
float skinPreSize = ConfigHandlerClient.skinPreSize;
float skinPreLocHorizontal = ConfigHandlerClient.skinPreLocHorizontal;
float skinPreLocVertical = ConfigHandlerClient.skinPreLocVertical;
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
double widthClip = sr.getScaledWidth_double() - skinPreSize;
double heightClip = sr.getScaledHeight_double() - skinPreSize;
int x = MathHelper.ceiling_double_int(widthClip * skinPreLocHorizontal);
int y = MathHelper.ceiling_double_int(heightClip * skinPreLocVertical);
drawSkinBox(mc, x, y, skinPreSize, skinPointer);
skinPointer = null;
}
}
use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class EntitySkinHandler method giveRandomSkin.
public void giveRandomSkin(ExPropsEntityEquipmentData entityEquipmentData) {
if (entityEquipmentData == null) {
return;
}
if (ConfigHandler.enitiySpawnWithSkinsChance <= 0) {
return;
}
ArrayList<ISkinType> skinTypes = entityEquipmentData.getSkinInventory().getSkinTypes();
for (int i = 0; i < skinTypes.size(); i++) {
int rnd = entityEquipmentData.getEntity().worldObj.rand.nextInt(99) + 1;
if (rnd >= ConfigHandler.enitiySpawnWithSkinsChance) {
continue;
}
ISkinType skinType = skinTypes.get(i);
LibraryFile libraryFile = getRandomSkinOfType(skinType);
if (libraryFile == null) {
continue;
}
SkinIdentifier identifier = new SkinIdentifier(0, libraryFile, 0, skinType);
ItemStack skinStack = SkinNBTHelper.makeEquipmentSkinStack(new SkinPointer(identifier));
if (skinStack == null) {
continue;
}
entityEquipmentData.getSkinInventory().setInventorySlotContents(i, skinStack);
}
}
Aggregations