Fixed Ranged Collector

This commit is contained in:
Flanks255 2024-03-10 17:10:39 -05:00
parent a4cc12d993
commit adc276e8b5
9 changed files with 73 additions and 27 deletions

View file

@ -1,4 +1,4 @@
// 1.20.4 2024-03-10T22:18:48.1078829 Recipes
// 1.20.4 2024-03-10T17:08:00.6295462 Recipes
4d3128b37a7153882a9324cda49b5069207561c5 data/actuallyadditions/recipes/atomic_reconstructor.json
b0367f5012651764931e8b8fd0c5bcca4e8614c0 data/actuallyadditions/recipes/battery_box.json
7e05cd54092b998dfdbd2221235dd52576ec79eb data/actuallyadditions/recipes/black_quartz_block.json
@ -48,6 +48,7 @@ ff81da8a0f6632779414c0512100696a11771814 data/actuallyadditions/recipes/hopping_
73696fd4e851f440a9850485fc9ad03fc63442a9 data/actuallyadditions/recipes/oil_generator.json
8c78ebb9351b98ffe368391a391b90385c0b8b7f data/actuallyadditions/recipes/placer.json
184acfb5fd3799b3fbe35150c67b6530581f8bf1 data/actuallyadditions/recipes/powered_furnace.json
b81a706a5f635d8a63ffd3034c80838dc10699c9 data/actuallyadditions/recipes/ranged_collector.json
532a454741e8068941f1f3c44f3be257530db8c3 data/actuallyadditions/recipes/shock_suppressor.json
7fa363b3afe88f3ffac1b9f85f59c6a291d59544 data/actuallyadditions/recipes/smooth_black_quartz_slab.json
892f9867958c77a0577adcfd8ce3f8da108ecd3e data/actuallyadditions/recipes/smooth_black_quartz_stair.json

View file

@ -0,0 +1,26 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"C": {
"item": "actuallyadditions:iron_casing"
},
"E": {
"tag": "forge:ender_pearls"
},
"H": {
"item": "minecraft:hopper"
},
"V": {
"item": "actuallyadditions:void_crystal"
}
},
"pattern": [
" V ",
"EHE",
" C "
],
"result": {
"item": "actuallyadditions:ranged_collector"
}
}

View file

@ -355,6 +355,15 @@ public class BlockRecipeGenerator extends RecipeProvider {
.define('E', ActuallyBlocks.ENORI_CRYSTAL.get())
.define('C', ActuallyBlocks.IRON_CASING.get())
.save(recipeOutput);
// Ranged Collector
Recipe.shaped(ActuallyBlocks.RANGED_COLLECTOR.getItem())
.pattern(" V ", "EHE", " C ")
.define('V', ActuallyItems.VOID_CRYSTAL.get())
.define('E', Tags.Items.ENDER_PEARLS)
.define('H', Items.HOPPER)
.define('C', ActuallyBlocks.IRON_CASING.get())
.save(recipeOutput);
}
public static class Recipe {

View file

@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
@ -22,6 +21,7 @@ import net.minecraft.world.inventory.ClickType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
import java.util.Objects;
public class ContainerRangedCollector extends AbstractContainerMenu {
@ -57,8 +57,9 @@ public class ContainerRangedCollector extends AbstractContainerMenu {
}
}
@Nonnull
@Override
public ItemStack quickMoveStack(Player player, int slot) {
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
int inventoryStart = 18;
int inventoryEnd = inventoryStart + 26;
int hotbarStart = inventoryEnd + 1;
@ -87,7 +88,7 @@ public class ContainerRangedCollector extends AbstractContainerMenu {
return ItemStack.EMPTY;
}
if (!StackUtil.isValid(newStack)) {
if (newStack.isEmpty()) {
theSlot.set(ItemStack.EMPTY);
} else {
theSlot.setChanged();
@ -104,7 +105,7 @@ public class ContainerRangedCollector extends AbstractContainerMenu {
}
@Override
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
public void clicked(int slotId, int dragType, @Nonnull ClickType clickTypeIn, @Nonnull Player player) {
if (SlotFilter.checkFilter(this, slotId, player)) {
return; //TODO: Check if this is correct, used to return ItemStack.EMPTY
} else {
@ -113,7 +114,7 @@ public class ContainerRangedCollector extends AbstractContainerMenu {
}
@Override
public boolean stillValid(Player player) {
public boolean stillValid(@Nonnull Player player) {
return this.collector.canPlayerUse(player);
}
}

View file

@ -11,19 +11,15 @@
package de.ellpeck.actuallyadditions.mod.inventory.gui;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.components.Button;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.network.PacketDistributor;
import java.util.ArrayList;
import java.util.List;
@ -37,19 +33,19 @@ public class FilterSettingsGui {
public Button whitelistButton;
public Button modButton;
public FilterSettingsGui(FilterSettings settings, int x, int y, Consumer<AbstractButton> buttonConsumer, int idOffset) {
public FilterSettingsGui(FilterSettings settings, int x, int y, Consumer<AbstractButton> buttonConsumer, Consumer<Integer> clickConsumer, int idOffset) {
this.theSettings = settings;
this.whitelistButton = Button.builder(Component.literal("WH"), $ -> {
theSettings.isWhitelist = !theSettings.isWhitelist;
buttonClicked(idOffset);
clickConsumer.accept(idOffset);
})
.bounds(x, y, 16, 12).build();
buttonConsumer.accept(this.whitelistButton);
y += 14;
this.modButton = Button.builder(Component.literal("MO"), $ -> {
theSettings.respectMod = !theSettings.respectMod;
buttonClicked(idOffset + 1);
clickConsumer.accept(idOffset + 1);
})
.bounds(x, y, 16, 12).build();
buttonConsumer.accept(this.modButton);
@ -57,13 +53,13 @@ public class FilterSettingsGui {
this.tick();
}
public void buttonClicked(int id) {
/* public void buttonClicked(int id) {
CompoundTag data = new CompoundTag();
data.putInt("ButtonID", id);
data.putInt("PlayerID", Minecraft.getInstance().player.getId());
data.putString("WorldID", Minecraft.getInstance().level.dimension().location().toString());
PacketDistributor.SERVER.noArg().send(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER));
}
}*/
public void tick() {
this.whitelistButton.setMessage(Component.literal("WH").withStyle(this.theSettings.isWhitelist

View file

@ -12,14 +12,19 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerRangedCollector;
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.network.PacketDistributor;
import javax.annotation.Nonnull;
@ -43,14 +48,14 @@ public class GuiRangedCollector extends AAScreen<ContainerRangedCollector> {
public void init() {
super.init();
//this.filter = new FilterSettingsGui(this.collector.filter, this.leftPos + 3, this.topPos + 6, this.buttonList);
this.filter = new FilterSettingsGui(this.collector.filter, this.leftPos + 3, this.topPos + 6, this::addRenderableWidget, this::buttonClicked, 0);
}
@Override
public void render(@Nonnull GuiGraphics guiGraphics, int x, int y, float f) {
super.render(guiGraphics, x, y, f);
//this.filter.drawHover(matrices, x, y);
this.filter.drawHover(guiGraphics, x, y);
}
@Override
@ -69,8 +74,15 @@ public class GuiRangedCollector extends AAScreen<ContainerRangedCollector> {
guiGraphics.blit(RES_LOC, this.leftPos, this.topPos, 0, 0, 176, 86);
}
// @Override
// public void actionPerformed(Button button) {
// PacketHandlerHelper.sendButtonPacket(this.collector, button.id);
// }
public void buttonClicked(int id) {
CompoundTag data = new CompoundTag();
data.putInt("ButtonID", id);
data.putInt("PlayerID", Minecraft.getInstance().player.getId());
data.putString("WorldID", Minecraft.getInstance().level.dimension().location().toString());
data.putInt("X", this.collector.getBlockPos().getX());
data.putInt("Y", this.collector.getBlockPos().getY());
data.putInt("Z", this.collector.getBlockPos().getZ());
PacketDistributor.SERVER.noArg().send(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
}
}

View file

@ -51,7 +51,7 @@ public class SackGui extends AAScreen<SackContainer> {
public void init() {
super.init();
this.filter = new FilterSettingsGui(this.container.filter, this.leftPos + 137, this.topPos + 10, this::addRenderableWidget, 1);
this.filter = new FilterSettingsGui(this.container.filter, this.leftPos + 137, this.topPos + 10, this::addRenderableWidget, this::buttonClicked, 1);
this.buttonAutoInsert = Button.builder(
Component.literal("I")

View file

@ -31,6 +31,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
@ -111,17 +112,17 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
@Override
public void onButtonPressed(int buttonID, Player player) {
//this.filter.onButtonPressed(buttonID);
} //TODO
this.filter.onButtonPressed(buttonID);
}
@Override
public Component getDisplayName() {
return Component.empty();
return Component.translatable("container.actuallyadditions.rangedCollector");
}
@Nullable
@Override
public AbstractContainerMenu createMenu(int windowId, Inventory playerInventory, Player player) {
public AbstractContainerMenu createMenu(int windowId, @Nonnull Inventory playerInventory, @Nonnull Player player) {
return new ContainerRangedCollector(windowId, playerInventory, this);
}
}

View file

@ -172,7 +172,7 @@
"block.actuallyadditions.xp_solidifier": "Experience Solidifier",
"block.actuallyadditions.leaf_generator": "Leaf-Eating Generator (wip)",
"block.actuallyadditions.long_range_breaker": "Long-Range Breaker (wip)",
"block.actuallyadditions.ranged_collector": "Ranged Collector (wip)",
"block.actuallyadditions.ranged_collector": "Ranged Collector",
"block.actuallyadditions.laser_relay": "Energy Laser Relay (wip)",
"block.actuallyadditions.laser_relay_advanced": "Advanced Energy Laser Relay (wip)",
"block.actuallyadditions.laser_relay_extreme": "Extreme Energy Laser Relay (wip)",