mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Some sack fixes, other misc things.
This commit is contained in:
parent
457cf00a7b
commit
3edef49c04
11 changed files with 67 additions and 90 deletions
|
@ -4,12 +4,21 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.tags.ITag;
|
import net.minecraft.tags.ITag;
|
||||||
import net.minecraft.tags.ItemTags;
|
import net.minecraft.tags.ItemTags;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public final class ActuallyTags {
|
public final class ActuallyTags {
|
||||||
|
public static final void init() {
|
||||||
|
// lol
|
||||||
|
Items.touch();
|
||||||
|
}
|
||||||
public static class Items {
|
public static class Items {
|
||||||
|
public static void touch() {
|
||||||
|
// load the stupid tags
|
||||||
|
}
|
||||||
public static final ITag.INamedTag<Item> DRILLS = tag("drills");
|
public static final ITag.INamedTag<Item> DRILLS = tag("drills");
|
||||||
public static final ITag.INamedTag<Item> COFFEE_BEANS = tag("coffee_beans");
|
public static final ITag.INamedTag<Item> COFFEE_BEANS = tag("coffee_beans");
|
||||||
public static final ITag.INamedTag<Item> TINY_COALS = tag("tiny_coals");
|
public static final ITag.INamedTag<Item> TINY_COALS = tag("tiny_coals");
|
||||||
|
public static final ITag.INamedTag<Item> HOLDS_ITEMS = ItemTags.createOptional(new ResourceLocation("forge", "holds_items"));
|
||||||
public static final ITag.INamedTag<Item> CRYSTALS = tag("crystals");
|
public static final ITag.INamedTag<Item> CRYSTALS = tag("crystals");
|
||||||
|
|
||||||
private static ITag.INamedTag<Item> tag(String name) {
|
private static ITag.INamedTag<Item> tag(String name) {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod;
|
package de.ellpeck.actuallyadditions.mod;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
|
import de.ellpeck.actuallyadditions.api.ActuallyTags;
|
||||||
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||||
|
@ -26,7 +27,7 @@ import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers;
|
import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemWorm;
|
import de.ellpeck.actuallyadditions.mod.items.Worm;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.BannerHelper;
|
import de.ellpeck.actuallyadditions.mod.misc.BannerHelper;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
|
import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler;
|
||||||
|
@ -103,13 +104,14 @@ public class ActuallyAdditions {
|
||||||
ENTITIES.register(eventBus);
|
ENTITIES.register(eventBus);
|
||||||
eventBus.addListener(this::onConfigReload);
|
eventBus.addListener(this::onConfigReload);
|
||||||
ActuallyParticles.init(eventBus);
|
ActuallyParticles.init(eventBus);
|
||||||
|
ActuallyTags.init();
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.addListener(this::serverStarted);
|
MinecraftForge.EVENT_BUS.addListener(this::serverStarted);
|
||||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopped);
|
MinecraftForge.EVENT_BUS.addListener(this::serverStopped);
|
||||||
MinecraftForge.EVENT_BUS.register(new CommonEvents());
|
MinecraftForge.EVENT_BUS.register(new CommonEvents());
|
||||||
MinecraftForge.EVENT_BUS.register(new DungeonLoot());
|
MinecraftForge.EVENT_BUS.register(new DungeonLoot());
|
||||||
MinecraftForge.EVENT_BUS.addListener(ActuallyAdditions::reloadEvent);
|
MinecraftForge.EVENT_BUS.addListener(ActuallyAdditions::reloadEvent);
|
||||||
MinecraftForge.EVENT_BUS.addListener(ItemWorm::onHoe);
|
MinecraftForge.EVENT_BUS.addListener(Worm::onHoe);
|
||||||
InitFluids.init(eventBus);
|
InitFluids.init(eventBus);
|
||||||
|
|
||||||
eventBus.addListener(this::setup);
|
eventBus.addListener(this::setup);
|
||||||
|
|
|
@ -19,7 +19,9 @@ import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.*;
|
import de.ellpeck.actuallyadditions.mod.inventory.gui.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit;
|
import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit;
|
||||||
import de.ellpeck.actuallyadditions.mod.particle.*;
|
import de.ellpeck.actuallyadditions.mod.particle.ActuallyParticles;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.particle.ParticleLaserItem;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.ScreenManager;
|
import net.minecraft.client.gui.ScreenManager;
|
||||||
import net.minecraft.client.network.play.ClientPlayNetHandler;
|
import net.minecraft.client.network.play.ClientPlayNetHandler;
|
||||||
|
@ -38,7 +40,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
public class ActuallyAdditionsClient {
|
public class ActuallyAdditionsClient {
|
||||||
|
|
||||||
public static void setup(FMLClientSetupEvent event) {
|
public static void setup(FMLClientSetupEvent event) {
|
||||||
ScreenManager.register(ActuallyContainers.BAG_CONTAINER.get(), GuiBag::new);
|
ScreenManager.register(ActuallyContainers.BAG_CONTAINER.get(), SackGui::new);
|
||||||
ScreenManager.register(ActuallyContainers.BIO_REACTOR_CONTAINER.get(), GuiBioReactor::new);
|
ScreenManager.register(ActuallyContainers.BIO_REACTOR_CONTAINER.get(), GuiBioReactor::new);
|
||||||
ScreenManager.register(ActuallyContainers.BREAKER_CONTAINER.get(), GuiBreaker::new);
|
ScreenManager.register(ActuallyContainers.BREAKER_CONTAINER.get(), GuiBreaker::new);
|
||||||
ScreenManager.register(ActuallyContainers.CANOLA_PRESS_CONTAINER.get(), GuiCanolaPress::new);
|
ScreenManager.register(ActuallyContainers.CANOLA_PRESS_CONTAINER.get(), GuiCanolaPress::new);
|
||||||
|
|
|
@ -14,11 +14,6 @@ import de.ellpeck.actuallyadditions.mod.config.ConfigCategories;
|
||||||
|
|
||||||
public enum ConfigStringListValues {
|
public enum ConfigStringListValues {
|
||||||
|
|
||||||
CONFIGURE_ITEMS(
|
|
||||||
"Configuration Items",
|
|
||||||
ConfigCategories.OTHER,
|
|
||||||
new String[] { "minecraft:redstone_torch", "minecraft:compass" },
|
|
||||||
"The non-Actually Additions items that are used to configure blocks from the mod. The first one is the Redstone Torch used to configure the Redstone Mode, and the second one is the Compass used to configure Laser Relays. If another mod overrides usage of either one of these items, you can change the registry name of the used items (using blocks is not possible) here."),
|
|
||||||
CRUSHER_RECIPE_EXCEPTIONS(
|
CRUSHER_RECIPE_EXCEPTIONS(
|
||||||
"Crusher Recipe Exceptions",
|
"Crusher Recipe Exceptions",
|
||||||
ConfigCategories.OTHER,
|
ConfigCategories.OTHER,
|
||||||
|
@ -70,11 +65,6 @@ public enum ConfigStringListValues {
|
||||||
ConfigCategories.OTHER,
|
ConfigCategories.OTHER,
|
||||||
new String[] { "minecraft:villager_golem" },
|
new String[] { "minecraft:villager_golem" },
|
||||||
"By default, the Spawner Changer allows every living entity to be put into a spawner. If there is one that shouldn't be able to, put its MAPPING NAME here."),
|
"By default, the Spawner Changer allows every living entity to be put into a spawner. If there is one that shouldn't be able to, put its MAPPING NAME here."),
|
||||||
SACK_BLACKLIST(
|
|
||||||
"Sack Blacklist",
|
|
||||||
ConfigCategories.OTHER,
|
|
||||||
new String[0],
|
|
||||||
"The items that aren't allowed to be put in the Traveller's Sack. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_block@3"),
|
|
||||||
REPAIR_BLACKLIST(
|
REPAIR_BLACKLIST(
|
||||||
"Repair Blacklist",
|
"Repair Blacklist",
|
||||||
ConfigCategories.OTHER,
|
ConfigCategories.OTHER,
|
||||||
|
|
|
@ -17,7 +17,7 @@ import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||||
import de.ellpeck.actuallyadditions.mod.data.WorldData;
|
import de.ellpeck.actuallyadditions.mod.data.WorldData;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.DrillItem;
|
import de.ellpeck.actuallyadditions.mod.items.DrillItem;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemBag;
|
import de.ellpeck.actuallyadditions.mod.items.Sack;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
|
@ -66,11 +66,11 @@ public class CommonEvents {
|
||||||
if (i != player.inventory.selected) {
|
if (i != player.inventory.selected) {
|
||||||
|
|
||||||
ItemStack invStack = player.inventory.getItem(i);
|
ItemStack invStack = player.inventory.getItem(i);
|
||||||
if (StackUtil.isValid(invStack) && invStack.getItem() instanceof ItemBag && invStack.hasTag()) {
|
if (StackUtil.isValid(invStack) && invStack.getItem() instanceof Sack && invStack.hasTag()) {
|
||||||
if (invStack.getOrCreateTag().getBoolean("AutoInsert")) {
|
if (invStack.getOrCreateTag().getBoolean("AutoInsert")) {
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
boolean isVoid = ((ItemBag) invStack.getItem()).isVoid;
|
boolean isVoid = ((Sack) invStack.getItem()).isVoid;
|
||||||
ItemStackHandlerAA inv = new ItemStackHandlerAA(28); //TODO whats going on here
|
ItemStackHandlerAA inv = new ItemStackHandlerAA(28); //TODO whats going on here
|
||||||
DrillItem.loadSlotsFromNBT(inv, invStack);
|
DrillItem.loadSlotsFromNBT(inv, invStack);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||||
public class ActuallyContainers {
|
public class ActuallyContainers {
|
||||||
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, ActuallyAdditions.MODID);
|
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, ActuallyAdditions.MODID);
|
||||||
|
|
||||||
public static final RegistryObject<ContainerType<ContainerBag>> BAG_CONTAINER = CONTAINERS.register("bag_container", () -> IForgeContainerType.create(ContainerBag::fromNetwork));
|
public static final RegistryObject<ContainerType<SackContainer>> BAG_CONTAINER = CONTAINERS.register("bag_container", () -> IForgeContainerType.create(SackContainer::fromNetwork));
|
||||||
public static final RegistryObject<ContainerType<ContainerBioReactor>> BIO_REACTOR_CONTAINER = CONTAINERS.register("bioreactor_container", () -> IForgeContainerType.create(ContainerBioReactor::fromNetwork));
|
public static final RegistryObject<ContainerType<ContainerBioReactor>> BIO_REACTOR_CONTAINER = CONTAINERS.register("bioreactor_container", () -> IForgeContainerType.create(ContainerBioReactor::fromNetwork));
|
||||||
public static final RegistryObject<ContainerType<ContainerBreaker>> BREAKER_CONTAINER = CONTAINERS.register("breaker_container", () -> IForgeContainerType.create(ContainerBreaker::fromNetwork));
|
public static final RegistryObject<ContainerType<ContainerBreaker>> BREAKER_CONTAINER = CONTAINERS.register("breaker_container", () -> IForgeContainerType.create(ContainerBreaker::fromNetwork));
|
||||||
public static final RegistryObject<ContainerType<ContainerCanolaPress>> CANOLA_PRESS_CONTAINER = CONTAINERS.register("canola_press_container", () -> IForgeContainerType.create(ContainerCanolaPress::fromNetwork));
|
public static final RegistryObject<ContainerType<ContainerCanolaPress>> CANOLA_PRESS_CONTAINER = CONTAINERS.register("canola_press_container", () -> IForgeContainerType.create(ContainerCanolaPress::fromNetwork));
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.api.ActuallyTags;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotDeletion;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotDeletion;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.DrillItem;
|
import de.ellpeck.actuallyadditions.mod.items.Sack;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemBag;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
|
@ -24,19 +24,16 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.ClickType;
|
import net.minecraft.inventory.container.ClickType;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ContainerBag extends Container implements IButtonReactor {
|
public class SackContainer extends Container implements IButtonReactor {
|
||||||
|
|
||||||
public final FilterSettings filter = new FilterSettings(4, false, false, false);
|
public final FilterSettings filter = new FilterSettings(4, false, false, false);
|
||||||
private final ItemStackHandlerAA bagInventory;
|
private final ItemStackHandlerAA bagInventory;
|
||||||
|
@ -46,45 +43,49 @@ public class ContainerBag extends Container implements IButtonReactor {
|
||||||
|
|
||||||
public static final int SIZE = 28;
|
public static final int SIZE = 28;
|
||||||
|
|
||||||
public static ContainerBag fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
|
public static SackContainer fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
|
||||||
return new ContainerBag(windowId, inv, data.readUUID(), new ItemStackHandlerAA(28));
|
return new SackContainer(windowId, inv, data.readUUID(), new ItemStackHandlerAA(28));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerBag(int windowId, PlayerInventory playerInventory, UUID uuid, ItemStackHandlerAA handler) {
|
public SackContainer(int windowId, PlayerInventory playerInventory, UUID uuid, ItemStackHandlerAA handler) {
|
||||||
super(ActuallyContainers.BAG_CONTAINER.get(), windowId);
|
super(ActuallyContainers.BAG_CONTAINER.get(), windowId);
|
||||||
|
|
||||||
this.inventory = playerInventory;
|
this.inventory = playerInventory;
|
||||||
this.bagInventory = handler; //new ItemStackHandlerAA(SIZE, (slot, stack, automation) -> !isBlacklisted(stack), ItemStackHandlerAA.REMOVE_TRUE);
|
this.bagInventory = handler;
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int row = 0; row < 4; row++) {
|
||||||
this.addSlot(new SlotFilter(this.filter, i, 155, 10 + i * 18));
|
this.addSlot(new SlotFilter(this.filter, row, 155, 10 + row * 18));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false) { // isvoid, move to its own container
|
if (false) { // TODO isvoid, move to its own container
|
||||||
this.addSlot(new SlotDeletion(this.bagInventory, 0, 64, 65) {
|
this.addSlot(new SlotDeletion(this.bagInventory, 0, 64, 65) {
|
||||||
@Override
|
@Override
|
||||||
public boolean mayPlace(ItemStack stack) {
|
public boolean mayPlace(ItemStack stack) {
|
||||||
return ContainerBag.this.filter.check(stack);
|
return SackContainer.this.filter.check(stack);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
// Sack inventory
|
||||||
for (int j = 0; j < 7; j++) {
|
for (int row = 0; row < 4; row++) {
|
||||||
this.addSlot(new SlotItemHandlerUnconditioned(this.bagInventory, j + i * 7, 10 + j * 18, 10 + i * 18) {
|
for (int col = 0; col < 7; col++) {
|
||||||
|
this.addSlot(new SlotItemHandlerUnconditioned(this.bagInventory, col + row * 7, 10 + col * 18, 10 + row * 18) {
|
||||||
@Override
|
@Override
|
||||||
public boolean mayPlace(ItemStack stack) {
|
public boolean mayPlace(ItemStack stack) {
|
||||||
return !isBlacklisted(stack) && ContainerBag.this.filter.check(stack);
|
return !stack.getItem().is(ActuallyTags.Items.HOLDS_ITEMS) && SackContainer.this.filter.check(stack);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
// Player Inventory
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int row = 0; row < 3; row++) {
|
||||||
this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 94 + i * 18));
|
for (int col = 0; col < 9; col++) {
|
||||||
|
this.addSlot(new Slot(playerInventory, col + row * 9 + 9, 8 + col * 18, 94 + row * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Player Hotbar
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
if (i == playerInventory.selected) {
|
if (i == playerInventory.selected) {
|
||||||
this.addSlot(new SlotImmovable(playerInventory, i, 8 + i * 18, 152));
|
this.addSlot(new SlotImmovable(playerInventory, i, 8 + i * 18, 152));
|
||||||
|
@ -94,8 +95,8 @@ public class ContainerBag extends Container implements IButtonReactor {
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = playerInventory.getSelected();
|
ItemStack stack = playerInventory.getSelected();
|
||||||
if (!stack.isEmpty() && stack.getItem() instanceof ItemBag) {
|
if (!stack.isEmpty() && stack.getItem() instanceof Sack) {
|
||||||
DrillItem.loadSlotsFromNBT(this.bagInventory, playerInventory.getSelected());
|
//DrillItem.loadSlotsFromNBT(this.bagInventory, playerInventory.getSelected());
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
CompoundNBT compound = stack.getOrCreateTag();
|
CompoundNBT compound = stack.getOrCreateTag();
|
||||||
this.filter.readFromNBT(compound, "Filter");
|
this.filter.readFromNBT(compound, "Filter");
|
||||||
|
@ -105,7 +106,7 @@ public class ContainerBag extends Container implements IButtonReactor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void broadcastChanges() {
|
public void broadcastChanges() { // TODO is this needed anymore?
|
||||||
super.broadcastChanges();
|
super.broadcastChanges();
|
||||||
|
|
||||||
if (this.filter.needsUpdateSend() || this.autoInsert != this.oldAutoInsert) {
|
if (this.filter.needsUpdateSend() || this.autoInsert != this.oldAutoInsert) {
|
||||||
|
@ -149,7 +150,7 @@ public class ContainerBag extends Container implements IButtonReactor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(PlayerEntity player, int slot) {
|
public ItemStack quickMoveStack(@Nonnull PlayerEntity player, int slot) {
|
||||||
int inventoryStart = this.bagInventory.getSlots() + 4;
|
int inventoryStart = this.bagInventory.getSlots() + 4;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -165,7 +166,7 @@ public class ContainerBag extends Container implements IButtonReactor {
|
||||||
if (slot >= inventoryStart) {
|
if (slot >= inventoryStart) {
|
||||||
//Shift from Inventory
|
//Shift from Inventory
|
||||||
if (!this.filter.check(newStack) || !this.moveItemStackTo(newStack, 4, 32, false)) {
|
if (!this.filter.check(newStack) || !this.moveItemStackTo(newStack, 4, 32, false)) {
|
||||||
if (slot >= inventoryStart && slot <= inventoryEnd) {
|
if (slot <= inventoryEnd) {
|
||||||
if (!this.moveItemStackTo(newStack, hotbarStart, hotbarEnd + 1, false)) {
|
if (!this.moveItemStackTo(newStack, hotbarStart, hotbarEnd + 1, false)) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
@ -209,8 +210,8 @@ public class ContainerBag extends Container implements IButtonReactor {
|
||||||
@Override
|
@Override
|
||||||
public void removed(PlayerEntity player) {
|
public void removed(PlayerEntity player) {
|
||||||
ItemStack stack = this.inventory.getSelected();
|
ItemStack stack = this.inventory.getSelected();
|
||||||
if (!stack.isEmpty() && stack.getItem() instanceof ItemBag) {
|
if (!stack.isEmpty() && stack.getItem() instanceof Sack) {
|
||||||
DrillItem.writeSlotsToNBT(this.bagInventory, this.inventory.getSelected());
|
//DrillItem.writeSlotsToNBT(this.bagInventory, this.inventory.getSelected());
|
||||||
CompoundNBT compound = stack.getOrCreateTag();
|
CompoundNBT compound = stack.getOrCreateTag();
|
||||||
this.filter.writeToNBT(compound, "Filter");
|
this.filter.writeToNBT(compound, "Filter");
|
||||||
compound.putBoolean("AutoInsert", this.autoInsert);
|
compound.putBoolean("AutoInsert", this.autoInsert);
|
||||||
|
@ -220,7 +221,7 @@ public class ContainerBag extends Container implements IButtonReactor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(PlayerEntity player) {
|
public boolean stillValid(PlayerEntity player) {
|
||||||
return true; //!this.sack.isEmpty() && player.getMainHandItem() == this.sack; //TODO fix later
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -231,31 +232,4 @@ public class ContainerBag extends Container implements IButtonReactor {
|
||||||
//this.filter.onButtonPressed(buttonID); //TODO
|
//this.filter.onButtonPressed(buttonID); //TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final List<Pair<Item, Integer>> BLACKLIST = new ArrayList<>();
|
|
||||||
|
|
||||||
private static boolean runOnce = false;
|
|
||||||
|
|
||||||
// TODO: [port] FIX THIS
|
|
||||||
public static boolean isBlacklisted(ItemStack stack) {
|
|
||||||
//TODO replace with modern tagging blocking etc
|
|
||||||
return false;
|
|
||||||
/* if (!runOnce) {
|
|
||||||
runOnce = true;
|
|
||||||
for (String s : ConfigStringListValues.SACK_BLACKLIST.getValue()) {
|
|
||||||
String[] split = s.split("@");
|
|
||||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(split[0]));
|
|
||||||
if (item == null) {
|
|
||||||
ActuallyAdditions.LOGGER.error("Invalid item in sack blacklist: " + s);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (split.length == 1) {
|
|
||||||
BLACKLIST.add(Pair.of(item, 0));
|
|
||||||
} else if (split.length == 2) {
|
|
||||||
BLACKLIST.add(Pair.of(item, Integer.parseInt(split[1])));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return BLACKLIST.contains(Pair.of(stack.getItem(), 0));*/
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag;
|
import de.ellpeck.actuallyadditions.mod.inventory.SackContainer;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
@ -21,16 +21,16 @@ import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class GuiBag extends AAScreen<ContainerBag> {
|
public class SackGui extends AAScreen<SackContainer> {
|
||||||
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_bag");
|
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_bag");
|
||||||
private static final ResourceLocation RES_LOC_VOID = AssetUtil.getGuiLocation("gui_void_bag");
|
private static final ResourceLocation RES_LOC_VOID = AssetUtil.getGuiLocation("gui_void_bag");
|
||||||
|
|
||||||
private final ContainerBag container;
|
private final SackContainer container;
|
||||||
private final boolean isVoid;
|
private final boolean isVoid;
|
||||||
private FilterSettingsGui filter;
|
private FilterSettingsGui filter;
|
||||||
private Button buttonAutoInsert;
|
private Button buttonAutoInsert;
|
||||||
|
|
||||||
public GuiBag(ContainerBag container, PlayerInventory inventory, ITextComponent title) {
|
public SackGui(SackContainer container, PlayerInventory inventory, ITextComponent title) {
|
||||||
super(container, inventory, title);
|
super(container, inventory, title);
|
||||||
this.imageWidth = 176;
|
this.imageWidth = 176;
|
||||||
this.imageHeight = 90 + 86;
|
this.imageHeight = 90 + 86;
|
|
@ -99,9 +99,9 @@ public final class ActuallyItems {
|
||||||
public static final RegistryObject<Item> LASER_UPGRADE_RANGE = ITEMS.register("laser_upgrade_range", ItemLaserRelayUpgrade::new);
|
public static final RegistryObject<Item> LASER_UPGRADE_RANGE = ITEMS.register("laser_upgrade_range", ItemLaserRelayUpgrade::new);
|
||||||
public static final RegistryObject<Item> LASER_UPGRADE_INVISIBILITY = ITEMS.register("laser_upgrade_invisibility", ItemLaserRelayUpgrade::new);
|
public static final RegistryObject<Item> LASER_UPGRADE_INVISIBILITY = ITEMS.register("laser_upgrade_invisibility", ItemLaserRelayUpgrade::new);
|
||||||
public static final Supplier<Item> HANDHELD_FILLER = ITEMS.register("handheld_filler", ItemFillingWand::new);
|
public static final Supplier<Item> HANDHELD_FILLER = ITEMS.register("handheld_filler", ItemFillingWand::new);
|
||||||
public static final RegistryObject<Item> TRAVELERS_SACK = ITEMS.register("travelers_sack", () -> new ItemBag(false));
|
public static final RegistryObject<Item> TRAVELERS_SACK = ITEMS.register("travelers_sack", () -> new Sack(false));
|
||||||
public static final RegistryObject<Item> VOID_SACK = ITEMS.register("void_sack", () -> new ItemBag(true));
|
public static final RegistryObject<Item> VOID_SACK = ITEMS.register("void_sack", () -> new Sack(true));
|
||||||
public static final RegistryObject<Item> WORM = ITEMS.register("worm", ItemWorm::new);
|
public static final RegistryObject<Item> WORM = ITEMS.register("worm", Worm::new);
|
||||||
public static final RegistryObject<Item> PLAYER_PROBE = ITEMS.register("player_probe", ItemPlayerProbe::new);
|
public static final RegistryObject<Item> PLAYER_PROBE = ITEMS.register("player_probe", ItemPlayerProbe::new);
|
||||||
public static final RegistryObject<Item> FILTER = ITEMS.register("filter", ItemFilter::new);
|
public static final RegistryObject<Item> FILTER = ITEMS.register("filter", ItemFilter::new);
|
||||||
public static final RegistryObject<Item> WATER_BOWL = ITEMS.register("water_bowl", ItemWaterBowl::new);
|
public static final RegistryObject<Item> WATER_BOWL = ITEMS.register("water_bowl", ItemWaterBowl::new);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag;
|
import de.ellpeck.actuallyadditions.mod.inventory.SackContainer;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.sack.SackData;
|
import de.ellpeck.actuallyadditions.mod.sack.SackData;
|
||||||
import de.ellpeck.actuallyadditions.mod.sack.SackManager;
|
import de.ellpeck.actuallyadditions.mod.sack.SackManager;
|
||||||
|
@ -32,10 +32,10 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ItemBag extends ItemBase {
|
public class Sack extends ItemBase {
|
||||||
public final boolean isVoid;
|
public final boolean isVoid;
|
||||||
|
|
||||||
public ItemBag(boolean isVoid) {
|
public Sack(boolean isVoid) {
|
||||||
super(ActuallyItems.defaultProps().stacksTo(1));
|
super(ActuallyItems.defaultProps().stacksTo(1));
|
||||||
this.isVoid = isVoid;
|
this.isVoid = isVoid;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ public class ItemBag extends ItemBase {
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||||
ItemStack sackStack = player.getItemInHand(hand);
|
ItemStack sackStack = player.getItemInHand(hand);
|
||||||
if (!world.isClientSide && hand == Hand.MAIN_HAND && sackStack.getItem() instanceof ItemBag && player instanceof ServerPlayerEntity) {
|
if (!world.isClientSide && hand == Hand.MAIN_HAND && sackStack.getItem() instanceof Sack && player instanceof ServerPlayerEntity) {
|
||||||
|
|
||||||
if (!isVoid) {
|
if (!isVoid) {
|
||||||
SackData data = getData(sackStack);
|
SackData data = getData(sackStack);
|
||||||
|
@ -100,7 +100,7 @@ public class ItemBag extends ItemBase {
|
||||||
|
|
||||||
|
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, new SimpleNamedContainerProvider((id, inv, entity) ->
|
NetworkHooks.openGui((ServerPlayerEntity) player, new SimpleNamedContainerProvider((id, inv, entity) ->
|
||||||
new ContainerBag(id, inv, uuid, data.getSpecialHandler()), sackStack.getHoverName()), (buffer -> buffer.writeUUID(uuid)));
|
new SackContainer(id, inv, uuid, data.getSpecialHandler()), sackStack.getHoverName()), (buffer -> buffer.writeUUID(uuid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class ItemBag extends ItemBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SackData getData(ItemStack stack) {
|
public static SackData getData(ItemStack stack) {
|
||||||
if (!(stack.getItem() instanceof ItemBag))
|
if (!(stack.getItem() instanceof Sack))
|
||||||
return null;
|
return null;
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
CompoundNBT tag = stack.getOrCreateTag();
|
CompoundNBT tag = stack.getOrCreateTag();
|
|
@ -28,9 +28,9 @@ import net.minecraftforge.eventbus.api.Event;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ItemWorm extends ItemBase {
|
public class Worm extends ItemBase {
|
||||||
|
|
||||||
public ItemWorm() {
|
public Worm() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue