[refactor] Auto-format and cleanup `kami` module

Signed-off-by: Dominika <sokolov.dominika@gmail.com>
This commit is contained in:
Dominika 2020-12-09 13:45:16 -05:00
parent e44307d4de
commit 642d762b23
No known key found for this signature in database
GPG Key ID: B4A5A6DCA70F861F
50 changed files with 439 additions and 441 deletions

View File

@ -82,7 +82,7 @@ public class KamiGUI extends GUI {
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
List<Map.Entry<K, V>> list =
new LinkedList<>(map.entrySet());
new LinkedList<>(map.entrySet());
list.sort(Map.Entry.comparingByValue());
Map<K, V> result = new LinkedHashMap<>();
@ -435,21 +435,21 @@ public class KamiGUI extends GUI {
return;
}
final Map<String, Integer> entityCounts = entityList.stream()
.filter(Objects::nonNull)
.filter(e -> !(e instanceof EntityPlayer))
.collect(Collectors.groupingBy(KamiGUI::getEntityName,
Collectors.reducing(0, ent -> {
if (ent instanceof EntityItem)
return ((EntityItem) ent).getItem().getCount();
return 1;
}, Integer::sum)
));
.filter(Objects::nonNull)
.filter(e -> !(e instanceof EntityPlayer))
.collect(Collectors.groupingBy(KamiGUI::getEntityName,
Collectors.reducing(0, ent -> {
if (ent instanceof EntityItem)
return ((EntityItem) ent).getItem().getCount();
return 1;
}, Integer::sum)
));
entityLabel.setText("");
entityCounts.entrySet().stream()
.sorted(Map.Entry.comparingByValue())
.map(entry -> TextFormatting.GRAY + entry.getKey() + " " + TextFormatting.DARK_GRAY + "x" + entry.getValue())
.forEach(entityLabel::addLine);
.sorted(Map.Entry.comparingByValue())
.map(entry -> TextFormatting.GRAY + entry.getKey() + " " + TextFormatting.DARK_GRAY + "x" + entry.getValue())
.forEach(entityLabel::addLine);
//entityLabel.getParent().setHeight(entityLabel.getLines().length * (entityLabel.getTheme().getFontRenderer().getFontHeight()+1) + 3);
}
@ -463,7 +463,7 @@ public class KamiGUI extends GUI {
/*
* Coordinates
*/
Frame coords = new Frame(getTheme(), new Stretcherlayout(1), "Coordinates");
Frame coords = new Frame(getTheme(), new Stretcherlayout(1), "Coordinates");
coords.setCloseable(false);
coords.setPinnable(true);
Label coordsLabel = new Label("");
@ -489,26 +489,26 @@ public class KamiGUI extends GUI {
/* The 7 and f in the string formatter is the color */
String colouredSeparator = TextFormatting.GRAY + " |" + TextFormatting.RESET;
String ow = String.format(" (%s%,d%s, %s%,d%s, %s%,d%s)",
TextFormatting.WHITE,
posX,
TextFormatting.GRAY,
TextFormatting.WHITE,
posY,
TextFormatting.GRAY,
TextFormatting.WHITE,
posZ,
TextFormatting.GRAY
TextFormatting.WHITE,
posX,
TextFormatting.GRAY,
TextFormatting.WHITE,
posY,
TextFormatting.GRAY,
TextFormatting.WHITE,
posZ,
TextFormatting.GRAY
);
String nether = String.format(" (%s%,d%s, %s%,d%s, %s%,d%s)",
TextFormatting.WHITE,
hposX,
TextFormatting.GRAY,
TextFormatting.WHITE,
posY,
TextFormatting.GRAY,
TextFormatting.WHITE,
hposZ,
TextFormatting.GRAY
TextFormatting.WHITE,
hposX,
TextFormatting.GRAY,
TextFormatting.WHITE,
posY,
TextFormatting.GRAY,
TextFormatting.WHITE,
hposZ,
TextFormatting.GRAY
);
coordsLabel.setText("");
coordsLabel.addLine(ow);

View File

@ -29,4 +29,4 @@ public class ActiveModules extends Label {
}
});
}
};
}

View File

@ -25,19 +25,19 @@ import static me.zeroeightsix.kami.util.color.ColorConverter.toF;
public class KamiActiveModulesUI extends AbstractComponentUI<me.zeroeightsix.kami.gui.kami.component.ActiveModules> {
final ColorGradient transRights = new ColorGradient(
new Pair<>(0f, new ColorHolder(91, 207, 250)), new Pair<>(19.9999999999f, new ColorHolder(91, 207, 250)),
new Pair<>(20f, new ColorHolder(245, 170, 185)), new Pair<>(39.9999999999f, new ColorHolder(245, 170, 185)),
new Pair<>(40f, new ColorHolder(255, 255, 255)), new Pair<>(59.9999999999f, new ColorHolder(255, 255, 255)),
new Pair<>(60f, new ColorHolder(245, 170, 185)), new Pair<>(79.9999999999f, new ColorHolder(245, 170, 185)),
new Pair<>(80f, new ColorHolder(91, 207, 250)), new Pair<>(100f, new ColorHolder(91, 207, 250))
new Pair<>(0f, new ColorHolder(91, 207, 250)), new Pair<>(19.9999999999f, new ColorHolder(91, 207, 250)),
new Pair<>(20f, new ColorHolder(245, 170, 185)), new Pair<>(39.9999999999f, new ColorHolder(245, 170, 185)),
new Pair<>(40f, new ColorHolder(255, 255, 255)), new Pair<>(59.9999999999f, new ColorHolder(255, 255, 255)),
new Pair<>(60f, new ColorHolder(245, 170, 185)), new Pair<>(79.9999999999f, new ColorHolder(245, 170, 185)),
new Pair<>(80f, new ColorHolder(91, 207, 250)), new Pair<>(100f, new ColorHolder(91, 207, 250))
);
@Override
public void renderComponent(me.zeroeightsix.kami.gui.kami.component.ActiveModules component) {
List<Module> modules = ModuleManager.getModules().stream()
.filter(module -> module.isEnabled() && (ActiveModules.INSTANCE.getHidden().getValue() || module.isOnArray()))
.sorted(Comparator.comparing(module -> FontRenderAdapter.INSTANCE.getStringWidth(module.getName().getValue() + (module.getHudInfo() == null ? "" : module.getHudInfo() + " ")) * (component.sort_up ? -1 : 1)))
.collect(Collectors.toList());
.filter(module -> module.isEnabled() && (ActiveModules.INSTANCE.getHidden().getValue() || module.isOnArray()))
.sorted(Comparator.comparing(module -> FontRenderAdapter.INSTANCE.getStringWidth(module.getName().getValue() + (module.getHudInfo() == null ? "" : module.getHudInfo() + " ")) * (component.sort_up ? -1 : 1)))
.collect(Collectors.toList());
int y = 2;
@ -92,8 +92,8 @@ public class KamiActiveModulesUI extends AbstractComponentUI<me.zeroeightsix.kam
String hudInfo = module.getHudInfo();
String text = ActiveModules.INSTANCE.getAlignedText(
module.getName().getValue(), (hudInfo == null ? "" : TextFormatting.GRAY + hudInfo + TextFormatting.RESET),
component.getAlignment().equals(AlignedComponent.Alignment.RIGHT)
module.getName().getValue(), (hudInfo == null ? "" : TextFormatting.GRAY + hudInfo + TextFormatting.RESET),
component.getAlignment().equals(AlignedComponent.Alignment.RIGHT)
);
float textWidth = FontRenderAdapter.INSTANCE.getStringWidth(text);
float textHeight = FontRenderAdapter.INSTANCE.getFontHeight() + 1;

View File

@ -27,9 +27,9 @@ public class KamiEnumButtonUI extends AbstractComponentUI<EnumButton> {
}
ColorHolder color = new ColorHolder(
component.isHovered() ? GuiC.buttonHoveredN.color :
component.isPressed() ? GuiC.buttonPressed.color :
GuiC.buttonHoveredT.color);
component.isHovered() ? GuiC.buttonHoveredN.color :
component.isPressed() ? GuiC.buttonPressed.color :
GuiC.buttonHoveredT.color);
int parts = component.getModes().length;
double step = component.getWidth() / (double) parts;

View File

@ -55,8 +55,8 @@ class KamiPotionUi : AbstractComponentUI<Potions>() {
* Formats name and time based on UI alignment
*/
fun formattedName(right: Boolean) =
if (right) "${TextFormatting.GRAY}${formattedTimeLeft()}${TextFormatting.RESET} ${formattedName()}"
else "${formattedName()} ${TextFormatting.GRAY}${formattedTimeLeft()}"
if (right) "${TextFormatting.GRAY}${formattedTimeLeft()}${TextFormatting.RESET} ${formattedName()}"
else "${formattedName()} ${TextFormatting.GRAY}${formattedTimeLeft()}"
/**
* (min:secs)

View File

@ -16,9 +16,9 @@ public class KamiUnboundSliderUI extends AbstractComponentUI<UnboundSlider> {
String s = component.getText() + ": " + component.getValue();
ColorHolder color = new ColorHolder(
component.isHovered() ? KamiGuiColors.GuiC.buttonHoveredN.color :
component.isPressed() ? KamiGuiColors.GuiC.buttonPressed.color :
KamiGuiColors.GuiC.buttonHoveredT.color);
component.isHovered() ? KamiGuiColors.GuiC.buttonHoveredN.color :
component.isPressed() ? KamiGuiColors.GuiC.buttonPressed.color :
KamiGuiColors.GuiC.buttonHoveredT.color);
FontRenderAdapter.INSTANCE.drawString(s, component.getWidth() / 2f - FontRenderAdapter.INSTANCE.getStringWidth(s) / 2f, 1f, false, color);
}

View File

@ -21,9 +21,9 @@ public class RootButtonUI<T extends Button> extends AbstractComponentUI<Button>
@Override
public void renderComponent(Button component) {
ColorHolder color = new ColorHolder(
component.isHovered() ? KamiGuiColors.GuiC.buttonHoveredN.color :
component.isPressed() ? KamiGuiColors.GuiC.buttonPressed.color :
KamiGuiColors.GuiC.buttonHoveredT.color);
component.isHovered() ? KamiGuiColors.GuiC.buttonHoveredN.color :
component.isPressed() ? KamiGuiColors.GuiC.buttonPressed.color :
KamiGuiColors.GuiC.buttonHoveredT.color);
VertexHelper vertexHelper = new VertexHelper(GlStateUtils.useVbo());

View File

@ -32,10 +32,10 @@ public class RootCheckButtonUI<T extends CheckButton> extends AbstractComponentU
public void renderComponent(CheckButton component) {
String text = component.getName(); // on toggle, toggled, hovered enabled
ColorHolder color = new ColorHolder(
component.isHovered() ? GuiC.buttonHoveredN.color :
component.isPressed() ? GuiC.buttonPressed.color :
component.isToggled() ? GuiC.buttonIdleT.color :
GuiC.buttonHoveredT.color);
component.isHovered() ? GuiC.buttonHoveredN.color :
component.isPressed() ? GuiC.buttonPressed.color :
component.isToggled() ? GuiC.buttonIdleT.color :
GuiC.buttonHoveredT.color);
if (component.isHovered()) {
if (component.hasDescription() && !isSettingsOpen() && Tooltips.INSTANCE.isEnabled()) {
Component componentAt = KamiMod.INSTANCE.getGuiManager().getComponentAt(DisplayGuiScreen.mouseX, DisplayGuiScreen.mouseY);

View File

@ -75,7 +75,7 @@ open class KamiGuiChat(startStringIn: String, historyBufferIn: String?, sentHist
for ((index, chunk) in command.syntaxChunks.withIndex()) {
if (index < args.size - 2) continue
val chunkValue = if (index == args.size - 2) args[index + 1] else null
val chunkValue = if (index == args.size - 2) args[index + 1] else null
val result = chunk.getChunk(command.syntaxChunks, chunk, args, chunkValue)
val space = if (result.isEmpty()) "" else " "

View File

@ -21,7 +21,7 @@ class KamiGuiDisconnected(private val reason: Array<String>, private val screen:
override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {
drawBackground(0)
drawCenteredString(fontRenderer, "[AutoLog] Logged because:", width / 2, 80, 0x9B90FF)
for ((index , reason) in reason.withIndex()) {
for ((index, reason) in reason.withIndex()) {
drawCenteredString(fontRenderer, reason, width / 2, 94 + (14 * index), 0xFFFFFF)
}

View File

@ -5,7 +5,7 @@ import me.zeroeightsix.kami.util.Wrapper
import net.minecraft.client.gui.GuiButton
class KamiGuiStealButton(x: Int, y: Int) :
GuiButton(696969, x, y, 50, 20, "Steal") {
GuiButton(696969, x, y, 50, 20, "Steal") {
override fun mouseReleased(mouseX: Int, mouseY: Int) {
if (ChestStealer.stealMode.value === ChestStealer.StealMode.MANUAL) {
ChestStealer.stealing = false

View File

@ -371,8 +371,8 @@ public abstract class GUI extends AbstractContainer {
}
return new int[]{
realX,
realY
realX,
realY
};
}
}

View File

@ -29,7 +29,7 @@ public abstract class AbstractComponent implements Component {
int maxHeight = Integer.MAX_VALUE;
protected int priority = 0;
private Setting<Boolean> visible = Settings.b("Visible", true);
private final Setting<Boolean> visible = Settings.b("Visible", true);
float opacity = 1f;
private boolean focus = false;
ComponentUI ui;
@ -306,7 +306,7 @@ public abstract class AbstractComponent implements Component {
boolean liesin = false;
if (component instanceof Container)
liesin = liesIn((Container) component);
liesin = liesIn(component);
if (liesin) return true;
}
return false;

View File

@ -6,7 +6,7 @@ package me.zeroeightsix.kami.gui.rgui.component;
public class AlignedComponent extends AbstractComponent {
Alignment alignment;
public static enum Alignment {
public enum Alignment {
LEFT(0), CENTER(1), RIGHT(2);
int index;

View File

@ -14,96 +14,96 @@ import java.util.ArrayList;
*/
public interface Component {
// Getters for location and size
public int getX(); // Relative to its parent.
int getX(); // Relative to its parent.
public int getY();
int getY();
public int getWidth();
int getWidth();
public int getHeight();
int getHeight();
// Setters for location and size
public void setX(int x);
void setX(int x);
public void setY(int y);
void setY(int y);
public void setWidth(int width);
void setWidth(int width);
public void setHeight(int height);
void setHeight(int height);
public Component setMinimumWidth(int width);
Component setMinimumWidth(int width);
public Component setMaximumWidth(int width);
Component setMaximumWidth(int width);
public Component setMinimumHeight(int height);
Component setMinimumHeight(int height);
public Component setMaximumHeight(int height);
Component setMaximumHeight(int height);
public int getMinimumWidth();
int getMinimumWidth();
public int getMaximumWidth();
int getMaximumWidth();
public int getMinimumHeight();
int getMinimumHeight();
public int getMaximumHeight();
int getMaximumHeight();
public float getOpacity();
float getOpacity();
public void setOpacity(float opacity);
void setOpacity(float opacity);
public boolean doAffectLayout();
boolean doAffectLayout();
public void setAffectLayout(boolean flag);
void setAffectLayout(boolean flag);
public Container getParent();
Container getParent();
public void setParent(Container parent);
void setParent(Container parent);
public boolean liesIn(Component container);
boolean liesIn(Component container);
public boolean isVisible();
boolean isVisible();
public void setVisible(boolean visible);
void setVisible(boolean visible);
public void setFocused(boolean focus);
void setFocused(boolean focus);
public boolean isFocused();
boolean isFocused();
public ComponentUI getUI();
ComponentUI getUI();
public Theme getTheme();
Theme getTheme();
public void setTheme(Theme theme);
void setTheme(Theme theme);
public boolean isHovered();
boolean isHovered();
public boolean isPressed();
boolean isPressed();
public ArrayList<MouseListener> getMouseListeners();
ArrayList<MouseListener> getMouseListeners();
public void addMouseListener(MouseListener listener);
void addMouseListener(MouseListener listener);
public ArrayList<RenderListener> getRenderListeners();
ArrayList<RenderListener> getRenderListeners();
public void addRenderListener(RenderListener listener);
void addRenderListener(RenderListener listener);
public ArrayList<KeyListener> getKeyListeners();
ArrayList<KeyListener> getKeyListeners();
public void addKeyListener(KeyListener listener);
void addKeyListener(KeyListener listener);
public ArrayList<UpdateListener> getUpdateListeners();
ArrayList<UpdateListener> getUpdateListeners();
public void addUpdateListener(UpdateListener listener);
void addUpdateListener(UpdateListener listener);
public ArrayList<TickListener> getTickListeners();
ArrayList<TickListener> getTickListeners();
public void addTickListener(TickListener listener);
void addTickListener(TickListener listener);
public void addPoof(IPoof poof);
void addPoof(IPoof poof);
public void callPoof(Class<? extends IPoof> target, PoofInfo info);
void callPoof(Class<? extends IPoof> target, PoofInfo info);
public int getPriority(); // The higher, the more prioritized.
int getPriority(); // The higher, the more prioritized.
public void kill();
void kill();
}

View File

@ -8,21 +8,21 @@ import java.util.ArrayList;
* Created by 086 on 25/06/2017.
*/
public interface Container extends Component {
public ArrayList<Component> getChildren();
ArrayList<Component> getChildren();
public Component getComponentAt(int x, int y);
Component getComponentAt(int x, int y);
public Container addChild(Component... component);
Container addChild(Component... component);
public Container removeChild(Component component);
Container removeChild(Component component);
public boolean hasChild(Component component);
boolean hasChild(Component component);
public void renderChildren();
void renderChildren();
public int getOriginOffsetX();
int getOriginOffsetX();
public int getOriginOffsetY();
int getOriginOffsetY();
public boolean penetrateTest(int x, int y);
boolean penetrateTest(int x, int y);
}

View File

@ -121,10 +121,7 @@ public class Frame extends OrganisedContainer {
public void onMouseDown(MouseButtonEvent event) {
dx = event.getX() + getOriginOffsetX();
dy = event.getY() + getOriginOffsetY();
if (dy <= getOriginOffsetY() && event.getButton() == 0 && dy > 0)
doDrag = true;
else
doDrag = false;
doDrag = dy <= getOriginOffsetY() && event.getButton() == 0 && dy > 0;
if (isMinimized && event.getY() > getOriginOffsetY())
event.cancel();

View File

@ -54,10 +54,10 @@ public class Scrollpane extends OrganisedContainer {
int[] real = GUI.calculateRealPosition(Scrollpane.this);
double scale = DisplayGuiScreen.getScale();
GL11.glScissor(
(int) (getX() * scale + real[0] * scale - getParent().getOriginOffsetX() - 1),
(int) (Display.getHeight() - getHeight() * scale - real[1] * scale - 1),
(int) (getWidth() * scale + getParent().getOriginOffsetX() * scale + 1),
(int) (getHeight() * scale + 1));
(int) (getX() * scale + real[0] * scale - getParent().getOriginOffsetX() - 1),
(int) (Display.getHeight() - getHeight() * scale - real[1] * scale - 1),
(int) (getWidth() * scale + getParent().getOriginOffsetX() * scale + 1),
(int) (getHeight() * scale + 1));
GL11.glEnable(GL11.GL_SCISSOR_TEST);
}

View File

@ -5,11 +5,11 @@ package me.zeroeightsix.kami.gui.rgui.component.listen;
*/
public interface KeyListener {
public void onKeyDown(KeyEvent event);
void onKeyDown(KeyEvent event);
public void onKeyUp(KeyEvent event);
void onKeyUp(KeyEvent event);
public static class KeyEvent {
class KeyEvent {
int key;
public KeyEvent(int key) {

View File

@ -6,17 +6,17 @@ import me.zeroeightsix.kami.gui.rgui.component.Component;
* Created by 086 on 26/06/2017.
*/
public interface MouseListener {
public void onMouseDown(MouseButtonEvent event);
void onMouseDown(MouseButtonEvent event);
public void onMouseRelease(MouseButtonEvent event);
void onMouseRelease(MouseButtonEvent event);
public void onMouseDrag(MouseButtonEvent event);
void onMouseDrag(MouseButtonEvent event);
public void onMouseMove(MouseMoveEvent event);
void onMouseMove(MouseMoveEvent event);
public void onScroll(MouseScrollEvent event);
void onScroll(MouseScrollEvent event);
public static class MouseMoveEvent {
class MouseMoveEvent {
boolean cancelled = false;
int x;
int y;
@ -65,7 +65,7 @@ public interface MouseListener {
}
}
public static class MouseButtonEvent {
class MouseButtonEvent {
int x;
int y;
int button;
@ -117,7 +117,7 @@ public interface MouseListener {
}
}
public static class MouseScrollEvent {
class MouseScrollEvent {
int x;
int y;
boolean up;

View File

@ -4,7 +4,7 @@ package me.zeroeightsix.kami.gui.rgui.component.listen;
* Created by 086 on 26/06/2017.
*/
public interface RenderListener {
public void onPreRender();
void onPreRender();
public void onPostRender();
void onPostRender();
}

View File

@ -6,7 +6,7 @@ import me.zeroeightsix.kami.gui.rgui.component.Component;
* Created by 086 on 3/08/2017.
*/
public interface UpdateListener<T extends Component> {
public void updateSize(T component, int oldWidth, int oldHeight);
void updateSize(T component, int oldWidth, int oldHeight);
public void updateLocation(T component, int oldX, int oldY);
void updateLocation(T component, int oldX, int oldY);
}

View File

@ -68,10 +68,10 @@ public class InputField extends AbstractComponent {
int[] real = GUI.calculateRealPosition(InputField.this);
double scale = DisplayGuiScreen.getScale();
glScissor(
(int) (real[0] * scale - getParent().getOriginOffsetX() - 1),
(int) (Display.getHeight() - getHeight() * scale - real[1] * scale - 1),
(int) (getWidth() * scale + getParent().getOriginOffsetX() + 1),
(int) (getHeight() * scale + 1));
(int) (real[0] * scale - getParent().getOriginOffsetX() - 1),
(int) (Display.getHeight() - getHeight() * scale - real[1] * scale - 1),
(int) (getWidth() * scale + getParent().getOriginOffsetX() + 1),
(int) (getHeight() * scale + 1));
glEnable(GL_SCISSOR_TEST);
glTranslatef(-scrollX, 0, 0);

View File

@ -7,6 +7,6 @@ import me.zeroeightsix.kami.gui.rgui.component.container.Container;
*/
public interface Layout {
public void organiseContainer(Container container);
void organiseContainer(Container container);
}

View File

@ -6,9 +6,9 @@ import me.zeroeightsix.kami.gui.rgui.component.Component;
* Created by 086 on 21/07/2017.
*/
public interface IPoof<T extends Component, S extends PoofInfo> {
public void execute(T component, S info);
void execute(T component, S info);
public Class getComponentClass();
Class getComponentClass();
public Class getInfoClass();
Class getInfoClass();
}

View File

@ -8,7 +8,7 @@ import me.zeroeightsix.kami.gui.rgui.poof.PoofInfo;
*/
public abstract class FramePoof<T extends Component, S extends PoofInfo> extends Poof<T, S> {
public static class FramePoofInfo extends PoofInfo {
private Action action;
private final Action action;
public FramePoofInfo(Action action) {
this.action = action;

View File

@ -12,14 +12,14 @@ import java.lang.reflect.ParameterizedType;
*/
public abstract class Poof<T extends Component, S extends PoofInfo> implements IPoof<T, S> {
private Class<T> componentclass;
private Class<S> infoclass;
private final Class<T> componentclass;
private final Class<S> infoclass;
public Poof() {
this.componentclass = (Class<T>) ((ParameterizedType) getClass()
.getGenericSuperclass()).getActualTypeArguments()[0];
.getGenericSuperclass()).getActualTypeArguments()[0];
this.infoclass = (Class<S>) ((ParameterizedType) getClass()
.getGenericSuperclass()).getActualTypeArguments()[1];
.getGenericSuperclass()).getActualTypeArguments()[1];
}
@Override

View File

@ -14,7 +14,7 @@ public abstract class AbstractComponentUI<T extends Component> implements Compon
public AbstractComponentUI() {
this.persistentClass = (Class<T>) ((ParameterizedType) getClass()
.getGenericSuperclass()).getActualTypeArguments()[0];
.getGenericSuperclass()).getActualTypeArguments()[0];
}
@Override

View File

@ -69,11 +69,11 @@ public class Framebuffer {
int texture = GL11.glGenTextures();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, width, height,
0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0,
texture, 0);
texture, 0);
return texture;
}
@ -81,11 +81,11 @@ public class Framebuffer {
int texture = GL11.glGenTextures();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT32, width, height,
0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null);
0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT,
texture, 0);
texture, 0);
return texture;
}
@ -93,9 +93,9 @@ public class Framebuffer {
int depthBuffer = GL30.glGenRenderbuffers();
GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthBuffer);
GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, width,
height);
height);
GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT,
GL30.GL_RENDERBUFFER, depthBuffer);
GL30.GL_RENDERBUFFER, depthBuffer);
return depthBuffer;
}

View File

@ -8,10 +8,10 @@ import org.lwjgl.input.Keyboard
* Updated by Xiaro on 08/18/20
*/
class Bind(
var isCtrl: Boolean,
var isAlt: Boolean,
var isShift: Boolean,
var key: Int
var isCtrl: Boolean,
var isAlt: Boolean,
var isShift: Boolean,
var key: Int
) {
val isEmpty: Boolean get() = !isCtrl && !isShift && !isAlt && key < 0

View File

@ -20,36 +20,36 @@ import kotlin.math.floor
*/
object BlockUtils {
val blackList = listOf(
Blocks.ENDER_CHEST,
Blocks.CHEST,
Blocks.TRAPPED_CHEST,
Blocks.CRAFTING_TABLE,
Blocks.ANVIL,
Blocks.BREWING_STAND,
Blocks.HOPPER,
Blocks.DROPPER,
Blocks.DISPENSER,
Blocks.TRAPDOOR,
Blocks.ENCHANTING_TABLE
Blocks.ENDER_CHEST,
Blocks.CHEST,
Blocks.TRAPPED_CHEST,
Blocks.CRAFTING_TABLE,
Blocks.ANVIL,
Blocks.BREWING_STAND,
Blocks.HOPPER,
Blocks.DROPPER,
Blocks.DISPENSER,
Blocks.TRAPDOOR,
Blocks.ENCHANTING_TABLE
)
val shulkerList = listOf(
Blocks.WHITE_SHULKER_BOX,
Blocks.ORANGE_SHULKER_BOX,
Blocks.MAGENTA_SHULKER_BOX,
Blocks.LIGHT_BLUE_SHULKER_BOX,
Blocks.YELLOW_SHULKER_BOX,
Blocks.LIME_SHULKER_BOX,
Blocks.PINK_SHULKER_BOX,
Blocks.GRAY_SHULKER_BOX,
Blocks.SILVER_SHULKER_BOX,
Blocks.CYAN_SHULKER_BOX,
Blocks.PURPLE_SHULKER_BOX,
Blocks.BLUE_SHULKER_BOX,
Blocks.BROWN_SHULKER_BOX,
Blocks.GREEN_SHULKER_BOX,
Blocks.RED_SHULKER_BOX,
Blocks.BLACK_SHULKER_BOX
Blocks.WHITE_SHULKER_BOX,
Blocks.ORANGE_SHULKER_BOX,
Blocks.MAGENTA_SHULKER_BOX,
Blocks.LIGHT_BLUE_SHULKER_BOX,
Blocks.YELLOW_SHULKER_BOX,
Blocks.LIME_SHULKER_BOX,
Blocks.PINK_SHULKER_BOX,
Blocks.GRAY_SHULKER_BOX,
Blocks.SILVER_SHULKER_BOX,
Blocks.CYAN_SHULKER_BOX,
Blocks.PURPLE_SHULKER_BOX,
Blocks.BLUE_SHULKER_BOX,
Blocks.BROWN_SHULKER_BOX,
Blocks.GREEN_SHULKER_BOX,
Blocks.RED_SHULKER_BOX,
Blocks.BLACK_SHULKER_BOX
)
private val mc = Minecraft.getMinecraft()
@ -137,7 +137,7 @@ object BlockUtils {
* @return true playing is not colliding with [pos] and there is block below it
*/
fun isPlaceable(pos: BlockPos, ignoreSelfCollide: Boolean = false) = mc.world.getBlockState(pos).material.isReplaceable
&& mc.world.checkNoEntityCollision(AxisAlignedBB(pos), if (ignoreSelfCollide) mc.player else null)
&& mc.world.checkNoEntityCollision(AxisAlignedBB(pos), if (ignoreSelfCollide) mc.player else null)
/**
* Checks if given [pos] is able to chest (air above) block in it
@ -153,7 +153,7 @@ object BlockUtils {
val placed = HashSet<BlockPos>()
var placeCount = 0
while (getPlaceInfo(emptyHashSet) != null) {
val placingInfo = getPlaceInfo(placed) ?: getPlaceInfo(emptyHashSet)?: break
val placingInfo = getPlaceInfo(placed) ?: getPlaceInfo(emptyHashSet) ?: break
placeCount++
placed.add(placingInfo.second.offset(placingInfo.first))
doPlace(placingInfo.second, placingInfo.first, placeSpeed)

View File

@ -141,9 +141,9 @@ object ConfigUtils {
val gui = KamiMod.INSTANCE.guiStateSetting.value
for ((key, value) in gui.entrySet()) {
val optional = KamiMod.INSTANCE.guiManager.children.stream()
.filter { component: Component? -> component is Frame }
.filter { component: Component -> (component as Frame).title == key }
.findFirst()
.filter { component: Component? -> component is Frame }
.filter { component: Component -> (component as Frame).title == key }
.findFirst()
if (optional.isPresent) {
val `object` = value.asJsonObject
val frame = optional.get() as Frame
@ -169,17 +169,17 @@ object ConfigUtils {
private fun saveConfigurationUnsafe() {
val jsonObject = JsonObject()
KamiMod.INSTANCE.guiManager.children.stream()
.filter { component: Component? -> component is Frame }
.map { component: Component? -> component as Frame? }
.forEach { frame ->
val frameObject = JsonObject()
frameObject.add("x", JsonPrimitive(frame!!.x))
frameObject.add("y", JsonPrimitive(frame.y))
frameObject.add("docking", JsonPrimitive(listOf(*Docking.values()).indexOf(frame.docking)))
frameObject.add("minimized", JsonPrimitive(frame.isMinimized))
frameObject.add("pinned", JsonPrimitive(frame.isPinned))
jsonObject.add(frame.title, frameObject)
}
.filter { component: Component? -> component is Frame }
.map { component: Component? -> component as Frame? }
.forEach { frame ->
val frameObject = JsonObject()
frameObject.add("x", JsonPrimitive(frame!!.x))
frameObject.add("y", JsonPrimitive(frame.y))
frameObject.add("docking", JsonPrimitive(listOf(*Docking.values()).indexOf(frame.docking)))
frameObject.add("minimized", JsonPrimitive(frame.isMinimized))
frameObject.add("pinned", JsonPrimitive(frame.isPinned))
jsonObject.add(frame.title, frameObject)
}
KamiMod.INSTANCE.guiStateSetting.value = jsonObject
val outputFile = Paths.get(getConfigName())
if (!Files.exists(outputFile)) Files.createFile(outputFile)

View File

@ -11,7 +11,7 @@ object EnchantmentUtils {
fun getAllEnchantments(itemStack: ItemStack): List<LeveledEnchantment> {
val enchantmentList = ArrayList<LeveledEnchantment>()
val nbtTagList = (if (itemStack.getItem() == Items.ENCHANTED_BOOK) itemStack.tagCompound?.getTagList("StoredEnchantments", 10)
else itemStack.enchantmentTagList)?: return enchantmentList
else itemStack.enchantmentTagList) ?: return enchantmentList
for (i in 0 until nbtTagList.tagCount()) {
val compound = nbtTagList.getCompoundTagAt(i)

View File

@ -9,7 +9,7 @@ object InfoCalculator {
private val mc = Wrapper.minecraft
fun getServerType() = if (mc.isIntegratedServerRunning) "Singleplayer" else mc.currentServerData?.serverIP
?: "Main Menu"
?: "Main Menu"
@JvmStatic
fun ping() = mc.player?.let { mc.connection?.getPlayerInfo(it.uniqueID)?.responseTime ?: 1 } ?: -1

View File

@ -37,7 +37,7 @@ object InventoryUtils {
mc.player?.inventory?.mainInventory?.let {
val clonedList = ArrayList(it)
for (i in min..max) {
if (Item.getIdFromItem(clonedList[i].getItem()) != itemID) continue
if (Item.getIdFromItem(clonedList[i].item) != itemID) continue
slots.add(i)
}
}
@ -62,7 +62,7 @@ object InventoryUtils {
mc.player?.openContainer?.inventory?.let {
val clonedList = ArrayList(it)
for (i in min..max) {
if (Item.getIdFromItem(clonedList[i].getItem()) != itemId) continue
if (Item.getIdFromItem(clonedList[i].item) != itemId) continue
slots.add(i)
}
}
@ -100,7 +100,7 @@ object InventoryUtils {
mc.player?.inventoryContainer?.inventory?.let {
val clonedList = ArrayList(it)
for (i in min..max) {
if (Item.getIdFromItem(clonedList[i].getItem()) != itemId) continue
if (Item.getIdFromItem(clonedList[i].item) != itemId) continue
slots.add(i)
}
}
@ -148,7 +148,7 @@ object InventoryUtils {
val clonedList = ArrayList(it)
for (i in min..max) {
val itemStack = clonedList.getOrNull(i) ?: continue
if (Item.getIdFromItem(itemStack.getItem()) != itemId) continue
if (Item.getIdFromItem(itemStack.item) != itemId) continue
currentCount += if (itemId == 0) 1 else itemStack.count
}
}
@ -184,7 +184,7 @@ object InventoryUtils {
val clonedList = ArrayList(it)
for (i in 36..44) { /* Finds slot contains no exception item first */
val itemStack = clonedList[i]
if (Item.getIdFromItem(itemStack.getItem()) != exceptionID) {
if (Item.getIdFromItem(itemStack.item) != exceptionID) {
slot2 = i
break
}
@ -207,9 +207,9 @@ object InventoryUtils {
*/
fun moveToSlot(windowId: Int, slotFrom: Int, slotTo: Int): ShortArray {
return shortArrayOf(
inventoryClick(windowId, slotFrom, type = ClickType.PICKUP),
inventoryClick(windowId, slotTo, type = ClickType.PICKUP),
inventoryClick(windowId, slotFrom, type = ClickType.PICKUP)
inventoryClick(windowId, slotFrom, type = ClickType.PICKUP),
inventoryClick(windowId, slotTo, type = ClickType.PICKUP),
inventoryClick(windowId, slotFrom, type = ClickType.PICKUP)
)
}
@ -256,10 +256,10 @@ object InventoryUtils {
* Put the item currently holding by mouse to somewhere or throw it
*/
fun removeHoldingItem() {
if (mc.player?.inventory?.getItemStack()?.isEmpty() != false) return
if (mc.player?.inventory?.itemStack?.isEmpty != false) return
val slot = (getSlotsFullInv(9, 45, 0) // Get empty slots in inventory and offhand
?: getSlotsFullInv(1, 4, 0))?.get(0) // Get empty slots in crafting slot
?: -999 // Throw on the ground
?: getSlotsFullInv(1, 4, 0))?.get(0) // Get empty slots in crafting slot
?: -999 // Throw on the ground
inventoryClick(slot = slot, type = ClickType.PICKUP)
}

View File

@ -3,10 +3,10 @@ package me.zeroeightsix.kami.util
import java.io.Serializable
data class Quad<out A, out B, out C, out D>(
val first: A,
val second: B,
val third: C,
val fourth: D
val first: A,
val second: B,
val third: C,
val fourth: D
) : Serializable {
override fun toString(): String = "($first, $second, $third, $fourth)"
}

View File

@ -41,8 +41,8 @@ object CrystalUtils {
fun canPlace(pos: BlockPos, entity: EntityLivingBase? = null): Boolean {
val placeBB = getCrystalPlacingBB(pos.up())
return canPlaceOn(pos)
&& (entity == null || !placeBB.intersects(entity.entityBoundingBox))
&& mc.world?.checkBlockCollision(placeBB) == false
&& (entity == null || !placeBB.intersects(entity.entityBoundingBox))
&& mc.world?.checkBlockCollision(placeBB) == false
}
/** Checks if the block is valid for placing crystal */
@ -66,10 +66,10 @@ object CrystalUtils {
/* Damage calculation */
fun calcDamage(crystal: EntityEnderCrystal, entity: EntityLivingBase, entityPos: Vec3d? = entity.positionVector, entityBB: AxisAlignedBB? = entity.entityBoundingBox) =
calcDamage(crystal.positionVector, entity, entityPos, entityBB)
calcDamage(crystal.positionVector, entity, entityPos, entityBB)
fun calcDamage(pos: BlockPos, entity: EntityLivingBase, entityPos: Vec3d? = entity.positionVector, entityBB: AxisAlignedBB? = entity.entityBoundingBox) =
calcDamage(Vec3d(pos).add(0.5, 1.0, 0.5), entity, entityPos, entityBB)
calcDamage(Vec3d(pos).add(0.5, 1.0, 0.5), entity, entityPos, entityBB)
fun calcDamage(pos: Vec3d, entity: EntityLivingBase, entityPos: Vec3d? = entity.positionVector, entityBB: AxisAlignedBB? = entity.entityBoundingBox): Float {
// Return 0 directly if entity is a player and in creative mode
@ -90,15 +90,15 @@ object CrystalUtils {
private fun calcRawDamage(pos: Vec3d, entityPos: Vec3d, entityBB: AxisAlignedBB): Float {
val distance = pos.distanceTo(entityPos)
val v = (1.0 - (distance / 12.0)) * (mc.world?.getBlockDensity(pos, entityBB)?: return 0.0f)
val v = (1.0 - (distance / 12.0)) * (mc.world?.getBlockDensity(pos, entityBB) ?: return 0.0f)
return ((v * v + v) / 2.0 * 84.0 + 1.0).toFloat()
}
private fun getDamageSource(damagePos: Vec3d) =
mc.world?.let { world ->
mc.player?.let {
DamageSource.causeExplosionDamage(Explosion(world, it, damagePos.x, damagePos.y, damagePos.z, 6F, false, true))
}
mc.world?.let { world ->
mc.player?.let {
DamageSource.causeExplosionDamage(Explosion(world, it, damagePos.x, damagePos.y, damagePos.z, 6F, false, true))
}
}
/* End of damage calculation */
}

View File

@ -20,19 +20,19 @@ object SurroundUtils {
@JvmStatic
val surroundOffset = arrayOf(
BlockPos(0, -1, 0), // down
BlockPos(0, 0, -1), // north
BlockPos(1, 0, 0), // east
BlockPos(0, 0, 1), // south
BlockPos(-1, 0, 0) // west
BlockPos(0, -1, 0), // down
BlockPos(0, 0, -1), // north
BlockPos(1, 0, 0), // east
BlockPos(0, 0, 1), // south
BlockPos(-1, 0, 0) // west
)
@JvmStatic
val surroundOffsetNoFloor = arrayOf(
BlockPos(0, 0, -1), // north
BlockPos(1, 0, 0), // east
BlockPos(0, 0, 1), // south
BlockPos(-1, 0, 0) // west
BlockPos(0, 0, -1), // north
BlockPos(1, 0, 0), // east
BlockPos(0, 0, 1), // south
BlockPos(-1, 0, 0) // west
)
@JvmStatic

View File

@ -19,9 +19,9 @@ class Listener<T : Any>(val event: Class<T>, val priority: Int, private val func
}
override fun equals(other: Any?) = this === other
|| (other is Listener<*>
&& other.event == this.event
&& other.function == this.function)
|| (other is Listener<*>
&& other.event == this.event
&& other.function == this.function)
override fun hashCode(): Int {
return 31 * event.hashCode() + function.hashCode()

View File

@ -11,7 +11,7 @@ object GlStateUtils {
@JvmStatic
var colorLock = false
private set
private set
@JvmStatic
fun useVbo(): Boolean {

View File

@ -98,7 +98,7 @@ object KamiTessellator : Tessellator(0x200000) {
val camPos: Vec3d
get() = EntityUtils.getInterpolatedPos(mc.renderViewEntity
?: mc.player, pTicks()).add(ActiveRenderInfo.getCameraPosition())
?: mc.player, pTicks()).add(ActiveRenderInfo.getCameraPosition())
/**
* @author Xiaro
@ -200,10 +200,10 @@ object KamiTessellator : Tessellator(0x200000) {
fun toLines(): Array<Pair<Vec3d, Vec3d>> {
val quad = this.toQuad()
return arrayOf(
Pair(quad[0], quad[1]),
Pair(quad[1], quad[2]),
Pair(quad[2], quad[3]),
Pair(quad[3], quad[0])
Pair(quad[0], quad[1]),
Pair(quad[1], quad[2]),
Pair(quad[2], quad[3]),
Pair(quad[3], quad[0])
)
}
@ -223,10 +223,10 @@ object KamiTessellator : Tessellator(0x200000) {
fun to2DQuad(): Array<Vec3d> {
return arrayOf(
Vec3d(this.minX, this.y, this.minZ),
Vec3d(this.minX, this.y, this.maxZ),
Vec3d(this.maxX, this.y, this.maxZ),
Vec3d(this.maxX, this.y, this.minZ)
Vec3d(this.minX, this.y, this.minZ),
Vec3d(this.minX, this.y, this.maxZ),
Vec3d(this.maxX, this.y, this.maxZ),
Vec3d(this.maxX, this.y, this.minZ)
)
}
}

View File

@ -222,56 +222,56 @@ class FontGlyphs(val style: Style, private val font: Font, private val fallbackF
class CharInfoBuilder(val posX: Int, val posY: Int, val width: Int, val height: Int) {
fun build(textureHeight: Double): CharInfo {
return CharInfo(
posX.toDouble(),
posY.toDouble(),
width.toDouble(),
height.toDouble(),
posX / TEXTURE_WIDTH_DOUBLE,
posY / textureHeight,
(posX + width) / TEXTURE_WIDTH_DOUBLE,
(posY + height) / textureHeight
posX.toDouble(),
posY.toDouble(),
width.toDouble(),
height.toDouble(),
posX / TEXTURE_WIDTH_DOUBLE,
posY / textureHeight,
(posX + width) / TEXTURE_WIDTH_DOUBLE,
(posY + height) / textureHeight
)
}
}
data class CharInfo(
/** Character's stored x position */
val posX1: Double,
/** Character's stored x position */
val posX1: Double,
/** Character's stored y position */
val posY1: Double,
/** Character's stored y position */
val posY1: Double,
/** Character's width */
val width: Double,
/** Character's width */
val width: Double,
/** Character's height */
val height: Double,
/** Character's height */
val height: Double,
/** Upper left u */
val u1: Double,
/** Upper left u */
val u1: Double,
/** Upper left v */
val v1: Double,
/** Upper left v */
val v1: Double,
/** Lower right u */
val u2: Double,
/** Lower right u */
val u2: Double,
/** Lower right v */
val v2: Double
/** Lower right v */
val v2: Double
)
data class GlyphChunk(
/** Id of this chunk */
val chunk: Int,
/** Id of this chunk */
val chunk: Int,
/** Texture id of the chunk texture */
val textureId: Int,
/** Texture id of the chunk texture */
val textureId: Int,
/** Dynamic texture object */
val dynamicTexture: DynamicTexture,
/** Dynamic texture object */
val dynamicTexture: DynamicTexture,
/** Array for all characters' info in this chunk */
val charInfoArray: Array<CharInfo>
/** Array for all characters' info in this chunk */
val charInfoArray: Array<CharInfo>
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true

View File

@ -79,11 +79,11 @@ object KamiFontRenderer {
/** All for the KAMI Blue kanji */
private val fallbackFonts = arrayOf(
"Noto Sans JP", "Noto Sans CJK JP", "Noto Sans CJK JP", "Noto Sans CJK KR", "Noto Sans CJK SC", "Noto Sans CJK TC", // Noto Sans
"Source Han Sans", "Source Han Sans HC", "Source Han Sans SC", "Source Han Sans TC", "Source Han Sans K", // Source Sans
"MS Gothic", "Meiryo", "Yu Gothic", // For Windows, Windows on top!
"Hiragino Sans GB W3", "Hiragino Kaku Gothic Pro W3", "Hiragino Kaku Gothic ProN W3", "Osaka", // For stupid Mac OSX
"TakaoPGothic", "IPAPGothic" // For cringy Linux
"Noto Sans JP", "Noto Sans CJK JP", "Noto Sans CJK JP", "Noto Sans CJK KR", "Noto Sans CJK SC", "Noto Sans CJK TC", // Noto Sans
"Source Han Sans", "Source Han Sans HC", "Source Han Sans SC", "Source Han Sans TC", "Source Han Sans K", // Source Sans
"MS Gothic", "Meiryo", "Yu Gothic", // For Windows, Windows on top!
"Hiragino Sans GB W3", "Hiragino Kaku Gothic Pro W3", "Hiragino Kaku Gothic ProN W3", "Osaka", // For stupid Mac OSX
"TakaoPGothic", "IPAPGothic" // For cringy Linux
)
init {

View File

@ -114,7 +114,7 @@ class TextComponent(val separator: String = " ") {
}.maxOrNull() ?: 0f
fun getHeight(lineSpace: Int, skipEmptyLines: Boolean = false, customFont: Boolean = FontRenderAdapter.useCustomFont) =
FontRenderAdapter.getFontHeight(customFont = customFont) * getLines(skipEmptyLines) + lineSpace * (getLines(skipEmptyLines) - 1)
FontRenderAdapter.getFontHeight(customFont = customFont) * getLines(skipEmptyLines) + lineSpace * (getLines(skipEmptyLines) - 1)
fun getLines(skipEmptyLines: Boolean = true) = textLines.count { !skipEmptyLines || (it != null && !it.isEmpty()) }

View File

@ -11,7 +11,7 @@ class Vec2d(var x: Double = 0.0, var y: Double = 0.0) {
constructor(vec2d: Vec2d) : this(vec2d.x, vec2d.y)
fun toRadians(): Vec2d {
return Vec2d(this.x / 180.0 * Math.PI, this.y / 180.0 * Math.PI)
return Vec2d(this.x / 180.0 * Math.PI, this.y / 180.0 * Math.PI)
}
fun length(): Double {

View File

@ -16,7 +16,7 @@ class Vec2f(@JvmField var x: Float, @JvmField var y: Float) {
*/
constructor(entity: Entity) : this(entity.rotationYaw, entity.rotationPitch)
constructor(vec2d: Vec2d): this(vec2d.x.toFloat(), vec2d.y.toFloat())
constructor(vec2d: Vec2d) : this(vec2d.x.toFloat(), vec2d.y.toFloat())
fun toRadians(): Vec2d {
return Vec2d(this.x / 180.0 * Math.PI, this.y / 180.0 * Math.PI)

View File

@ -1,4 +1,4 @@
package me.zeroeightsix.kami.util.math;
package me.zeroeightsix.kami.util.math
import me.zeroeightsix.kami.util.Wrapper
import net.minecraft.block.BlockAir
@ -99,13 +99,13 @@ object VectorUtils {
*/
fun getHighestTerrainPos(pos: BlockPos): BlockPos {
for (i in pos.y downTo 0) {
val block = Wrapper.world!!.getBlockState(BlockPos(pos.getX(), i, pos.getZ())).block
val replaceable = Wrapper.world!!.getBlockState(BlockPos(pos.getX(), i, pos.getZ())).material.isReplaceable
val block = Wrapper.world!!.getBlockState(BlockPos(pos.x, i, pos.z)).block
val replaceable = Wrapper.world!!.getBlockState(BlockPos(pos.x, i, pos.z)).material.isReplaceable
if (block !is BlockAir && !replaceable) {
return BlockPos(pos.getX(), i, pos.getZ())
return BlockPos(pos.x, i, pos.z)
}
}
return BlockPos(pos.getX(), 0, pos.getZ())
return BlockPos(pos.x, 0, pos.z)
}
private fun getBlockPos(minX: Int, maxX: Int, minY: Int, maxY: Int, minZ: Int, maxZ: Int): List<BlockPos> {

View File

@ -54,10 +54,10 @@ object MessageDetectionHelper {
fun shouldSend(all: Boolean, restart: Boolean, direct: Boolean, queue: Boolean, importantPings: Boolean, message: String): Boolean {
return all
|| message.detect(restart, Regexes.RESTART)
|| isDirect(direct, message)
|| message.detect(queue, Regexes.QUEUE)
|| message.detect(importantPings, Regexes.QUEUE_IMPORTANT)
|| message.detect(restart, Regexes.RESTART)
|| isDirect(direct, message)
|| message.detect(queue, Regexes.QUEUE)
|| message.detect(importantPings, Regexes.QUEUE_IMPORTANT)
}
@ -69,8 +69,8 @@ object MessageDetectionHelper {
private val commandPrefixes: Array<String>
get() = arrayOf("/", ",", ".", "-", ";", "?", "*", "^", "&", "%", "#", "$",
Command.getCommandPrefix(),
ChatEncryption.delimiterValue.value)
Command.getCommandPrefix(),
ChatEncryption.delimiterValue.value)
}
enum class Regexes(val regex: Regex) {

View File

@ -82,7 +82,7 @@ object MessageSendHelper {
fun sendServerMessage(message: String?) {
if (message.isNullOrBlank()) return
mc.player?.connection?.sendPacket(CPacketChatMessage(message))
?: LogWrapper.warning("Could not send server message: \"$message\"")
?: LogWrapper.warning("Could not send server message: \"$message\"")
}
@JvmStatic

View File

@ -2,149 +2,150 @@ package me.zeroeightsix.kami.util.text
object SpamFilters {
val announcer = arrayOf( // RusherHack b8
"I just walked .+ feet!",
"I just placed a .+!",
"I just attacked .+ with a .+!",
"I just dropped a .+!",
"I just opened chat!",
"I just opened my console!",
"I just opened my GUI!",
"I just went into full screen mode!",
"I just paused my game!",
"I just opened my inventory!",
"I just looked at the player list!",
"I just took a screen shot!",
"I just swaped hands!",
"I just ducked!",
"I just changed perspectives!",
"I just jumped!",
"I just ate a .+!",
"I just crafted .+ .+!",
"I just picked up a .+!",
"I just smelted .+ .+!",
"I just respawned!", // RusherHack b11
"I just attacked .+ with my hands",
"I just broke a .+!", // WWE
"I recently walked .+ blocks",
"I just droped a .+ called, .+!",
"I just placed a block called, .+!",
"Im currently breaking a block called, .+!",
"I just broke a block called, .+!",
"I just opened chat!",
"I just opened chat and typed a slash!",
"I just paused my game!",
"I just opened my inventory!",
"I just looked at the player list!",
"I just changed perspectives, now im in .+!",
"I just crouched!",
"I just jumped!",
"I just attacked a entity called, .+ with a .+",
"Im currently eatting a peice of food called, .+!",
"Im currently using a item called, .+!",
"I just toggled full screen mode!",
"I just took a screen shot!",
"I just swaped hands and now theres a .+ in my main hand and a .+ in my off hand!",
"I just used pick block on a block called, .+!",
"Ra just completed his blazing ark",
"Its a new day yes it is", // DotGod.CC
"I just placed .+ thanks to (http:\\/\\/)?DotGod\\.CC!",
"I just flew .+ meters like a butterfly thanks to (http:\\/\\/)?DotGod\\.CC!")
"I just walked .+ feet!",
"I just placed a .+!",
"I just attacked .+ with a .+!",
"I just dropped a .+!",
"I just opened chat!",
"I just opened my console!",
"I just opened my GUI!",
"I just went into full screen mode!",
"I just paused my game!",
"I just opened my inventory!",
"I just looked at the player list!",
"I just took a screen shot!",
"I just swaped hands!",
"I just ducked!",
"I just changed perspectives!",
"I just jumped!",
"I just ate a .+!",
"I just crafted .+ .+!",
"I just picked up a .+!",
"I just smelted .+ .+!",
"I just respawned!", // RusherHack b11
"I just attacked .+ with my hands",
"I just broke a .+!", // WWE
"I recently walked .+ blocks",
"I just droped a .+ called, .+!",
"I just placed a block called, .+!",
"Im currently breaking a block called, .+!",
"I just broke a block called, .+!",
"I just opened chat!",
"I just opened chat and typed a slash!",
"I just paused my game!",
"I just opened my inventory!",
"I just looked at the player list!",
"I just changed perspectives, now im in .+!",
"I just crouched!",
"I just jumped!",
"I just attacked a entity called, .+ with a .+",
"Im currently eatting a peice of food called, .+!",
"Im currently using a item called, .+!",
"I just toggled full screen mode!",
"I just took a screen shot!",
"I just swaped hands and now theres a .+ in my main hand and a .+ in my off hand!",
"I just used pick block on a block called, .+!",
"Ra just completed his blazing ark",
"Its a new day yes it is", // DotGod.CC
"I just placed .+ thanks to (http:\\/\\/)?DotGod\\.CC!",
"I just flew .+ meters like a butterfly thanks to (http:\\/\\/)?DotGod\\.CC!")
val spammer = arrayOf( //WWE
"WWE Client's spammer",
"Lol get gud",
"Future client is bad",
"WWE > Future",
"WWE > Impact",
"Default Message",
"IKnowImEZ is a god",
"THEREALWWEFAN231 is a god",
"WWE Client made by IKnowImEZ/THEREALWWEFAN231",
"WWE Client was the first public client to have Path Finder/New Chunks",
"WWE Client was the first public client to have color signs",
"WWE Client was the first client to have Teleport Finder",
"WWE Client was the first client to have Tunneller & Tunneller Back Fill",
"Zispanos")
"WWE Client's spammer",
"Lol get gud",
"Future client is bad",
"WWE > Future",
"WWE > Impact",
"Default Message",
"IKnowImEZ is a god",
"THEREALWWEFAN231 is a god",
"WWE Client made by IKnowImEZ/THEREALWWEFAN231",
"WWE Client was the first public client to have Path Finder/New Chunks",
"WWE Client was the first public client to have color signs",
"WWE Client was the first client to have Teleport Finder",
"WWE Client was the first client to have Tunneller & Tunneller Back Fill",
"Zispanos")
val insulter = arrayOf( // WWE
".+ Download WWE utility mod, Its free!",
".+ 4b4t is da best mintscreft serber",
".+ dont abouse",
".+ you cuck",
".+ https://www.youtube.com/channel/UCJGCNPEjvsCn0FKw3zso0TA",
".+ is my step dad",
".+ again daddy!",
"dont worry .+ it happens to every one",
".+ dont buy future it's crap, compared to WWE!",
"What are you, fucking gay, .+?",
"Did you know? .+ hates you, .+",
"You are literally 10, .+",
".+ finally lost their virginity, sadly they lost it to .+... yeah, that's unfortunate.",
".+, don't be upset, it's not like anyone cares about you, fag.",
".+, see that rubbish bin over there? Get your ass in it, or I'll get .+ to whoop your ass.",
".+, may I borrow that dirt block? that guy named .+ needs it...",
"Yo, .+, btfo you virgin",
"Hey .+ want to play some High School RP with me and .+?",
".+ is an Archon player. Why is he on here? Fucking factions player.",
"Did you know? .+ just joined The Vortex Coalition!",
".+ has successfully conducted the cactus dupe and duped a itemhand!",
".+, are you even human? You act like my dog, holy shit.",
".+, you were never loved by your family.",
"Come on .+, you hurt .+'s feelings. You meany.",
"Stop trying to meme .+, you can't do that. kek",
".+, .+ is gay. Don't go near him.",
"Whoa .+ didn't mean to offend you, .+.",
".+ im not pvping .+, im WWE'ing .+.",
"Did you know? .+ just joined The Vortex Coalition!",
".+, are you even human? You act like my dog, holy shit.")
".+ Download WWE utility mod, Its free!",
".+ 4b4t is da best mintscreft serber",
".+ dont abouse",
".+ you cuck",
".+ https://www.youtube.com/channel/UCJGCNPEjvsCn0FKw3zso0TA",
".+ is my step dad",
".+ again daddy!",
"dont worry .+ it happens to every one",
".+ dont buy future it's crap, compared to WWE!",
"What are you, fucking gay, .+?",
"Did you know? .+ hates you, .+",
"You are literally 10, .+",
".+ finally lost their virginity, sadly they lost it to .+... yeah, that's unfortunate.",
".+, don't be upset, it's not like anyone cares about you, fag.",
".+, see that rubbish bin over there? Get your ass in it, or I'll get .+ to whoop your ass.",
".+, may I borrow that dirt block? that guy named .+ needs it...",
"Yo, .+, btfo you virgin",
"Hey .+ want to play some High School RP with me and .+?",
".+ is an Archon player. Why is he on here? Fucking factions player.",
"Did you know? .+ just joined The Vortex Coalition!",
".+ has successfully conducted the cactus dupe and duped a itemhand!",
".+, are you even human? You act like my dog, holy shit.",
".+, you were never loved by your family.",
"Come on .+, you hurt .+'s feelings. You meany.",
"Stop trying to meme .+, you can't do that. kek",
".+, .+ is gay. Don't go near him.",
"Whoa .+ didn't mean to offend you, .+.",
".+ im not pvping .+, im WWE'ing .+.",
"Did you know? .+ just joined The Vortex Coalition!",
".+, are you even human? You act like my dog, holy shit.")
val greeter = arrayOf( // WWE
"Bye, Bye .+",
"Farwell, .+", // Others(?)
"See you next time, .+",
"Catch ya later, .+",
"Bye, .+",
"Welcome, .+",
"Hey, .+", // Vanilla MC / Essentials MC
".+ joined the game",
".+ has joined",
".+ joined the lobby",
"Welcome .+",
".+ left the game")
"Bye, Bye .+",
"Farwell, .+", // Others(?)
"See you next time, .+",
"Catch ya later, .+",
"Bye, .+",
"Welcome, .+",
"Hey, .+", // Vanilla MC / Essentials MC
".+ joined the game",
".+ has joined",
".+ joined the lobby",
"Welcome .+",
".+ left the game")
val discordInvite = arrayOf(
"discord.gg",
"discordapp.com",
"discord.io",
"invite.gg",
"discord.com/invite")
"discord.gg",
"discordapp.com",
"discord.io",
"invite.gg",
"discord.com/invite")
val greenText = arrayOf(
"^>.+$")
"^>.+$")
val ipAddress = arrayOf(
"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\:\\d{1,5}\\b",
"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",
"^(?:http(?:s)?:\\/\\/)?(?:[^\\.]+\\.)?.*\\..*\\..*$",
".*\\..*\\:\\d{1,5}$")
"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\:\\d{1,5}\\b",
"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",
"^(?:http(?:s)?:\\/\\/)?(?:[^\\.]+\\.)?.*\\..*\\..*$",
".*\\..*\\:\\d{1,5}$")
val ownsMeAndAll = arrayOf(
"owns me and all")
"owns me and all")
val thanksTo = arrayOf(
"i just.*thanks to",
"i just.*using")
"i just.*thanks to",
"i just.*using")
val specialBeginning = arrayOf(
"^[.,/?!()\\[\\]{}<|\\-+=\\\\]")
"^[.,/?!()\\[\\]{}<|\\-+=\\\\]")
val specialEnding = arrayOf(
"[/@#^()\\[\\]{}<>|\\-+=\\\\]$")
"[/@#^()\\[\\]{}<>|\\-+=\\\\]$")
val slurs = arrayOf(
"nigg.{0,3}",
"chi[^c]k",
"tra.{0,1}n(y|ie)",
"kik.{1,2}",
"fa(g |g.{0,2})",
"reta.{0,3}"
"nigg.{0,3}",
"chi[^c]k",
"tra.{0,1}n(y|ie)",
"kik.{1,2}",
"fa(g |g.{0,2})",
"reta.{0,3}"
)
// fairly simple - anarchy servers shouldn't have a chat filter so there isn't an attempt to check for bypasses
val swears = arrayOf(
"fuck(er)?",
"shit",
"cunt",
"puss(ie|y)",
"bitch",
"twat"
"fuck(er)?",
"shit",
"cunt",
"puss(ie|y)",
"bitch",
"twat"
)
}