mirror of
https://github.com/GTNewHorizons/FindIt.git
synced 2026-11-18 23:59:05 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
0e2d9e02a4
commit
f2dc81704a
19 files changed
+150
-128
No files matched your search
@@ -5,6 +5,7 @@ import com.gtnh.findit.service.blockfinder.ClientBlockFindService;
|
||||
import com.gtnh.findit.service.cooldown.SearchCooldownService;
|
||||
import com.gtnh.findit.service.itemfinder.ClientItemFindService;
|
||||
import com.gtnh.findit.service.itemfinder.ItemFindService;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
@@ -16,8 +17,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
name = FindIt.MOD_NAME,
|
||||
version = FindIt.VERSION,
|
||||
dependencies = "required-after:NotEnoughItems;required-after:gregtech",
|
||||
acceptableRemoteVersions = "*"
|
||||
)
|
||||
acceptableRemoteVersions = "*")
|
||||
public class FindIt {
|
||||
|
||||
// Mod info
|
||||
@@ -46,8 +46,7 @@ public class FindIt {
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
}
|
||||
public void postInit(FMLPostInitializationEvent event) {}
|
||||
|
||||
public static SearchCooldownService getCooldownService() {
|
||||
return INSTANCE.cooldownService;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.gtnh.findit;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
public class FindItConfig {
|
||||
|
||||
public static int SEARCH_RADIUS = 16;
|
||||
@@ -15,28 +15,18 @@ public class FindItConfig {
|
||||
try {
|
||||
config.load();
|
||||
|
||||
SEARCH_RADIUS = config.get(
|
||||
Configuration.CATEGORY_GENERAL,
|
||||
"SearchRadius",
|
||||
"16",
|
||||
"Radius to search within"
|
||||
).getInt();
|
||||
SEARCH_RADIUS = config.get(Configuration.CATEGORY_GENERAL, "SearchRadius", "16", "Radius to search within")
|
||||
.getInt();
|
||||
|
||||
SEARCH_COOLDOWN = config.get(
|
||||
Configuration.CATEGORY_GENERAL,
|
||||
"SearchCooldown",
|
||||
"10",
|
||||
"Search cooldown in ticks"
|
||||
).getInt();
|
||||
SEARCH_COOLDOWN = config
|
||||
.get(Configuration.CATEGORY_GENERAL, "SearchCooldown", "10", "Search cooldown in ticks").getInt();
|
||||
|
||||
MAX_RESPONSE_SIZE = config.get(
|
||||
Configuration.CATEGORY_GENERAL,
|
||||
"MaxResponseSize",
|
||||
"20",
|
||||
"Maximum number of positions that can be displayed by item/block search"
|
||||
).getInt();
|
||||
} catch (Exception ignore) {
|
||||
} finally {
|
||||
"Maximum number of positions that can be displayed by item/block search").getInt();
|
||||
} catch (Exception ignore) {} finally {
|
||||
if (config.hasChanged()) config.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ public class FindItNetwork {
|
||||
private static int lastMessageId = -1;
|
||||
public static final SimpleNetworkWrapper CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(FindIt.MOD_ID);
|
||||
|
||||
public static <REQ extends IMessage, REPLY extends IMessage> void registerMessage(Class<? extends IMessageHandler<REQ, REPLY>> messageHandler, Class<REQ> requestMessageType, Side side) {
|
||||
public static <REQ extends IMessage, REPLY extends IMessage> void registerMessage(
|
||||
Class<? extends IMessageHandler<REQ, REPLY>> messageHandler, Class<REQ> requestMessageType, Side side) {
|
||||
CHANNEL.registerMessage(messageHandler, requestMessageType, ++lastMessageId, side);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.gtnh.findit.fx;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityReddustFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.List;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ParticlePosition extends EntityReddustFX {
|
||||
|
||||
@@ -20,8 +21,7 @@ public class ParticlePosition extends EntityReddustFX {
|
||||
world,
|
||||
pos.chunkPosX + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble()),
|
||||
pos.chunkPosY + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble()),
|
||||
pos.chunkPosZ + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble())
|
||||
);
|
||||
pos.chunkPosZ + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble()));
|
||||
version = validVersion;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ public class ParticlePosition extends EntityReddustFX {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(final Tessellator tessellator, float partialTickTime, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
|
||||
public void renderParticle(final Tessellator tessellator, float partialTickTime, float rotationX, float rotationZ,
|
||||
float rotationYZ, float rotationXY, float rotationXZ) {
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package com.gtnh.findit.fx;
|
||||
|
||||
import com.gtnh.findit.FindIt;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.List;
|
||||
import com.gtnh.findit.FindIt;
|
||||
|
||||
public class SlotHighlighter {
|
||||
|
||||
private static final ResourceLocation highlightTexture = new ResourceLocation(FindIt.MOD_ID, "textures/gui/slot_highlight.png");
|
||||
private static final ResourceLocation highlightTexture = new ResourceLocation(
|
||||
FindIt.MOD_ID,
|
||||
"textures/gui/slot_highlight.png");
|
||||
|
||||
public static void highlightSlots(GuiContainer gui, List<Integer> slots, int color) {
|
||||
if (slots.isEmpty()) {
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
package com.gtnh.findit.service.blockfinder;
|
||||
|
||||
import com.gtnh.findit.FindIt;
|
||||
import com.gtnh.findit.FindItConfig;
|
||||
import com.gtnh.findit.FindItNetwork;
|
||||
import com.gtnh.findit.util.WorldUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.gtnh.findit.FindIt;
|
||||
import com.gtnh.findit.FindItConfig;
|
||||
import com.gtnh.findit.FindItNetwork;
|
||||
import com.gtnh.findit.util.WorldUtils;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||
|
||||
public class BlockFindService {
|
||||
|
||||
public BlockFindService() {
|
||||
FindItNetwork.registerMessage(FindBlockRequest.Handler.class, FindBlockRequest.class, Side.SERVER);
|
||||
FindItNetwork.registerMessage(BlockFoundResponse.Handler.class, BlockFoundResponse.class, Side.CLIENT);
|
||||
FindItNetwork.registerMessage(FindBlockRequest.Handler.class, FindBlockRequest.class, Side.SERVER);
|
||||
FindItNetwork.registerMessage(BlockFoundResponse.Handler.class, BlockFoundResponse.class, Side.CLIENT);
|
||||
}
|
||||
|
||||
public void handleRequest(EntityPlayerMP player, FindBlockRequest request) {
|
||||
if (FindIt.getCooldownService().checkSearchCooldown(player)) {
|
||||
return;
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package com.gtnh.findit.service.blockfinder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
|
||||
import com.gtnh.findit.util.ProtoUtils;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockFoundResponse implements IMessage {
|
||||
|
||||
@@ -20,8 +22,7 @@ public class BlockFoundResponse implements IMessage {
|
||||
this.positions = positions;
|
||||
}
|
||||
|
||||
public BlockFoundResponse() {
|
||||
}
|
||||
public BlockFoundResponse() {}
|
||||
|
||||
public List<ChunkPosition> getPositions() {
|
||||
return positions;
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
package com.gtnh.findit.service.blockfinder;
|
||||
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import com.gtnh.findit.FindIt;
|
||||
import com.gtnh.findit.FindItNetwork;
|
||||
import com.gtnh.findit.fx.ParticlePosition;
|
||||
import com.gtnh.findit.util.AbstractStackFinder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
import com.gtnh.findit.FindIt;
|
||||
import com.gtnh.findit.FindItNetwork;
|
||||
import com.gtnh.findit.fx.ParticlePosition;
|
||||
import com.gtnh.findit.util.AbstractStackFinder;
|
||||
|
||||
public class ClientBlockFindService extends BlockFindService {
|
||||
|
||||
public ClientBlockFindService() {
|
||||
@@ -47,4 +49,4 @@ public class ClientBlockFindService extends BlockFindService {
|
||||
public static ClientBlockFindService getInstance() {
|
||||
return (ClientBlockFindService) FindIt.getBlockFindService();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.gtnh.findit.service.blockfinder;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
import com.gtnh.findit.FindIt;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
public class FindBlockRequest implements IMessage {
|
||||
|
||||
@@ -18,8 +20,7 @@ public class FindBlockRequest implements IMessage {
|
||||
this.metaToFind = meta;
|
||||
}
|
||||
|
||||
public FindBlockRequest() {
|
||||
}
|
||||
public FindBlockRequest() {}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.gtnh.findit.service.cooldown;
|
||||
|
||||
import com.gtnh.findit.FindItConfig;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import java.util.WeakHashMap;
|
||||
import com.gtnh.findit.FindItConfig;
|
||||
|
||||
public class SearchCooldownService {
|
||||
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
package com.gtnh.findit.service.itemfinder;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.event.NEIConfigsLoadedEvent;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import com.gtnh.findit.FindIt;
|
||||
import com.gtnh.findit.FindItNetwork;
|
||||
import com.gtnh.findit.fx.ParticlePosition;
|
||||
import com.gtnh.findit.fx.SlotHighlighter;
|
||||
import com.gtnh.findit.util.AbstractStackFinder;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -22,10 +14,22 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.event.NEIConfigsLoadedEvent;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
import com.gtnh.findit.FindIt;
|
||||
import com.gtnh.findit.FindItNetwork;
|
||||
import com.gtnh.findit.fx.ParticlePosition;
|
||||
import com.gtnh.findit.fx.SlotHighlighter;
|
||||
import com.gtnh.findit.util.AbstractStackFinder;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
|
||||
public class ClientItemFindService extends ItemFindService {
|
||||
|
||||
@@ -50,7 +54,10 @@ public class ClientItemFindService extends ItemFindService {
|
||||
}
|
||||
|
||||
public void handleSlotHighlight(HighlightSlotsPacket packet) {
|
||||
highlightData = new ContainerHighlightData(packet.getWindowId(), packet.getTargetStack(), packet.getTargetSlots());
|
||||
highlightData = new ContainerHighlightData(
|
||||
packet.getWindowId(),
|
||||
packet.getTargetStack(),
|
||||
packet.getTargetSlots());
|
||||
}
|
||||
|
||||
public class TickListener {
|
||||
@@ -110,6 +117,7 @@ public class ClientItemFindService extends ItemFindService {
|
||||
}
|
||||
|
||||
private static class ContainerHighlightData {
|
||||
|
||||
private final int windowId;
|
||||
private final ItemStack targetStack;
|
||||
private final List<Integer> targetSlots;
|
||||
@@ -143,12 +151,13 @@ public class ClientItemFindService extends ItemFindService {
|
||||
}
|
||||
|
||||
public static class NEIEventListener {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onNEIConfigsLoaded(NEIConfigsLoadedEvent event) {
|
||||
if (FindIt.isExtraUtilitiesLoaded()) {
|
||||
GuiContainerManager.inputHandlers.removeIf((inputHandler) ->
|
||||
inputHandler.getClass().getName().equals("com.rwtema.extrautils.nei.ping.NEIPing")
|
||||
);
|
||||
GuiContainerManager.inputHandlers.removeIf(
|
||||
(inputHandler) -> inputHandler.getClass().getName()
|
||||
.equals("com.rwtema.extrautils.nei.ping.NEIPing"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,4 +165,4 @@ public class ClientItemFindService extends ItemFindService {
|
||||
public static ClientItemFindService getInstance() {
|
||||
return (ClientItemFindService) FindIt.getItemFindService();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.gtnh.findit.service.itemfinder;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.gtnh.findit.FindIt;
|
||||
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
|
||||
import com.gtnh.findit.util.ProtoUtils;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class FindItemRequest implements IMessage {
|
||||
|
||||
@@ -17,8 +19,7 @@ public class FindItemRequest implements IMessage {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public FindItemRequest() {
|
||||
}
|
||||
public FindItemRequest() {}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package com.gtnh.findit.service.itemfinder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
|
||||
import com.gtnh.findit.util.ProtoUtils;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HighlightSlotsPacket implements IMessage {
|
||||
|
||||
@@ -23,8 +25,7 @@ public class HighlightSlotsPacket implements IMessage {
|
||||
this.targetSlots = targetSlots;
|
||||
}
|
||||
|
||||
public HighlightSlotsPacket() {
|
||||
}
|
||||
public HighlightSlotsPacket() {}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
@@ -69,4 +70,4 @@ public class HighlightSlotsPacket implements IMessage {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
package com.gtnh.findit.service.itemfinder;
|
||||
|
||||
import com.gtnh.findit.FindIt;
|
||||
import com.gtnh.findit.FindItConfig;
|
||||
import com.gtnh.findit.FindItNetwork;
|
||||
import com.gtnh.findit.util.WorldUtils;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -19,7 +15,13 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
|
||||
|
||||
import java.util.*;
|
||||
import com.gtnh.findit.FindIt;
|
||||
import com.gtnh.findit.FindItConfig;
|
||||
import com.gtnh.findit.FindItNetwork;
|
||||
import com.gtnh.findit.util.WorldUtils;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ItemFindService {
|
||||
|
||||
@@ -53,8 +55,7 @@ public class ItemFindService {
|
||||
|
||||
List<ChunkPosition> positions = new ArrayList<>();
|
||||
|
||||
tileIter:
|
||||
for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
|
||||
tileIter: for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
|
||||
try {
|
||||
if (!(tileEntity instanceof IInventory)) {
|
||||
continue;
|
||||
@@ -82,9 +83,9 @@ public class ItemFindService {
|
||||
|
||||
if (!positions.isEmpty()) {
|
||||
ItemFoundResult foundResult = new ItemFindService.ItemFoundResult(
|
||||
request.getStackToFind(), positions,
|
||||
player.getEntityWorld().getTotalWorldTime()
|
||||
);
|
||||
request.getStackToFind(),
|
||||
positions,
|
||||
player.getEntityWorld().getTotalWorldTime());
|
||||
|
||||
lastResults.put(player, foundResult);
|
||||
FindItNetwork.CHANNEL.sendTo(new ItemFoundResponse(request.getStackToFind(), positions), player);
|
||||
@@ -129,15 +130,15 @@ public class ItemFindService {
|
||||
|
||||
FindItNetwork.CHANNEL.sendTo(
|
||||
new HighlightSlotsPacket(container.windowId, lastFoundResult.foundStack, targetSlots),
|
||||
player
|
||||
);
|
||||
player);
|
||||
}
|
||||
}
|
||||
|
||||
private IInventory getSlotTrueInventory(Slot slot) {
|
||||
if (slot.inventory instanceof InventoryLargeChest) {
|
||||
InventoryLargeChest largeChest = (InventoryLargeChest) slot.inventory;
|
||||
return slot.slotNumber < largeChest.upperChest.getSizeInventory() ? largeChest.upperChest : largeChest.lowerChest;
|
||||
return slot.slotNumber < largeChest.upperChest.getSizeInventory() ? largeChest.upperChest
|
||||
: largeChest.lowerChest;
|
||||
}
|
||||
return slot.inventory;
|
||||
}
|
||||
@@ -165,6 +166,7 @@ public class ItemFindService {
|
||||
}
|
||||
|
||||
public static class ItemFoundResult {
|
||||
|
||||
private final ItemStack foundStack;
|
||||
private final Set<ChunkPosition> positions = new HashSet<>();
|
||||
private final long responseTime;
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package com.gtnh.findit.service.itemfinder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
|
||||
import com.gtnh.findit.util.ProtoUtils;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemFoundResponse implements IMessage {
|
||||
|
||||
@@ -23,8 +25,7 @@ public class ItemFoundResponse implements IMessage {
|
||||
this.positions = positions;
|
||||
}
|
||||
|
||||
public ItemFoundResponse() {
|
||||
}
|
||||
public ItemFoundResponse() {}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.gtnh.findit.util;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.client.gui.implementations.*;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class AbstractStackFinder implements IContainerInputHandler {
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.gtnh.findit.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ProtoUtils {
|
||||
|
||||
public static void writePositions(ByteBuf buf, List<ChunkPosition> positions) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.gtnh.findit.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WorldUtils {
|
||||
|
||||
public static List<TileEntity> getTileEntitiesAround(Entity entity, int r) {
|
||||
@@ -23,7 +23,8 @@ public class WorldUtils {
|
||||
* @param (x1,y1,z1) included
|
||||
* @param (x2,y2,z2) excluded
|
||||
*/
|
||||
public static List<TileEntity> getTileEntitiesInRegion(World world, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
public static List<TileEntity> getTileEntitiesInRegion(World world, int x1, int y1, int z1, int x2, int y2,
|
||||
int z2) {
|
||||
List<TileEntity> result = new ArrayList<>();
|
||||
int cx1 = x2 >> 4;
|
||||
int cz1 = z2 >> 4;
|
||||
@@ -34,10 +35,12 @@ public class WorldUtils {
|
||||
if (chunk != null) {
|
||||
Map<ChunkPosition, TileEntity> tiles = chunk.chunkTileEntityMap;
|
||||
for (TileEntity tile : tiles.values()) {
|
||||
if (!tile.isInvalid()
|
||||
&& tile.xCoord >= x1 && tile.xCoord < x2
|
||||
&& tile.yCoord >= y1 && tile.yCoord < y2
|
||||
&& tile.zCoord >= z1 && tile.zCoord < z2) {
|
||||
if (!tile.isInvalid() && tile.xCoord >= x1
|
||||
&& tile.xCoord < x2
|
||||
&& tile.yCoord >= y1
|
||||
&& tile.yCoord < y2
|
||||
&& tile.zCoord >= z1
|
||||
&& tile.zCoord < z2) {
|
||||
result.add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user