From b99eb0cec2a332bf5eb91db95d8caab52ffb5ac1 Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Sat, 15 May 2021 09:45:01 -0500 Subject: [PATCH] First Pass at the Void Bag --- src/generated/resources/.cache/cache | 2 +- .../assets/actuallyadditions/lang/en_us.json | 1 + .../actuallyadditions/client/ClientSetup.java | 2 + .../client/screens/VoidSackScreen.java | 35 ++++++++ .../common/container/ActuallyContainers.java | 3 + .../common/container/VoidSackContainer.java | 76 ++++++++++++++++++ .../common/items/ActuallyItems.java | 2 +- .../common/items/useables/VoidSack.java | 42 ++++++++++ .../data/GeneratorLanguage.java | 1 + .../textures/gui/gui_void_bag.png | Bin 2021 -> 1058 bytes 10 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/client/screens/VoidSackScreen.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/container/VoidSackContainer.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/items/useables/VoidSack.java diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 0c3e24e51..af625b6d3 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -122,7 +122,7 @@ e2c81adfe240117fa0ce2e3dfcfd04f4e1034153 assets/actuallyadditions/blockstates/wh 3670535838b4c26d01afe7ee4807c53a6cbaba12 assets/actuallyadditions/blockstates/white_wall_block.json 78e89628e3c6e891f2994b2a1794672f69826516 assets/actuallyadditions/blockstates/wood_casing_block.json 207adf3d139369e983100a6002f6f77d36d40916 assets/actuallyadditions/blockstates/xp_solidifier_block.json -59ee3cf6d1199a2a84ea3e03c89fc3f20dde913f assets/actuallyadditions/lang/en_us.json +826a4316bc53dea8131245950e188dae3d57681c assets/actuallyadditions/lang/en_us.json 997ea09e934d491608895093fc7ba8d2022a50f5 assets/actuallyadditions/models/block/black_brick_quartz_slab_block.json fa8ed5a44ee7475368eaa6c8afcd2fdcc0342a4f assets/actuallyadditions/models/block/black_brick_quartz_slab_block_top.json 00fe865b4ff89f2a82cc40bf11c806fd5ef22130 assets/actuallyadditions/models/block/black_brick_quartz_stair_block.json diff --git a/src/generated/resources/assets/actuallyadditions/lang/en_us.json b/src/generated/resources/assets/actuallyadditions/lang/en_us.json index 88797901f..b7fc50106 100644 --- a/src/generated/resources/assets/actuallyadditions/lang/en_us.json +++ b/src/generated/resources/assets/actuallyadditions/lang/en_us.json @@ -4,6 +4,7 @@ "actuallyadditions.energy.crystal-flux-short": "CF", "actuallyadditions.energy.crystal-flux-single": "%s Crystal Flux", "actuallyadditions.gui.name.drill": "Drill", + "actuallyadditions.gui.name.void_sack": "Void Sack", "actuallyadditions.info.gui.animals": "%s Animals", "actuallyadditions.info.gui.enoughToBreed": "Enough to breed!", "actuallyadditions.info.gui.notEnough": "Not enough to breed!", diff --git a/src/main/java/de/ellpeck/actuallyadditions/client/ClientSetup.java b/src/main/java/de/ellpeck/actuallyadditions/client/ClientSetup.java index 289a8c3a4..088c14919 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/client/ClientSetup.java +++ b/src/main/java/de/ellpeck/actuallyadditions/client/ClientSetup.java @@ -3,6 +3,7 @@ package de.ellpeck.actuallyadditions.client; import de.ellpeck.actuallyadditions.client.render.tiles.BatteryBoxTileRender; import de.ellpeck.actuallyadditions.client.screens.DrillScreen; import de.ellpeck.actuallyadditions.client.screens.FeederScreen; +import de.ellpeck.actuallyadditions.client.screens.VoidSackScreen; import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.container.ActuallyContainers; import de.ellpeck.actuallyadditions.common.tiles.ActuallyTiles; @@ -18,6 +19,7 @@ public class ClientSetup { private static void setupScreens() { ScreenManager.registerFactory(ActuallyContainers.DRILL_CONTAINER.get(), DrillScreen::new); ScreenManager.registerFactory(ActuallyContainers.FEEDER_CONTAINER.get(), FeederScreen::new); + ScreenManager.registerFactory(ActuallyContainers.VOID_SACK_CONTAINER.get(), VoidSackScreen::new); } private static void setupTileRenders() { diff --git a/src/main/java/de/ellpeck/actuallyadditions/client/screens/VoidSackScreen.java b/src/main/java/de/ellpeck/actuallyadditions/client/screens/VoidSackScreen.java new file mode 100644 index 000000000..ea2741900 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/client/screens/VoidSackScreen.java @@ -0,0 +1,35 @@ +package de.ellpeck.actuallyadditions.client.screens; + +import com.mojang.blaze3d.matrix.MatrixStack; +import de.ellpeck.actuallyadditions.common.container.VoidSackContainer; +import de.ellpeck.actuallyadditions.common.utilities.ScreenHelper; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.ITextComponent; + +public class VoidSackScreen extends WtfMojangScreen{ + private static final ResourceLocation background = ScreenHelper.getGuiLocation("gui_void_bag"); + + public VoidSackScreen(VoidSackContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { + super(screenContainer, inv, titleIn); + + this.xSize = 176; + this.ySize = 43 + 86; + + this.titleY += 90; + } + + @Override + protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) { + getMinecraft().getTextureManager().bindTexture(ScreenHelper.INVENTORY_GUI); + blit(matrixStack, this.guiLeft, this.guiTop + 43, 0, 0, 176, 86); + + getMinecraft().getTextureManager().bindTexture(background); + blit(matrixStack, this.guiLeft, this.guiTop, 0, 0, 176, 43); + } + + @Override + public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + super.render(matrixStack, mouseX, mouseY, partialTicks); + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/container/ActuallyContainers.java b/src/main/java/de/ellpeck/actuallyadditions/common/container/ActuallyContainers.java index 0a85fc0e8..e5904764f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/container/ActuallyContainers.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/container/ActuallyContainers.java @@ -15,4 +15,7 @@ public final class ActuallyContainers { public static final RegistryObject> FEEDER_CONTAINER = CONTAINERS.register("feeder_container", () -> IForgeContainerType.create(FeederContainer::fromNetwork)); + + public static final RegistryObject> VOID_SACK_CONTAINER + = CONTAINERS.register("void_sack_container", () -> IForgeContainerType.create(VoidSackContainer::fromNetwork)); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/container/VoidSackContainer.java b/src/main/java/de/ellpeck/actuallyadditions/common/container/VoidSackContainer.java new file mode 100644 index 000000000..a78df0be4 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/common/container/VoidSackContainer.java @@ -0,0 +1,76 @@ +package de.ellpeck.actuallyadditions.common.container; + +import de.ellpeck.actuallyadditions.common.items.useables.VoidSack; +import de.ellpeck.actuallyadditions.common.utilities.ContainerHelper; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.items.wrapper.InvWrapper; + +public class VoidSackContainer extends Container { + ItemStack stack; + public VoidSackContainer(int windowId, PlayerInventory inv, ItemStack stackIn) { + super(ActuallyContainers.VOID_SACK_CONTAINER.get(), windowId); + this.stack = stackIn; + + + ContainerHelper.setupPlayerInventory(new InvWrapper(inv), 0, ContainerHelper.DEFAULT_SLOTS_X, 105, this::addSlot); + + addSlot(new Slot(new VoidInventory(), ContainerHelper.PLAYER_INVENTORY_END_SLOT+1, 13,18)); + } + + public static VoidSackContainer fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) { + return new VoidSackContainer(windowId, inv, inv.player.getHeldItemMainhand()); + } + + @Override + public boolean canInteractWith(PlayerEntity playerIn) { + return playerIn.getHeldItemMainhand().getItem() instanceof VoidSack; + } + + @Override + public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + Slot fromSlot = this.inventorySlots.get(index); + + if (fromSlot == null || !fromSlot.getHasStack()) { + return ItemStack.EMPTY; + } + + ItemStack fromStack = fromSlot.getStack(); + + // Voids an item that is shift clicked... + if (index <= ContainerHelper.PLAYER_INVENTORY_END_SLOT && !(fromStack.getItem() instanceof VoidSack)) { + ItemStack copied = fromStack.copy(); + fromStack.shrink(fromStack.getCount()); + return copied; + } + + return ItemStack.EMPTY; + } + + // Possibly cursed, but does the job + private static class VoidInventory implements IInventory { + @Override + public int getSizeInventory() { return 1; } + @Override + public boolean isEmpty() { return true; } + @Override + public ItemStack getStackInSlot(int index) { return ItemStack.EMPTY; } + @Override + public ItemStack decrStackSize(int index, int count) { return ItemStack.EMPTY; } + @Override + public ItemStack removeStackFromSlot(int index) { return ItemStack.EMPTY; } + @Override + public void setInventorySlotContents(int index, ItemStack stack) {} + @Override + public void markDirty() {} + @Override + public boolean isUsableByPlayer(PlayerEntity player) { return true; } + @Override + public void clear() {} + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/items/ActuallyItems.java b/src/main/java/de/ellpeck/actuallyadditions/common/items/ActuallyItems.java index 733fc503d..69cb0aae3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/items/ActuallyItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/items/ActuallyItems.java @@ -75,7 +75,7 @@ public final class ActuallyItems { public static final RegistryObject LASER_RELAY_MODIFIER_INVISIBILITY = ITEMS.register("laser_relay_modifier_invisibility", basicItem()); public static final RegistryObject HANDHELD_FILLER = ITEMS.register("handheld_filler", basicItem()); public static final RegistryObject TRAVELERS_SACK = ITEMS.register("travelers_sack", basicItem()); - public static final RegistryObject VOID_SACK = ITEMS.register("void_sack", basicItem()); + public static final RegistryObject VOID_SACK = ITEMS.register("void_sack", VoidSack::new); public static final RegistryObject WORM = ITEMS.register("worm", basicItem()); public static final RegistryObject PLAYER_PROBE = ITEMS.register("player_probe", basicItem()); public static final RegistryObject ITEM_FILTER = ITEMS.register("item_filter", basicItem()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/items/useables/VoidSack.java b/src/main/java/de/ellpeck/actuallyadditions/common/items/useables/VoidSack.java new file mode 100644 index 000000000..8b8607ee7 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/common/items/useables/VoidSack.java @@ -0,0 +1,42 @@ +package de.ellpeck.actuallyadditions.common.items.useables; + +import de.ellpeck.actuallyadditions.common.container.DrillContainer; +import de.ellpeck.actuallyadditions.common.container.VoidSackContainer; +import de.ellpeck.actuallyadditions.common.items.ActuallyItem; +import de.ellpeck.actuallyadditions.common.utilities.Help; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.container.SimpleNamedContainerProvider; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.world.World; +import net.minecraftforge.fml.network.NetworkHooks; + +public class VoidSack extends ActuallyItem { + public VoidSack() { + super(baseProps()); + } + + @Override + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { + return false; + } + + @Override + public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + ItemStack stack = playerIn.getHeldItem(handIn); + if (worldIn.isRemote()) { + return ActionResult.resultPass(stack); + } + + if (handIn == Hand.MAIN_HAND) { + NetworkHooks.openGui((ServerPlayerEntity) playerIn, new SimpleNamedContainerProvider( + (windowId, playerInv, playerEntity) -> new VoidSackContainer(windowId, playerInv, stack), + Help.trans("gui.name.void_sack") + )); + } + + return ActionResult.resultSuccess(stack); + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/GeneratorLanguage.java b/src/main/java/de/ellpeck/actuallyadditions/data/GeneratorLanguage.java index ce311360d..4a22f69d3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/GeneratorLanguage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/GeneratorLanguage.java @@ -341,6 +341,7 @@ public class GeneratorLanguage extends LanguageProvider { // Screen names addPrefixed("gui.name.drill", "Drill"); + addPrefixed("gui.name.void_sack", "Void Sack"); addPrefixed("info.gui.animals","%s Animals"); addPrefixed("info.gui.enoughToBreed","Enough to breed!"); diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/gui_void_bag.png b/src/main/resources/assets/actuallyadditions/textures/gui/gui_void_bag.png index 9a3f8d4ce710de1c7e397f254a5b062b837eac99..77c51d0b55e4a679594f2eeed3fab674f6f9e188 100644 GIT binary patch literal 1058 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5D>38$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBzHxw0h%1o(|NsB7W5+^6L(R?2ySuyl+S(>HHGSgeUzU}%F*f!)2geUK zwx4WlzgSs+vV!#W=*&6>qy$TX{DOgcQ2>ML+L=i}NzMX~$YKTtzLg-%_)&T=>%S>`SG|KF|s{q!4O!Tl-i?ayAnm2N0CKg_^pz|ah&GJ1bbI@=?X z5cQgC>SR8VgxddG?d{#T56FbCm{Ycf;Y@)jv%~?0r?+|yUajwc^KoYW+?|Q4*)c2$ z>x@&cMKiy#F9+r$a)+<-hfM6T}~UJn(NhQ~U8F`3HnQ`}(vuGU{atCdB{S^k?2KWAimBz1t{oZz~7hx8LupAJ}qX{j?}Kj@u6}^S%^(ApLv2?tymcOWF*F z|JVGw!@S9mq3A~y?Xu(au0na-j*K_X_#t$ z2o!kE(7@w5#%Zv&r1h0&JLiUd|9{PwPi9T%(+=^s4q`~#(Z$G<&`|U?&F}H2cRy#| zGJjUhp0LQ+e6QaByqJI6YZrbKZG6W#BQw!1mw{PgLCkJRki%0Mm<{eUG4dQZh)lHc zUU<{{^B&`^eR}nB+a>oh*8pX~hO=>Qc>QHpO}qHB-7GVv{k-aQnt36c-TfXp#(f+A z|6;1yBe|E!;LrKx=WP|FnIA;(G$e!lY9ThFIh_0-zJ23=R{YiH!@rIwVBTZ!boFyt I=akR{0Pdi+&Hw-a literal 2021 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&2?&#~tz_78O`%fY(kk47* z5n0T@z_%KN8T;NG`2!S`C~=J_3C>R|DNig)Whh9@%q!8$OD$0_(KFDq%rUO>V_;xU z_H=O!sfc@fEwJy3l>lo%*-@_u(cekY3Cnjy_k;@dRlhlM*z(fUd%riVG`X(2@9n$q z@9%FvA9+(&`}6c)_T@Y+YYvp326F@ceV+F!$5842-dpXvpRak-H?>pn-RtY?6b3vhC0IO8-x3&zrVk4|NQy+`Nw*wa=$0If37+3{)uHj>jCeV zN6cPMof`|ZdJBK0i5Nrh6u+FwaW`)Qec}XEn9OM4I^vXoLT6QZBrqCK!Xo%T>xaBo zLMy>CeR)WsG#Z@v(hyC9GxX)L+~TmZ(yC)YT7<@u^ z72byCxD5GE89EHhwC?W6h2}VDvY(oF#|)a|ZnfJ;aW|~=GS8b0&2ev?<$75Uge;Zb zeioGPfjRD*V*fFw2VUnltvR#d(r0hDh?aX{*y{ScKOdi8eH;$Vs}P-{eV1Yuif#S( z)9{$((;rJa1rOct|1md$A?BgR+55MW&YiMW)lH6@1IkMajl64r?6--%{#cgRVcHp>;{D8~L_`0Gn?#Y^z^v^n}(m=iQ_FuKGJeSOP;kAbERk2OajJH<#f;!lqBTNst+%s2gn_w#DFb~z$ zL*1Y!Kcn}qzLyFNr@+~JPRx%yWoA8XOU1O@8HUrNyopOZlH$=nOvf6mll z*f+(!SGPg#Y5FFHA3<`a+Zd{*%s