mirror of
https://github.com/seppukudevelopment/seppuku
synced 2025-01-12 01:49:41 +00:00
Search now uses new BlocksComponent
This commit is contained in:
parent
80468c9712
commit
38e8cee13f
@ -0,0 +1,7 @@
|
||||
package me.rigamortis.seppuku.api.event.gui.hud;
|
||||
|
||||
/**
|
||||
* @author noil
|
||||
*/
|
||||
public class EventUIValueChanged {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package me.rigamortis.seppuku.api.event.gui.hud.modulelist;
|
||||
|
||||
import me.rigamortis.seppuku.api.event.gui.hud.EventUIValueChanged;
|
||||
|
||||
/**
|
||||
* @author noil
|
||||
*/
|
||||
public class EventUIListValueChanged extends EventUIValueChanged {
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package me.rigamortis.seppuku.api.gui.hud.component;
|
||||
|
||||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.event.gui.hud.modulelist.EventUIListValueChanged;
|
||||
import me.rigamortis.seppuku.api.util.RenderUtil;
|
||||
import me.rigamortis.seppuku.api.value.Value;
|
||||
import net.minecraft.block.Block;
|
||||
@ -143,6 +145,8 @@ public final class BlocksComponent extends HudComponent {
|
||||
this.value.getValue().remove(block);
|
||||
else
|
||||
this.value.getValue().add(block);
|
||||
|
||||
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIListValueChanged());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package me.rigamortis.seppuku.api.gui.hud.component;
|
||||
|
||||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.event.gui.hud.modulelist.EventUIListValueChanged;
|
||||
import me.rigamortis.seppuku.api.util.RenderUtil;
|
||||
import me.rigamortis.seppuku.api.value.Value;
|
||||
import net.minecraft.block.Block;
|
||||
@ -145,6 +147,8 @@ public final class ItemsComponent extends HudComponent {
|
||||
this.value.getValue().remove(item);
|
||||
else
|
||||
this.value.getValue().add(item);
|
||||
|
||||
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIListValueChanged());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public final class SearchCommand extends Command {
|
||||
if (id > 0) {
|
||||
final Block block = Block.getBlockById(id);
|
||||
|
||||
if (searchModule.contains(Block.getIdFromBlock(block))) {
|
||||
if (searchModule.contains(block)) {
|
||||
Seppuku.INSTANCE.logChat("Search already contains " + block.getLocalizedName());
|
||||
} else {
|
||||
searchModule.add(Block.getIdFromBlock(block));
|
||||
@ -76,7 +76,7 @@ public final class SearchCommand extends Command {
|
||||
if (block == Blocks.AIR) {
|
||||
Seppuku.INSTANCE.errorChat("Cannot add Air to search");
|
||||
} else {
|
||||
if (searchModule.contains(Block.getIdFromBlock(block))) {
|
||||
if (searchModule.contains(block)) {
|
||||
Seppuku.INSTANCE.logChat("Search already contains " + block.getLocalizedName());
|
||||
} else {
|
||||
searchModule.add(Block.getIdFromBlock(block));
|
||||
@ -104,7 +104,7 @@ public final class SearchCommand extends Command {
|
||||
if (id > 0) {
|
||||
final Block block = Block.getBlockById(id);
|
||||
|
||||
if (searchModule.contains(Block.getIdFromBlock(block))) {
|
||||
if (searchModule.contains(block)) {
|
||||
searchModule.remove(Block.getIdFromBlock(block));
|
||||
if (searchModule.isEnabled()) {
|
||||
searchModule.clearBlocks();
|
||||
@ -125,7 +125,7 @@ public final class SearchCommand extends Command {
|
||||
if (block == Blocks.AIR) {
|
||||
Seppuku.INSTANCE.errorChat("Cannot remove Air from search");
|
||||
} else {
|
||||
if (searchModule.contains(Block.getIdFromBlock(block))) {
|
||||
if (searchModule.contains(block)) {
|
||||
searchModule.remove(Block.getIdFromBlock(block));
|
||||
if (searchModule.isEnabled()) {
|
||||
searchModule.clearBlocks();
|
||||
@ -147,13 +147,13 @@ public final class SearchCommand extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
if (searchModule.getIds().size() > 0) {
|
||||
if (searchModule.getBlockIds().getValue().size() > 0) {
|
||||
final TextComponentString msg = new TextComponentString("\2477Search IDs: ");
|
||||
|
||||
for (int i : searchModule.getIds()) {
|
||||
msg.appendSibling(new TextComponentString("\2477[\247a" + i + "\2477] ")
|
||||
for (Block block : searchModule.getBlockIds().getValue()) {
|
||||
msg.appendSibling(new TextComponentString("\2477[\247a" + Block.getIdFromBlock(block) + "\2477] ")
|
||||
.setStyle(new Style()
|
||||
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(Block.getBlockById(i).getLocalizedName())))));
|
||||
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(block.getLocalizedName())))));
|
||||
}
|
||||
|
||||
Seppuku.INSTANCE.logcChat(msg);
|
||||
|
@ -7,6 +7,8 @@ import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.config.Configurable;
|
||||
import me.rigamortis.seppuku.api.util.FileUtil;
|
||||
import me.rigamortis.seppuku.impl.module.render.SearchModule;
|
||||
import me.rigamortis.seppuku.impl.module.render.XrayModule;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
@ -36,9 +38,15 @@ public final class SearchConfig extends Configurable {
|
||||
if (blockIds != null)
|
||||
searchIdsJsonArray = blockIds.getAsJsonArray();
|
||||
|
||||
if (searchIdsJsonArray != null) {
|
||||
for (JsonElement jsonElement : searchIdsJsonArray) {
|
||||
((SearchModule) Objects.requireNonNull(Seppuku.INSTANCE.getModuleManager().find("Search"))).add(jsonElement.getAsInt());
|
||||
final SearchModule searchModule = (SearchModule) Seppuku.INSTANCE.getModuleManager().find("Search");
|
||||
if (searchModule != null) {
|
||||
if (searchIdsJsonArray != null) {
|
||||
for (JsonElement jsonElement : searchIdsJsonArray) {
|
||||
searchModule.add(jsonElement.getAsInt());
|
||||
}
|
||||
}
|
||||
if (searchModule.getBlockIds().getValue().isEmpty()) {
|
||||
searchModule.add("furnace");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,8 +59,8 @@ public final class SearchConfig extends Configurable {
|
||||
JsonObject save = new JsonObject();
|
||||
|
||||
JsonArray searchIdsJsonArray = new JsonArray();
|
||||
for (Integer i : this.searchModule.getIds())
|
||||
searchIdsJsonArray.add(i);
|
||||
for (Block block : this.searchModule.getBlockIds().getValue())
|
||||
searchIdsJsonArray.add(Block.getIdFromBlock(block));
|
||||
|
||||
save.add("SearchBlockIds", searchIdsJsonArray);
|
||||
|
||||
|
@ -10,7 +10,6 @@ import me.rigamortis.seppuku.impl.module.render.XrayModule;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author noil
|
||||
@ -37,9 +36,15 @@ public final class XrayConfig extends Configurable {
|
||||
if (blockIds != null)
|
||||
xrayIdsJsonArray = blockIds.getAsJsonArray();
|
||||
|
||||
if (xrayIdsJsonArray != null) {
|
||||
for (JsonElement jsonElement : xrayIdsJsonArray) {
|
||||
((XrayModule) Objects.requireNonNull(Seppuku.INSTANCE.getModuleManager().find("Xray"))).add(jsonElement.getAsInt());
|
||||
final XrayModule xrayModule = (XrayModule) Seppuku.INSTANCE.getModuleManager().find("Xray");
|
||||
if (xrayModule != null) {
|
||||
if (xrayIdsJsonArray != null) {
|
||||
for (JsonElement jsonElement : xrayIdsJsonArray) {
|
||||
xrayModule.add(jsonElement.getAsInt());
|
||||
}
|
||||
}
|
||||
if (xrayModule.getBlocks().getValue().isEmpty()) {
|
||||
xrayModule.add("diamond_ore");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rigamortis.seppuku.impl.module.render;
|
||||
|
||||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.event.gui.hud.modulelist.EventUIListValueChanged;
|
||||
import me.rigamortis.seppuku.api.event.player.EventDestroyBlock;
|
||||
import me.rigamortis.seppuku.api.event.render.EventRender3D;
|
||||
import me.rigamortis.seppuku.api.event.render.EventRenderBlockModel;
|
||||
@ -44,17 +45,31 @@ public final class SearchModule extends Module {
|
||||
BOX, OUTLINE, OUTLINE_BOX, PLANE
|
||||
}
|
||||
|
||||
private List<Integer> ids = new ArrayList<>();
|
||||
private final Value<List<Block>> blockIds = new Value<>("Ids", new String[]{"id", "i", "blocks"}, "Blocks to search for.");
|
||||
private final List<Vec3d> blocks = new ArrayList<>(512);
|
||||
private final ICamera frustum = new Frustum();
|
||||
|
||||
public SearchModule() {
|
||||
super("Search", new String[]{"srch", "find", "locate"}, "Search for different types of blocks. Enter the \"search\" command.", "NONE", -1, ModuleType.RENDER);
|
||||
|
||||
this.blockIds.setValue(new ArrayList<>());
|
||||
|
||||
if (Seppuku.INSTANCE.getConfigManager().isFirstLaunch())
|
||||
this.add("furnace");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.blocks.clear();
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onToggle() {
|
||||
super.onToggle();
|
||||
Minecraft.getMinecraft().renderGlobal.loadRenderers();
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onLoadWorld(EventLoadWorld event) {
|
||||
if (event.getWorld() != null) {
|
||||
@ -145,21 +160,16 @@ public final class SearchModule extends Module {
|
||||
public void onRenderBlock(EventRenderBlockModel event) {
|
||||
final BlockPos pos = event.getBlockPos();
|
||||
final IBlockState blockState = event.getBlockState();
|
||||
if (this.contains(Block.getIdFromBlock(blockState.getBlock())) && !this.isPosCached(pos.getX(), pos.getY(), pos.getZ()) && this.blocks.size() < this.limit.getValue()) {
|
||||
if (this.contains(blockState.getBlock()) && !this.isPosCached(pos.getX(), pos.getY(), pos.getZ()) && this.blocks.size() < this.limit.getValue()) {
|
||||
this.blocks.add(new Vec3d(pos));
|
||||
} else if (!this.contains(blockState.getBlock()) && this.isPosCached(pos.getX(), pos.getY(), pos.getZ())) {
|
||||
this.blocks.remove(new Vec3d(pos));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.blocks.clear();
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onToggle() {
|
||||
super.onToggle();
|
||||
Minecraft.getMinecraft().renderGlobal.loadRenderers();
|
||||
@Listener
|
||||
public void onUIListValueChanged(EventUIListValueChanged event) {
|
||||
this.updateRenders();
|
||||
}
|
||||
|
||||
private void removeBlock(BlockPos pos) {
|
||||
@ -213,38 +223,31 @@ public final class SearchModule extends Module {
|
||||
(int) mc.player.posZ + 256);
|
||||
}
|
||||
|
||||
public boolean contains(int id) {
|
||||
return this.ids.contains(id);
|
||||
}
|
||||
|
||||
public boolean contains(String localizedName) {
|
||||
final Block blockFromName = Block.getBlockFromName(localizedName);
|
||||
if (blockFromName != null) {
|
||||
return contains(Block.getIdFromBlock(blockFromName));
|
||||
}
|
||||
return false;
|
||||
public boolean contains(Block block) {
|
||||
return this.blockIds.getValue().contains(block);
|
||||
}
|
||||
|
||||
public void add(int id) {
|
||||
if (!contains(id)) {
|
||||
this.ids.add(id);
|
||||
final Block blockFromID = Block.getBlockById(id);
|
||||
if (!contains(blockFromID)) {
|
||||
this.blockIds.getValue().add(blockFromID);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String name) {
|
||||
final Block blockFromName = Block.getBlockFromName(name);
|
||||
if (blockFromName != null) {
|
||||
final int id = Block.getIdFromBlock(blockFromName);
|
||||
if (!contains(id)) {
|
||||
this.ids.add(id);
|
||||
if (!contains(blockFromName)) {
|
||||
this.blockIds.getValue().add(blockFromName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(int id) {
|
||||
for (Integer i : this.ids) {
|
||||
if (id == i) {
|
||||
this.ids.remove(i);
|
||||
for (Block block : this.blockIds.getValue()) {
|
||||
final int blockID = Block.getIdFromBlock(block);
|
||||
if (blockID == id) {
|
||||
this.blockIds.getValue().remove(block);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -253,16 +256,15 @@ public final class SearchModule extends Module {
|
||||
public void remove(String name) {
|
||||
final Block blockFromName = Block.getBlockFromName(name);
|
||||
if (blockFromName != null) {
|
||||
final int id = Block.getIdFromBlock(blockFromName);
|
||||
if (contains(id)) {
|
||||
this.ids.remove(id);
|
||||
if (contains(blockFromName)) {
|
||||
this.blockIds.getValue().remove(blockFromName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int clear() {
|
||||
final int count = this.ids.size();
|
||||
this.ids.clear();
|
||||
final int count = this.blockIds.getValue().size();
|
||||
this.blockIds.getValue().clear();
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -291,11 +293,7 @@ public final class SearchModule extends Module {
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
public List<Integer> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<Integer> ids) {
|
||||
this.ids = ids;
|
||||
public Value<List<Block>> getBlockIds() {
|
||||
return blockIds;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rigamortis.seppuku.impl.module.render;
|
||||
|
||||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.event.gui.hud.modulelist.EventUIListValueChanged;
|
||||
import me.rigamortis.seppuku.api.event.render.EventRenderBlockModel;
|
||||
import me.rigamortis.seppuku.api.event.render.EventRenderBlockSide;
|
||||
import me.rigamortis.seppuku.api.event.world.EventSetOpaqueCube;
|
||||
@ -8,8 +9,6 @@ import me.rigamortis.seppuku.api.module.Module;
|
||||
import me.rigamortis.seppuku.api.value.Value;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -21,8 +20,7 @@ import java.util.List;
|
||||
*/
|
||||
public final class XrayModule extends Module {
|
||||
|
||||
public final Value<List<Block>> blocks = new Value<List<Block>>("Ids", new String[]{"id", "i"}, "Testing");
|
||||
public final Value<List<Item>> items = new Value<List<Item>>("Items", new String[]{"item"}, "Testing");
|
||||
public final Value<List<Block>> blocks = new Value<List<Block>>("Ids", new String[]{"id", "i"}, "Blocks to xray for.");
|
||||
|
||||
private float lastGamma;
|
||||
private int lastAO;
|
||||
@ -31,9 +29,6 @@ public final class XrayModule extends Module {
|
||||
super("Xray", new String[]{"JadeVision", "Jade"}, "Allows you to filter what the world renders", "NONE", -1, ModuleType.RENDER);
|
||||
|
||||
this.blocks.setValue(new ArrayList<>());
|
||||
this.items.setValue(new ArrayList<>());
|
||||
|
||||
this.items.getValue().add(Items.WHEAT);
|
||||
|
||||
if (Seppuku.INSTANCE.getConfigManager().isFirstLaunch())
|
||||
this.add("diamond_ore");
|
||||
@ -94,6 +89,11 @@ public final class XrayModule extends Module {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onUIListValueChanged(EventUIListValueChanged event) {
|
||||
this.updateRenders();
|
||||
}
|
||||
|
||||
public void updateRenders() {
|
||||
//Minecraft.getMinecraft().renderGlobal.loadRenderers();
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
Loading…
Reference in New Issue
Block a user