mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 20:36:00 +00:00
Merge branch 'patch' into dev
# Conflicts: # src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java # src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java # src/main/java/noppes/npcs/client/renderer/customitem/CustomItemRenderer.java
This commit is contained in:
commit
f5ac14b93e
15 files changed
+334
-101
No files matched your search
@@ -42,6 +42,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
private int posX,posY,posZ;
|
||||
|
||||
private List<String> list;
|
||||
private List<String> rawList;
|
||||
private List<String> tagList;
|
||||
|
||||
private static int showingClones = 0;
|
||||
@@ -181,6 +182,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
}
|
||||
this.list = list;
|
||||
this.rawList = new ArrayList<String>(this.list);
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
private void showClones() {
|
||||
@@ -198,6 +200,26 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
|
||||
this.tagMap = ClientTagMapController.Instance.getTagMap(activeTab);
|
||||
this.rawList = new ArrayList<String>(this.list);
|
||||
if(this.tagMap != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
|
||||
for(int i = 0; i < this.list.size(); i++){
|
||||
StringBuilder npcName = new StringBuilder(list.get(i));
|
||||
if (this.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){
|
||||
Tag tag = tags.get(tagUUID);
|
||||
if(tag != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
|
||||
npcName.append(" [" + tag.name + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.rawList.set(i, npcName.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
public void keyTyped(char c, int i)
|
||||
@@ -222,6 +244,9 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
if(this.list == null){
|
||||
this.list = new ArrayList<String>();
|
||||
}
|
||||
if(this.rawList == null){
|
||||
this.rawList = new ArrayList<String>();
|
||||
}
|
||||
|
||||
// No Filters - or - Entities
|
||||
if(tagFilters.size() == 0 || showingClones == 1){
|
||||
@@ -231,9 +256,10 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
// Yes Search
|
||||
else {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String name : this.list){
|
||||
if(name.toLowerCase().contains(search))
|
||||
list.add(name);
|
||||
for(int i = 0; i < this.list.size(); i++){
|
||||
if(this.rawList.get(i).toLowerCase().contains(search)){
|
||||
list.add(this.list.get(i));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -257,14 +283,16 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
|
||||
// Yes Search
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String name : this.list){
|
||||
if(name.toLowerCase().contains(search)) {
|
||||
if(tagMap.hasClone(name)){
|
||||
if(meetsCondition(name)){
|
||||
list.add(name);
|
||||
for(int i = 0; i < this.list.size(); i++){
|
||||
if(this.rawList.get(i).toLowerCase().contains(search)){
|
||||
String npcName = this.list.get(i);
|
||||
if(tagMap.hasClone(npcName)){
|
||||
if(meetsCondition(npcName)){
|
||||
list.add(npcName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -481,6 +509,27 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
|
||||
this.list = list;
|
||||
|
||||
this.rawList = new ArrayList<String>(this.list);
|
||||
if(this.tagMap != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
|
||||
for(int i = 0; i < this.list.size(); i++){
|
||||
StringBuilder npcName = new StringBuilder(list.get(i));
|
||||
if (this.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){
|
||||
Tag tag = tags.get(tagUUID);
|
||||
if(tag != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
|
||||
npcName.append(" [" + tag.name + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.rawList.set(i, npcName.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
GL11.glRotatef(this.rotation, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||
|
||||
this.imageData.bindTexture();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
|
||||
}
|
||||
|
||||
if((this.parent.getShowingClones() == 0 || this.parent.getShowingClones() == 2) && this.parent.tagMap != null){
|
||||
int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 5;
|
||||
int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 3;
|
||||
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
|
||||
if (this.parent.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tagUUID : this.parent.tagMap.getUUIDsList(list.get(i))){
|
||||
@@ -64,7 +64,7 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
|
||||
if(tag != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
|
||||
fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color);
|
||||
tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 2;
|
||||
tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,15 @@ public class ImageData {
|
||||
}
|
||||
|
||||
public boolean imageLoaded() {
|
||||
if (!this.gotWidthHeight) {
|
||||
try {
|
||||
if (!this.isUrl) {
|
||||
this.getWidthHeight();
|
||||
} else {
|
||||
this.getURLWidthHeight();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
return !this.invalid && this.location != null && this.gotWidthHeight;
|
||||
}
|
||||
|
||||
@@ -70,6 +79,10 @@ public class ImageData {
|
||||
}
|
||||
|
||||
private void getWidthHeight() throws IOException {
|
||||
if (this.invalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
InputStream inputstream = null;
|
||||
|
||||
try {
|
||||
@@ -81,7 +94,7 @@ public class ImageData {
|
||||
this.totalHeight = bufferedimage.getHeight();
|
||||
correctWidthHeight();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.invalid = true;
|
||||
} finally {
|
||||
if (inputstream != null) {
|
||||
inputstream.close();
|
||||
@@ -90,7 +103,7 @@ public class ImageData {
|
||||
}
|
||||
|
||||
private void getURLWidthHeight(){
|
||||
if(this.imageDownloadAlt.getBufferedImage() != null) {
|
||||
if(this.imageDownloadAlt.getBufferedImage() != null && !this.invalid) {
|
||||
this.gotWidthHeight = true;
|
||||
this.totalWidth = this.imageDownloadAlt.getBufferedImage().getWidth();
|
||||
this.totalHeight = this.imageDownloadAlt.getBufferedImage().getHeight();
|
||||
@@ -104,34 +117,10 @@ public class ImageData {
|
||||
}
|
||||
|
||||
public int getTotalWidth() {
|
||||
if (!this.gotWidthHeight) {
|
||||
try {
|
||||
if (!this.isUrl) {
|
||||
this.getWidthHeight();
|
||||
} else {
|
||||
this.getURLWidthHeight();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
if (!this.gotWidthHeight) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return this.totalWidth;
|
||||
return this.gotWidthHeight ? this.totalWidth : -1;
|
||||
}
|
||||
|
||||
public int getTotalHeight() {
|
||||
if (!this.gotWidthHeight) {
|
||||
try {
|
||||
if (!this.isUrl) {
|
||||
this.getWidthHeight();
|
||||
} else {
|
||||
this.getURLWidthHeight();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
if (!this.gotWidthHeight) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return this.totalHeight;
|
||||
return this.gotWidthHeight ? this.totalHeight : -1;
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,6 @@ import noppes.npcs.items.ItemScripted;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
|
||||
import static net.minecraft.client.renderer.entity.RenderItem.renderInFrame;
|
||||
@@ -46,15 +44,10 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
|
||||
ScriptCustomItem scriptCustomItem = ItemScripted.GetWrapper(itemStack);
|
||||
|
||||
BufferedImage bufferedImage = ClientCacheHandler.getImageData(scriptCustomItem.texture).getBufferedImage();
|
||||
if (bufferedImage != null && (scriptCustomItem.width != bufferedImage.getWidth() || scriptCustomItem.height != bufferedImage.getHeight())) {
|
||||
scriptCustomItem.width = bufferedImage.getWidth();
|
||||
scriptCustomItem.height = bufferedImage.getHeight();
|
||||
scriptCustomItem.saveItemData();
|
||||
}
|
||||
|
||||
if(scriptCustomItem.width < 1 || scriptCustomItem.height < 1)
|
||||
ImageData imageData = ClientCacheHandler.getImageData(scriptCustomItem.texture);
|
||||
if (!imageData.imageLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
GL11.glPushMatrix();
|
||||
@@ -77,7 +70,6 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
GL11.glRotatef(scriptCustomItem.rotationYRate * entityRenderTicks%360, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZRate * entityRenderTicks%360, 0, 0, 1);
|
||||
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
GL11.glTranslatef(0.0F, bobbingY, 0.0F);
|
||||
|
||||
int color = scriptCustomItem.getColor();
|
||||
@@ -181,6 +173,7 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F));
|
||||
|
||||
for (int k = 0; k < b0; ++k)
|
||||
@@ -250,6 +243,7 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
for (int l = 0; l < b0; ++l)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
|
||||
if (l > 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user