From 4d5276d8523e5c4771bdde386c9a538ec544d4c5 Mon Sep 17 00:00:00 2001 From: syeyoung <42869671+cyoung06@users.noreply.github.com> Date: Thu, 26 Nov 2020 13:02:20 +0900 Subject: value edit stuff --- .../dungeonsguide/dungeon/data/OffsetPoint.java | 23 +++- .../dungeon/roomfinder/DungeonRoom.java | 5 + .../roomedit/elements/MIntegerSelectionButton.java | 70 +++++++++++ .../roomedit/elements/MParameter.java | 3 +- .../roomedit/gui/GuiDungeonParameterEdit.java | 12 +- .../roomedit/valueedit/ValueEditBoolean.java | 79 +++++++++++++ .../roomedit/valueedit/ValueEditInteger.java | 78 +++++++++++++ .../roomedit/valueedit/ValueEditNull.java | 5 + .../roomedit/valueedit/ValueEditOffsetPoint.java | 130 +++++++++++++++++++++ .../roomedit/valueedit/ValueEditRegistry.java | 5 + .../roomedit/valueedit/ValueEditString.java | 2 + .../syeyoung/dungeonsguide/utils/RenderUtils.java | 69 +++++++++++ 12 files changed, 475 insertions(+), 6 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java (limited to 'src') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java index 49775537..05bc7138 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java @@ -11,12 +11,16 @@ import javax.vecmath.Vector2d; @Data @AllArgsConstructor -public class OffsetPoint { +public class OffsetPoint implements Cloneable { private int x; private int y; private int z; public OffsetPoint(DungeonRoom dungeonRoom, BlockPos pos) { + setPosInWorld(dungeonRoom, pos); + } + + public void setPosInWorld(DungeonRoom dungeonRoom, BlockPos pos) { Vector2d vector2d = new Vector2d(pos.getX(), pos.getZ()); for (int i = 0; i < dungeonRoom.getRoomMatcher().getRotation(); i++) vector2d = VectorUtils.rotateClockwise(vector2d); @@ -47,6 +51,10 @@ public class OffsetPoint { Block b = dungeonRoom.getRelativeBlockAt(relBp.getX(), relBp.getY(), relBp.getZ()); return b; } + public BlockPos getBlockPos(DungeonRoom dungeonRoom) { + BlockPos relBp = toRotatedRelBlockPos(dungeonRoom); + return dungeonRoom.getRelativeBlockPosAt(relBp.getX(), relBp.getY(), relBp.getZ()); + } public int getData(DungeonRoom dungeonRoom) { BlockPos relBp = toRotatedRelBlockPos(dungeonRoom); @@ -54,4 +62,17 @@ public class OffsetPoint { int b = dungeonRoom.getRelativeBlockDataAt(relBp.getX(), relBp.getY(), relBp.getZ()); return b; } + + @Override + public Object clone() throws CloneNotSupportedException { + return new OffsetPoint(x,y,z); + } + + @Override + public String toString() { + return "OffsetPoint{x=" + x + + ", y=" + y + + ", z=" + z + + '}'; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java index 41e2fb6f..2b56b139 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -114,6 +114,11 @@ public class DungeonRoom { return null; } + public BlockPos getRelativeBlockPosAt(int x, int y, int z) { + BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getZ(),min.getZ()); + return pos; + } + public int getRelativeBlockDataAt(int x, int y, int z) { // validate x y z's if (canAccessRelative(x,z)) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java new file mode 100644 index 00000000..9ba6350a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MIntegerSelectionButton.java @@ -0,0 +1,70 @@ +package kr.syeyoung.dungeonsguide.roomedit.elements; + +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; +import java.util.List; + +@Getter +@Setter +public class MIntegerSelectionButton extends MPanel { + + private int data; + + private MButton dec; + private MButton inc; + private MTextField selected; + + @Getter + @Setter + private Runnable onUpdate; + + public MIntegerSelectionButton(int data2) { + this.data = data2; + + dec = new MButton(); dec.setText("<"); add(dec); + inc = new MButton(); inc.setText(">"); add(inc); + selected = new MTextField() { + @Override + public void edit(String str) { + try { + data = Integer.parseInt(str); + } catch (Exception e) {} + } + }; updateSelected(); add(selected); + + dec.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data--; + updateSelected(); + onUpdate.run(); + } + }); + inc.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data ++; + updateSelected(); + onUpdate.run(); + } + }); + } + + public int getSelected() { + return data; + } + + private void updateSelected() { + selected.setText(data+""); + } + + @Override + public void onBoundsUpdate() { + dec.setBounds(new Rectangle(0,0,bounds.height, bounds.height)); + inc.setBounds(new Rectangle(bounds.width - bounds.height, 0, bounds.height, bounds.height)); + selected.setBounds(new Rectangle(bounds.height, 0, bounds.width - bounds.height - bounds.height, bounds.height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java index 13e1c6ed..be6c4303 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java @@ -3,6 +3,7 @@ package kr.syeyoung.dungeonsguide.roomedit.elements; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; import kr.syeyoung.dungeonsguide.roomedit.panes.ProcessorParameterEditPane; import lombok.Getter; import lombok.Setter; @@ -52,7 +53,7 @@ public class MParameter extends MPanel { public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { if (this.bounds.x > -20 && new Rectangle(new Point(0,0),bounds.getSize()).contains(relMouseX, relMouseY)) { // open new gui; - System.out.println("hey I'm "+parameter.getName()+", i'ma open gui"); + EditingContext.getEditingContext().openGui(new GuiDungeonParameterEdit(this, processorParameterEditPane)); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java index 83383954..4798e59d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java @@ -40,6 +40,7 @@ public class GuiDungeonParameterEdit extends GuiScreen { public GuiDungeonParameterEdit(final MParameter parameter2, final ProcessorParameterEditPane processorParameterEditPane) { dungeonRoom = EditingContext.getEditingContext().getRoom(); + mainPanel.setBackgroundColor(new Color(17, 17, 17, 179)); this.parameter = parameter2.getParameter(); { MTextField mTextField = new MTextField() { @@ -51,7 +52,7 @@ public class GuiDungeonParameterEdit extends GuiScreen { MLabelAndElement mLabelAndElement = new MLabelAndElement("Name", mTextField); mTextField.setText(parameter.getName()); - mLabelAndElement.setBounds(new Rectangle(0,20,200, 20)); + mLabelAndElement.setBounds(new Rectangle(0,0,200, 20)); mainPanel.add(mLabelAndElement); } { @@ -59,7 +60,7 @@ public class GuiDungeonParameterEdit extends GuiScreen { final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(ValueEditRegistry.getClassesSupported(), classSelection) { @Override public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, 20, parentWidth,parentHeight - 20)); + setBounds(new Rectangle(0, 20, parentWidth,20)); } }; @@ -123,8 +124,11 @@ public class GuiDungeonParameterEdit extends GuiScreen { currentValueEdit.getChildComponents().clear(); ValueEditCreator valueEditCreator = ValueEditRegistry.getValueEditMap(classSelection); - parameter.setNewData(valueEditCreator.createDefaultValue(parameter)); - parameter.setPreviousData(valueEditCreator.cloneObj(parameter.getNewData())); + + if (!classSelection.equals(parameter.getNewData() == null ?"null" :parameter.getNewData().getClass().getName())) { + parameter.setNewData(valueEditCreator.createDefaultValue(parameter)); + parameter.setPreviousData(valueEditCreator.cloneObj(parameter.getNewData())); + } MPanel valueEdit = (MPanel) valueEditCreator.createValueEdit(parameter); if (valueEdit == null) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java new file mode 100644 index 00000000..7a9b4259 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java @@ -0,0 +1,79 @@ +package kr.syeyoung.dungeonsguide.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; +import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.roomedit.elements.MStringSelectionButton; +import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; +import scala.actors.threadpool.Arrays; + +import java.awt.*; + +public class ValueEditBoolean extends MPanel implements ValueEdit { + private Parameter parameter; + + + public ValueEditBoolean(Parameter parameter2) { + this.parameter = parameter2; + { + MLabel label = new MLabel() { + @Override + public String getText() { + return parameter.getPreviousData().toString(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); + mLabelAndElement.setBounds(new Rectangle(0,0,bounds.width,20)); + add(mLabelAndElement); + } + { + boolean newData = (Boolean) parameter.getNewData(); + final MStringSelectionButton textField = new MStringSelectionButton(Arrays.asList(new String[] {"true", "false"}), Boolean.toString(newData)); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + parameter.setNewData(Boolean.valueOf(textField.getSelected())); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); + mLabelAndElement.setBounds(new Rectangle(0,20,bounds.width,20)); + add(mLabelAndElement); + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(bounds.width, 20)); + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditBoolean createValueEdit(Parameter parameter) { + return new ValueEditBoolean(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return true; + } + + @Override + public Object cloneObj(Object object) { + return object; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java new file mode 100644 index 00000000..7806cafc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java @@ -0,0 +1,78 @@ +package kr.syeyoung.dungeonsguide.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.elements.MIntegerSelectionButton; +import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; +import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; + +import java.awt.*; + +public class ValueEditInteger extends MPanel implements ValueEdit { + private Parameter parameter; + + + public ValueEditInteger(final Parameter parameter2) { + this.parameter = parameter2; + { + MLabel label = new MLabel() { + @Override + public String getText() { + return parameter.getPreviousData().toString(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); + mLabelAndElement.setBounds(new Rectangle(0,0,bounds.width,20)); + add(mLabelAndElement); + } + { + int newData = (Integer) parameter.getNewData(); + final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + parameter.setNewData(textField.getData()); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); + mLabelAndElement.setBounds(new Rectangle(0,20,bounds.width,20)); + add(mLabelAndElement); + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(bounds.width, 20)); + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditInteger createValueEdit(Parameter parameter) { + return new ValueEditInteger(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return 0; + } + + @Override + public Object cloneObj(Object object) { + return object; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java index 42488e98..d71ebc88 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java @@ -12,4 +12,9 @@ public class ValueEditNull implements ValueEditCreator { public ActuallyClonable createDefaultValue(Parameter parameter) { return null; } + + @Override + public Object cloneObj(Object object) { + return null; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java new file mode 100644 index 00000000..c91e0bea --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java @@ -0,0 +1,130 @@ +package kr.syeyoung.dungeonsguide.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import scala.actors.threadpool.Arrays; + +import java.awt.*; + +public class ValueEditOffsetPoint extends MPanel implements ValueEdit { + private Parameter parameter; + + + public ValueEditOffsetPoint(final Parameter parameter2) { + this.parameter = parameter2; + { + MLabel label = new MLabel() { + @Override + public String getText() { + return parameter.getPreviousData().toString(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); + mLabelAndElement.setBounds(new Rectangle(0,0,bounds.width,20)); + add(mLabelAndElement); + } + OffsetPoint newData = (OffsetPoint) parameter.getNewData(); + { + final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getX()); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + ((OffsetPoint) parameter.getNewData()).setX(textField.getData()); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("x",textField); + mLabelAndElement.setBounds(new Rectangle(0,20,bounds.width,20)); + add(mLabelAndElement); + } + { + final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getY()); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + ((OffsetPoint) parameter.getNewData()).setY(textField.getData()); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("y",textField); + mLabelAndElement.setBounds(new Rectangle(0,40,bounds.width,20)); + add(mLabelAndElement); + } + { + final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getZ()); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + ((OffsetPoint) parameter.getNewData()).setX(textField.getData()); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("z",textField); + mLabelAndElement.setBounds(new Rectangle(0,60,bounds.width,20)); + add(mLabelAndElement); + } + { + final MLabel setToHEre = new MLabel() { + @Override + public String getText() { + OffsetPoint offsetPoint = (OffsetPoint) parameter.getNewData(); + return Block.getIdFromBlock(offsetPoint.getBlock(EditingContext.getEditingContext().getRoom())) + + ":" + offsetPoint.getData(EditingContext.getEditingContext().getRoom()); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("newPt",setToHEre); + mLabelAndElement.setBounds(new Rectangle(0,80,bounds.width,20)); + add(mLabelAndElement); + } + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + RenderUtils.highlightBlock2(((OffsetPoint)parameter.getPreviousData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(255,0,0,150), partialTicks); + RenderUtils.highlightBlock2(((OffsetPoint)parameter.getNewData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,0,150), partialTicks); + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(bounds.width, 20)); + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditOffsetPoint createValueEdit(Parameter parameter) { + return new ValueEditOffsetPoint(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((OffsetPoint)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java index 72120c0f..5fd86b22 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java @@ -1,5 +1,7 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -19,5 +21,8 @@ public class ValueEditRegistry { static { valueEditMap.put("null", new ValueEditNull()); valueEditMap.put(String.class.getName(), new ValueEditString.Generator()); + valueEditMap.put(Boolean.class.getName(), new ValueEditBoolean.Generator()); + valueEditMap.put(Integer.class.getName(), new ValueEditInteger.Generator()); + valueEditMap.put(OffsetPoint.class.getName(), new ValueEditOffsetPoint.Generator()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java index e7162a1a..96bb9a4f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java @@ -26,12 +26,14 @@ public class ValueEditString extends MPanel implements ValueEdit { add(mLabelAndElement); } { + String newData = (String) parameter.getNewData(); MTextField textField = new MTextField() { @Override public void edit(String str) { parameter.setNewData(str); } }; + textField.setText(newData); MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); mLabelAndElement.setBounds(new Rectangle(0,20,bounds.width,20)); add(mLabelAndElement); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index 8207e7d7..bc741e04 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -148,6 +148,75 @@ public class RenderUtils { + GL11.glEnd(); + + + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); + + +//... + + } + public static void highlightBlock2(BlockPos blockpos, Color c, float partialTicks) { + + RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); + + Vector3f renderPos = getRenderPos(blockpos.getX(), blockpos.getY(), blockpos.getZ(), partialTicks); + + + GL11.glPushMatrix(); + GlStateManager.pushAttrib(); + GL11.glTranslatef(renderPos.x, renderPos.y, renderPos.z); + GL11.glRotatef(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); + GL11.glRotatef(renderManager.playerViewX, 1.0f, 0.0f, 0.0f); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.disableTexture2D(); + + GL11.glColor4ub((byte)c.getRed(), (byte)c.getGreen(), (byte)c.getBlue(), (byte)c.getAlpha()); + + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 0, 1); + GL11.glVertex3d(0, 1, 1); + GL11.glVertex3d(0, 1, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(1, 0, 1); + GL11.glVertex3d(1, 0, 0); + GL11.glVertex3d(1, 1, 0); + GL11.glVertex3d(1, 1, 1); + + GL11.glVertex3d(0, 1, 1); + GL11.glVertex3d(0, 0, 1); + GL11.glVertex3d(1, 0, 1); + GL11.glVertex3d(1, 1, 1); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 1, 0); + GL11.glVertex3d(1, 1, 0); + GL11.glVertex3d(1, 0, 0); + + GL11.glVertex3d(0,1,0); + GL11.glVertex3d(0,1,1); + GL11.glVertex3d(1,1,1); + GL11.glVertex3d(1,1,0); + + GL11.glVertex3d(0,0,1); + GL11.glVertex3d(0,0,0); + GL11.glVertex3d(1,0,0); + GL11.glVertex3d(1,0,1); + + + GL11.glEnd(); -- cgit