First Pass at the Void Bag

This commit is contained in:
Flanks255 2021-05-15 09:45:01 -05:00
parent 62e5c41ab5
commit b99eb0cec2
10 changed files with 162 additions and 2 deletions

View file

@ -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

View file

@ -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!",

View file

@ -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() {

View file

@ -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<VoidSackContainer>{
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);
}
}

View file

@ -15,4 +15,7 @@ public final class ActuallyContainers {
public static final RegistryObject<ContainerType<FeederContainer>> FEEDER_CONTAINER
= CONTAINERS.register("feeder_container", () -> IForgeContainerType.create(FeederContainer::fromNetwork));
public static final RegistryObject<ContainerType<VoidSackContainer>> VOID_SACK_CONTAINER
= CONTAINERS.register("void_sack_container", () -> IForgeContainerType.create(VoidSackContainer::fromNetwork));
}

View file

@ -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() {}
}
}

View file

@ -75,7 +75,7 @@ public final class ActuallyItems {
public static final RegistryObject<Item> LASER_RELAY_MODIFIER_INVISIBILITY = ITEMS.register("laser_relay_modifier_invisibility", basicItem());
public static final RegistryObject<Item> HANDHELD_FILLER = ITEMS.register("handheld_filler", basicItem());
public static final RegistryObject<Item> TRAVELERS_SACK = ITEMS.register("travelers_sack", basicItem());
public static final RegistryObject<Item> VOID_SACK = ITEMS.register("void_sack", basicItem());
public static final RegistryObject<Item> VOID_SACK = ITEMS.register("void_sack", VoidSack::new);
public static final RegistryObject<Item> WORM = ITEMS.register("worm", basicItem());
public static final RegistryObject<Item> PLAYER_PROBE = ITEMS.register("player_probe", basicItem());
public static final RegistryObject<Item> ITEM_FILTER = ITEMS.register("item_filter", basicItem());

View file

@ -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<ItemStack> 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);
}
}

View file

@ -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!");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 1 KiB