Move container builder to Reborn Core
This commit is contained in:
parent
e7604cd9ce
commit
b399e211fa
58 changed files with 130 additions and 1265 deletions
|
@ -30,7 +30,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import techreborn.client.container.ContainerDestructoPack;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import techreborn.client.gui.*;
|
||||
import techreborn.client.gui.GuiAutoCrafting;
|
||||
import techreborn.tiles.*;
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class IconSupplier {
|
||||
public static String armour_head_name = "techreborn:gui/slot_sprites/armour_head";
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite armour_head;
|
||||
|
||||
public static String armour_chest_name = "techreborn:gui/slot_sprites/armour_chest";
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite armour_chest;
|
||||
|
||||
public static String armour_legs_name = "techreborn:gui/slot_sprites/armour_legs";
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite armour_legs;
|
||||
|
||||
public static String armour_feet_name = "techreborn:gui/slot_sprites/armour_feet";
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite armour_feet;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void preTextureStitch(TextureStitchEvent.Pre event) {
|
||||
TextureMap map = event.getMap();
|
||||
armour_head = map.registerSprite(new ResourceLocation(armour_head_name));
|
||||
armour_chest = map.registerSprite(new ResourceLocation(armour_chest_name));
|
||||
armour_legs = map.registerSprite(new ResourceLocation(armour_legs_name));
|
||||
armour_feet = map.registerSprite(new ResourceLocation(armour_feet_name));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
|
||||
public interface IContainerProvider {
|
||||
BuiltContainer createContainer(EntityPlayer player);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
|
||||
/**
|
||||
* Created by Mark on 12/04/2017.
|
||||
*/
|
||||
public interface IRightClickHandler {
|
||||
|
||||
public boolean handleRightClick(int slotID, EntityPlayer player, BuiltContainer container);
|
||||
}
|
|
@ -1,307 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container.builder;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.MutableTriple;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.client.container.IRightClickHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class BuiltContainer extends Container {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Predicate<EntityPlayer> canInteract;
|
||||
private final List<Range<Integer>> playerSlotRanges;
|
||||
private final List<Range<Integer>> tileSlotRanges;
|
||||
|
||||
private final ArrayList<MutableTriple<IntSupplier, IntConsumer, Short>> shortValues;
|
||||
private final ArrayList<MutableTriple<IntSupplier, IntConsumer, Integer>> integerValues;
|
||||
private List<Consumer<InventoryCrafting>> craftEvents;
|
||||
private Integer[] integerParts;
|
||||
|
||||
private final TileLegacyMachineBase tile;
|
||||
|
||||
public BuiltContainer(final String name, final Predicate<EntityPlayer> canInteract,
|
||||
final List<Range<Integer>> playerSlotRange,
|
||||
final List<Range<Integer>> tileSlotRange, TileLegacyMachineBase tile) {
|
||||
this.name = name;
|
||||
|
||||
this.canInteract = canInteract;
|
||||
|
||||
this.playerSlotRanges = playerSlotRange;
|
||||
this.tileSlotRanges = tileSlotRange;
|
||||
|
||||
this.shortValues = new ArrayList<>();
|
||||
this.integerValues = new ArrayList<>();
|
||||
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public void addShortSync(final List<Pair<IntSupplier, IntConsumer>> syncables) {
|
||||
|
||||
for (final Pair<IntSupplier, IntConsumer> syncable : syncables)
|
||||
this.shortValues.add(MutableTriple.of(syncable.getLeft(), syncable.getRight(), (short) 0));
|
||||
this.shortValues.trimToSize();
|
||||
}
|
||||
|
||||
public void addIntegerSync(final List<Pair<IntSupplier, IntConsumer>> syncables) {
|
||||
|
||||
for (final Pair<IntSupplier, IntConsumer> syncable : syncables)
|
||||
this.integerValues.add(MutableTriple.of(syncable.getLeft(), syncable.getRight(), 0));
|
||||
this.integerValues.trimToSize();
|
||||
this.integerParts = new Integer[this.integerValues.size()];
|
||||
}
|
||||
|
||||
public void addCraftEvents(final List<Consumer<InventoryCrafting>> craftEvents) {
|
||||
this.craftEvents = craftEvents;
|
||||
}
|
||||
|
||||
public void addSlot(final Slot slot) {
|
||||
this.addSlotToContainer(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(final EntityPlayer playerIn) {
|
||||
if(this.tile != null) {
|
||||
return tile.isUsableByPlayer(playerIn);
|
||||
} else {
|
||||
return this.canInteract.test(playerIn); // <
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCraftMatrixChanged(final IInventory inv) {
|
||||
if (!this.craftEvents.isEmpty())
|
||||
this.craftEvents.forEach(consumer -> consumer.accept((InventoryCrafting) inv));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
||||
if (dragType == 1 && slotId > 0 && slotId < 1000) {
|
||||
Slot slot = this.inventorySlots.get(slotId);
|
||||
if (slot instanceof IRightClickHandler) {
|
||||
if (((IRightClickHandler) slot).handleRightClick(slot.getSlotIndex(), player, this)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.slotClick(slotId, dragType, clickTypeIn, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (final IContainerListener listener : this.listeners) {
|
||||
|
||||
int i = 0;
|
||||
if (!this.shortValues.isEmpty())
|
||||
for (final MutableTriple<IntSupplier, IntConsumer, Short> value : this.shortValues) {
|
||||
final short supplied = (short) value.getLeft().getAsInt();
|
||||
if (supplied != value.getRight()) {
|
||||
|
||||
listener.sendWindowProperty(this, i, supplied);
|
||||
value.setRight(supplied);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!this.integerValues.isEmpty())
|
||||
for (final MutableTriple<IntSupplier, IntConsumer, Integer> value : this.integerValues) {
|
||||
final int supplied = value.getLeft().getAsInt();
|
||||
if (supplied != value.getRight()) {
|
||||
|
||||
listener.sendWindowProperty(this, i, supplied >> 16);
|
||||
listener.sendWindowProperty(this, i + 1, (short) (supplied & 0xFFFF));
|
||||
value.setRight(supplied);
|
||||
}
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(final IContainerListener listener) {
|
||||
super.addListener(listener);
|
||||
|
||||
int i = 0;
|
||||
if (!this.shortValues.isEmpty())
|
||||
for (final MutableTriple<IntSupplier, IntConsumer, Short> value : this.shortValues) {
|
||||
final short supplied = (short) value.getLeft().getAsInt();
|
||||
|
||||
listener.sendWindowProperty(this, i, supplied);
|
||||
value.setRight(supplied);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!this.integerValues.isEmpty())
|
||||
for (final MutableTriple<IntSupplier, IntConsumer, Integer> value : this.integerValues) {
|
||||
final int supplied = value.getLeft().getAsInt();
|
||||
|
||||
listener.sendWindowProperty(this, i, supplied >> 16);
|
||||
listener.sendWindowProperty(this, i + 1, (short) (supplied & 0xFFFF));
|
||||
value.setRight(supplied);
|
||||
i += 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(final int id, final int value) {
|
||||
|
||||
if (id < this.shortValues.size()) {
|
||||
this.shortValues.get(id).getMiddle().accept((short) value);
|
||||
this.shortValues.get(id).setRight((short) value);
|
||||
} else if (id - this.shortValues.size() < this.integerValues.size() * 2) {
|
||||
|
||||
if ((id - this.shortValues.size()) % 2 == 0)
|
||||
this.integerParts[(id - this.shortValues.size()) / 2] = value;
|
||||
else {
|
||||
this.integerValues.get((id - this.shortValues.size()) / 2).getMiddle().accept(
|
||||
(this.integerParts[(id - this.shortValues.size()) / 2] & 0xFFFF) << 16 | value & 0xFFFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer player, final int index) {
|
||||
|
||||
ItemStack originalStack = ItemStack.EMPTY;
|
||||
|
||||
final Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
|
||||
final ItemStack stackInSlot = slot.getStack();
|
||||
originalStack = stackInSlot.copy();
|
||||
|
||||
boolean shifted = false;
|
||||
|
||||
for (final Range<Integer> range : this.playerSlotRanges)
|
||||
if (range.contains(index)) {
|
||||
|
||||
if (this.shiftToTile(stackInSlot))
|
||||
shifted = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!shifted)
|
||||
for (final Range<Integer> range : this.tileSlotRanges)
|
||||
if (range.contains(index)) {
|
||||
if (this.shiftToPlayer(stackInSlot))
|
||||
shifted = true;
|
||||
break;
|
||||
}
|
||||
|
||||
slot.onSlotChange(stackInSlot, originalStack);
|
||||
if (stackInSlot.getCount() <= 0)
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
else
|
||||
slot.onSlotChanged();
|
||||
if (stackInSlot.getCount() == originalStack.getCount())
|
||||
return ItemStack.EMPTY;
|
||||
slot.onTake(player, stackInSlot);
|
||||
}
|
||||
return originalStack;
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected boolean shiftItemStack(final ItemStack stackToShift, final int start, final int end) {
|
||||
boolean changed = false;
|
||||
if (stackToShift.isStackable()) {
|
||||
for (int slotIndex = start; stackToShift.getCount() > 0 && slotIndex < end; slotIndex++) {
|
||||
final Slot slot = this.inventorySlots.get(slotIndex);
|
||||
final ItemStack stackInSlot = slot.getStack();
|
||||
if (!stackInSlot.isEmpty() && ItemUtils.isItemEqual(stackInSlot, stackToShift, true, true)
|
||||
&& slot.isItemValid(stackToShift)) {
|
||||
final int resultingStackSize = stackInSlot.getCount() + stackToShift.getCount();
|
||||
final int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
if (resultingStackSize <= max) {
|
||||
stackToShift.setCount(0);
|
||||
stackInSlot.setCount(resultingStackSize);
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
} else if (stackInSlot.getCount() < max) {
|
||||
stackToShift.shrink(max - stackInSlot.getCount());
|
||||
stackInSlot.setCount(max);
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stackToShift.getCount() > 0) {
|
||||
for (int slotIndex = start; stackToShift.getCount() > 0 && slotIndex < end; slotIndex++) {
|
||||
final Slot slot = this.inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot.isEmpty() && slot.isItemValid(stackToShift)) {
|
||||
final int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
stackInSlot = stackToShift.copy();
|
||||
stackInSlot.setCount(Math.min(stackToShift.getCount(), max));
|
||||
stackToShift.shrink(stackInSlot.getCount());
|
||||
slot.putStack(stackInSlot);
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean shiftToTile(final ItemStack stackToShift) {
|
||||
for (final Range<Integer> range : this.tileSlotRanges)
|
||||
if (this.shiftItemStack(stackToShift, range.getMinimum(), range.getMaximum() + 1))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean shiftToPlayer(final ItemStack stackToShift) {
|
||||
for (final Range<Integer> range : this.playerSlotRanges)
|
||||
if (this.shiftItemStack(stackToShift, range.getMinimum(), range.getMaximum() + 1))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container.builder;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ContainerBuilder {
|
||||
|
||||
private final String name;
|
||||
|
||||
private Predicate<EntityPlayer> canInteract = player -> true;
|
||||
|
||||
final List<Slot> slots;
|
||||
final List<Range<Integer>> playerInventoryRanges, tileInventoryRanges;
|
||||
|
||||
final List<Pair<IntSupplier, IntConsumer>> shortValues;
|
||||
final List<Pair<IntSupplier, IntConsumer>> integerValues;
|
||||
|
||||
final List<Consumer<InventoryCrafting>> craftEvents;
|
||||
|
||||
public ContainerBuilder(final String name) {
|
||||
|
||||
this.name = name;
|
||||
|
||||
this.slots = new ArrayList<>();
|
||||
this.playerInventoryRanges = new ArrayList<>();
|
||||
this.tileInventoryRanges = new ArrayList<>();
|
||||
|
||||
this.shortValues = new ArrayList<>();
|
||||
this.integerValues = new ArrayList<>();
|
||||
|
||||
this.craftEvents = new ArrayList<>();
|
||||
}
|
||||
|
||||
public ContainerBuilder interact(final Predicate<EntityPlayer> canInteract) {
|
||||
this.canInteract = canInteract;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerPlayerInventoryBuilder player(final InventoryPlayer player) {
|
||||
return new ContainerPlayerInventoryBuilder(this, player);
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder tile(final IInventory tile) {
|
||||
return new ContainerTileInventoryBuilder(this, tile);
|
||||
}
|
||||
|
||||
void addPlayerInventoryRange(final Range<Integer> range) {
|
||||
this.playerInventoryRanges.add(range);
|
||||
}
|
||||
|
||||
void addTileInventoryRange(final Range<Integer> range) {
|
||||
this.tileInventoryRanges.add(range);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* The container have to know if the tile is still available (the block was not destroyed)
|
||||
* and if the player is not to far from him to close the GUI if necessary
|
||||
*/
|
||||
public BuiltContainer create() {
|
||||
final BuiltContainer built = new BuiltContainer(this.name, this.canInteract,
|
||||
this.playerInventoryRanges,
|
||||
this.tileInventoryRanges, null);
|
||||
if (!this.shortValues.isEmpty())
|
||||
built.addShortSync(this.shortValues);
|
||||
if (!this.integerValues.isEmpty())
|
||||
built.addIntegerSync(this.integerValues);
|
||||
if (!this.craftEvents.isEmpty())
|
||||
built.addCraftEvents(this.craftEvents);
|
||||
|
||||
this.slots.forEach(built::addSlot);
|
||||
|
||||
this.slots.clear();
|
||||
return built;
|
||||
}
|
||||
|
||||
public BuiltContainer create(final TileLegacyMachineBase tile) {
|
||||
final BuiltContainer built = new BuiltContainer(this.name, this.canInteract,
|
||||
this.playerInventoryRanges,
|
||||
this.tileInventoryRanges, tile);
|
||||
if (!this.shortValues.isEmpty())
|
||||
built.addShortSync(this.shortValues);
|
||||
if (!this.integerValues.isEmpty())
|
||||
built.addIntegerSync(this.integerValues);
|
||||
if (!this.craftEvents.isEmpty())
|
||||
built.addCraftEvents(this.craftEvents);
|
||||
|
||||
this.slots.forEach(built::addSlot);
|
||||
|
||||
this.slots.clear();
|
||||
return built;
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container.builder;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import org.apache.commons.lang3.Range;
|
||||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import techreborn.client.IconSupplier;
|
||||
import techreborn.client.container.builder.slot.SpriteSlot;
|
||||
|
||||
public final class ContainerPlayerInventoryBuilder {
|
||||
|
||||
private final InventoryPlayer player;
|
||||
private final ContainerBuilder parent;
|
||||
private Range<Integer> main;
|
||||
private Range<Integer> hotbar;
|
||||
private Range<Integer> armor;
|
||||
|
||||
ContainerPlayerInventoryBuilder(final ContainerBuilder parent, final InventoryPlayer player) {
|
||||
this.player = player;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public ContainerPlayerInventoryBuilder inventory(final int xStart, final int yStart) {
|
||||
final int startIndex = this.parent.slots.size();
|
||||
for (int i = 0; i < 3; ++i)
|
||||
for (int j = 0; j < 9; ++j)
|
||||
this.parent.slots.add(new BaseSlot(this.player, j + i * 9 + 9, xStart + j * 18, yStart + i * 18));
|
||||
this.main = Range.between(startIndex, this.parent.slots.size() - 1);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerPlayerInventoryBuilder hotbar(final int xStart, final int yStart) {
|
||||
final int startIndex = this.parent.slots.size();
|
||||
for (int i = 0; i < 9; ++i)
|
||||
this.parent.slots.add(new BaseSlot(this.player, i, xStart + i * 18, yStart));
|
||||
this.hotbar = Range.between(startIndex, this.parent.slots.size() - 1);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerPlayerInventoryBuilder inventory() {
|
||||
return this.inventory(8, 94);
|
||||
}
|
||||
|
||||
public ContainerPlayerInventoryBuilder hotbar() {
|
||||
return this.hotbar(8, 152);
|
||||
}
|
||||
|
||||
public ContainerPlayerArmorInventoryBuilder armor() {
|
||||
return new ContainerPlayerArmorInventoryBuilder(this);
|
||||
}
|
||||
|
||||
public ContainerBuilder addInventory() {
|
||||
if (this.hotbar != null)
|
||||
this.parent.addPlayerInventoryRange(this.hotbar);
|
||||
if (this.main != null)
|
||||
this.parent.addPlayerInventoryRange(this.main);
|
||||
if (this.armor != null)
|
||||
this.parent.addTileInventoryRange(this.armor);
|
||||
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public static final class ContainerPlayerArmorInventoryBuilder {
|
||||
private final ContainerPlayerInventoryBuilder parent;
|
||||
private final int startIndex;
|
||||
|
||||
public ContainerPlayerArmorInventoryBuilder(final ContainerPlayerInventoryBuilder parent) {
|
||||
this.parent = parent;
|
||||
this.startIndex = parent.parent.slots.size();
|
||||
}
|
||||
|
||||
private ContainerPlayerArmorInventoryBuilder armor(final int index, final int xStart, final int yStart,
|
||||
final EntityEquipmentSlot slotType, final String sprite) {
|
||||
this.parent.parent.slots.add(new SpriteSlot(this.parent.player, index, xStart, yStart, sprite, 1)
|
||||
.setFilter(stack -> stack.getItem().isValidArmor(stack, slotType, this.parent.player.player)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerPlayerArmorInventoryBuilder helmet(final int xStart, final int yStart) {
|
||||
return this.armor(this.parent.player.getSizeInventory() - 2, xStart, yStart, EntityEquipmentSlot.HEAD, IconSupplier.armour_head_name);
|
||||
}
|
||||
|
||||
public ContainerPlayerArmorInventoryBuilder chestplate(final int xStart, final int yStart) {
|
||||
return this.armor(this.parent.player.getSizeInventory() - 3, xStart, yStart, EntityEquipmentSlot.CHEST, IconSupplier.armour_chest_name);
|
||||
}
|
||||
|
||||
public ContainerPlayerArmorInventoryBuilder leggings(final int xStart, final int yStart) {
|
||||
return this.armor(this.parent.player.getSizeInventory() - 4, xStart, yStart, EntityEquipmentSlot.LEGS, IconSupplier.armour_legs_name);
|
||||
}
|
||||
|
||||
public ContainerPlayerArmorInventoryBuilder boots(final int xStart, final int yStart) {
|
||||
return this.armor(this.parent.player.getSizeInventory() - 5, xStart, yStart, EntityEquipmentSlot.FEET, IconSupplier.armour_feet_name);
|
||||
}
|
||||
|
||||
public ContainerPlayerArmorInventoryBuilder complete(final int xStart, final int yStart) {
|
||||
return this.helmet(xStart, yStart).chestplate(xStart, yStart + 18).leggings(xStart, yStart + 18 + 18)
|
||||
.boots(xStart, yStart + 18 + 18 + 18);
|
||||
}
|
||||
|
||||
public ContainerPlayerInventoryBuilder addArmor() {
|
||||
this.parent.armor = Range.between(this.startIndex, this.parent.parent.slots.size() - 1);
|
||||
return this.parent;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,181 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container.builder;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.SlotFurnaceFuel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IUpgrade;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import reborncore.client.gui.slots.SlotFake;
|
||||
import reborncore.client.gui.slots.SlotOutput;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.container.builder.slot.FilteredSlot;
|
||||
import techreborn.client.container.builder.slot.UpgradeSlot;
|
||||
import techreborn.compat.CompatManager;
|
||||
import techreborn.utils.IC2ItemCharger;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ContainerTileInventoryBuilder {
|
||||
|
||||
private final IInventory tile;
|
||||
private final ContainerBuilder parent;
|
||||
private final int rangeStart;
|
||||
|
||||
ContainerTileInventoryBuilder(final ContainerBuilder parent, final IInventory tile) {
|
||||
this.tile = tile;
|
||||
this.parent = parent;
|
||||
this.rangeStart = parent.slots.size();
|
||||
if (tile instanceof IUpgradeable) {
|
||||
upgradeSlots((IUpgradeable) tile);
|
||||
}
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder slot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new BaseSlot(this.tile, index, x, y));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder outputSlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new SlotOutput(this.tile, index, x, y));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder fakeSlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new SlotFake(this.tile, index, x, y, false, false, Integer.MAX_VALUE));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder filterSlot(final int index, final int x, final int y,
|
||||
final Predicate<ItemStack> filter) {
|
||||
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y).setFilter(filter));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder energySlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y)
|
||||
.setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)
|
||||
|| (CompatManager.isIC2Loaded && IC2ItemCharger.isIC2PoweredItem(stack))));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder fluidSlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y).setFilter(
|
||||
stack -> stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.UP)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder fuelSlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new SlotFurnaceFuel(this.tile, index, x, y));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ContainerTileInventoryBuilder upgradeSlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y)
|
||||
.setFilter(stack -> stack.getItem() instanceof IUpgrade));
|
||||
return this;
|
||||
}
|
||||
|
||||
private ContainerTileInventoryBuilder upgradeSlots(IUpgradeable upgradeable) {
|
||||
if (upgradeable.canBeUpgraded()) {
|
||||
for (int i = 0; i < upgradeable.getUpgradeSlotCount(); i++) {
|
||||
this.parent.slots.add(new UpgradeSlot(upgradeable.getUpgradeInvetory(), i, -19, i * 18 + 12));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param supplier The supplier must supply a variable holding inside a Short, it
|
||||
* will be truncated by force.
|
||||
* @param setter The setter to call when the variable has been updated.
|
||||
* @return ContainerTileInventoryBuilder Inventory which will do the sync
|
||||
*/
|
||||
public ContainerTileInventoryBuilder syncShortValue(final IntSupplier supplier, final IntConsumer setter) {
|
||||
this.parent.shortValues.add(Pair.of(supplier, setter));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param supplier The supplier it can supply a variable holding in an Integer it
|
||||
* will be split inside multiples shorts.
|
||||
* @param setter The setter to call when the variable has been updated.
|
||||
* @return ContainerTileInventoryBuilder Inventory which will do the sync
|
||||
*/
|
||||
public ContainerTileInventoryBuilder syncIntegerValue(final IntSupplier supplier, final IntConsumer setter) {
|
||||
this.parent.integerValues.add(Pair.of(supplier, setter));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder syncEnergyValue() {
|
||||
if (this.tile instanceof TilePowerAcceptor)
|
||||
return this.syncIntegerValue(() -> (int) ((TilePowerAcceptor) this.tile).getEnergy(),
|
||||
((TilePowerAcceptor) this.tile)::setEnergy)
|
||||
.syncIntegerValue(() -> (int) ((TilePowerAcceptor) this.tile).extraPowerStoage,
|
||||
((TilePowerAcceptor) this.tile)::setExtraPowerStoage)
|
||||
.syncIntegerValue(() -> (int) ((TilePowerAcceptor) this.tile).getPowerChange(),
|
||||
((TilePowerAcceptor) this.tile)::setPowerChange);
|
||||
Core.logHelper.error(this.tile + " is not an instance of TilePowerAcceptor! Energy cannot be synced.");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder syncCrafterValue() {
|
||||
if (this.tile instanceof IRecipeCrafterProvider)
|
||||
return this
|
||||
.syncIntegerValue(() -> ((IRecipeCrafterProvider) this.tile).getRecipeCrafter().currentTickTime,
|
||||
(currentTickTime) -> ((IRecipeCrafterProvider) this.tile)
|
||||
.getRecipeCrafter().currentTickTime = currentTickTime)
|
||||
.syncIntegerValue(() -> ((IRecipeCrafterProvider) this.tile).getRecipeCrafter().currentNeededTicks,
|
||||
(currentNeededTicks) -> ((IRecipeCrafterProvider) this.tile)
|
||||
.getRecipeCrafter().currentNeededTicks = currentNeededTicks);
|
||||
Core.logHelper
|
||||
.error(this.tile + " is not an instance of IRecipeCrafterProvider! Craft progress cannot be synced.");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder onCraft(final Consumer<InventoryCrafting> onCraft) {
|
||||
this.parent.craftEvents.add(onCraft);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerBuilder addInventory() {
|
||||
this.parent.tileInventoryRanges.add(Range.between(this.rangeStart, this.parent.slots.size() - 1));
|
||||
return this.parent;
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container.builder.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class FilteredSlot extends Slot {
|
||||
|
||||
private Predicate<ItemStack> filter;
|
||||
private int stackLimit = 64;
|
||||
|
||||
public FilteredSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition) {
|
||||
super(inventory, index, xPosition, yPosition);
|
||||
}
|
||||
|
||||
public FilteredSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, int stackLimit) {
|
||||
super(inventory, index, xPosition, yPosition);
|
||||
this.stackLimit = stackLimit;
|
||||
}
|
||||
|
||||
public FilteredSlot setFilter(final Predicate<ItemStack> filter) {
|
||||
this.filter = filter;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack stack) {
|
||||
try {
|
||||
return this.filter.test(stack);
|
||||
} catch (NullPointerException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return stackLimit;
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container.builder.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SpriteSlot extends FilteredSlot {
|
||||
|
||||
private final String spriteName;
|
||||
int stacksize;
|
||||
|
||||
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final String sprite, final int stacksize) {
|
||||
super(inventory, index, xPosition, yPosition);
|
||||
this.spriteName = sprite;
|
||||
this.stacksize = stacksize;
|
||||
}
|
||||
|
||||
public SpriteSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition, final String sprite) {
|
||||
this(inventory, index, xPosition, yPosition, sprite, 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return this.stacksize;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getSlotTexture() {
|
||||
return this.spriteName;
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container.builder.slot;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import reborncore.api.tile.IUpgrade;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IRightClickHandler;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
|
||||
public class UpgradeSlot extends Slot implements IRightClickHandler {
|
||||
|
||||
public UpgradeSlot(final IInventory inventory, final int index, final int xPosition, final int yPosition) {
|
||||
super(inventory, index, xPosition, yPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack stack) {
|
||||
return stack.getItem() instanceof IUpgrade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRightClick(int slotID, EntityPlayer player, BuiltContainer container) {
|
||||
if (inventory instanceof Inventory) {
|
||||
Inventory inv = (Inventory) inventory;
|
||||
TileEntity tileEntity = inv.getTileBase();
|
||||
if (tileEntity instanceof IUpgradeable) {
|
||||
IUpgradeable upgradeable = (IUpgradeable) tileEntity;
|
||||
if (upgradeable.canBeUpgraded()) {
|
||||
ItemStack stack = upgradeable.getUpgradeInvetory().getStackInSlot(slotID);
|
||||
if (!stack.isEmpty() && stack.getItem() instanceof IUpgrade) {
|
||||
if (player.world.isRemote) {
|
||||
((IUpgrade) stack.getItem()).handleRightClick(tileEntity, stack, container, slotID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import org.lwjgl.input.Keyboard;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import techreborn.client.gui.slot.GuiFluidConfiguration;
|
||||
import techreborn.client.gui.slot.GuiSlotConfiguration;
|
||||
import techreborn.client.gui.widget.GuiButtonPowerBar;
|
||||
|
|
|
@ -37,7 +37,7 @@ import reborncore.client.gui.GuiUtil;
|
|||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.network.packet.PacketConfigSave;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.slot.elements.ConfigSlotElement;
|
||||
import techreborn.client.gui.slot.elements.ElementBase;
|
||||
|
|
|
@ -26,7 +26,7 @@ package techreborn.compat.jei;
|
|||
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferInfo;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -43,7 +43,7 @@ import reborncore.client.hud.StackInfoHUD;
|
|||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import techreborn.blocks.BlockRubberLeaves;
|
||||
import techreborn.client.ClientEventHandler;
|
||||
import techreborn.client.IconSupplier;
|
||||
import reborncore.client.IconSupplier;
|
||||
import techreborn.client.RegisterItemJsons;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.slot.GuiFluidConfiguration;
|
||||
|
@ -70,7 +70,6 @@ public class ClientProxy extends CommonProxy {
|
|||
RenderingRegistry.registerEntityRenderingHandler(EntityNukePrimed.class, new RenderManagerNuke());
|
||||
ModelDynamicCell.init();
|
||||
RegisterItemJsons.registerModels();
|
||||
MinecraftForge.EVENT_BUS.register(new IconSupplier());
|
||||
MinecraftForge.EVENT_BUS.register(new FluidBlockModelHandler());
|
||||
MinecraftForge.EVENT_BUS.register(ClientEventHandler.class);
|
||||
}
|
||||
|
|
|
@ -35,14 +35,14 @@ import reborncore.common.RebornCoreConfig;
|
|||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.IC2ItemCharger;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.compat.CompatManager;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.utils.IC2ItemCharger;
|
||||
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
public class TileChargeOMat extends TilePowerAcceptor
|
||||
|
|
|
@ -33,9 +33,9 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ package techreborn.tiles;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
|
|
|
@ -32,9 +32,9 @@ import reborncore.common.registration.impl.ConfigRegistry;
|
|||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.items.DynamicCell;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
|
|
@ -34,9 +34,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.IC2Duplicates;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
|
|
|
@ -27,9 +27,9 @@ package techreborn.tiles;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
|
|
|
@ -38,9 +38,9 @@ import reborncore.common.tile.TileLegacyMachineBase;
|
|||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@ import reborncore.common.util.ItemUtils;
|
|||
import reborncore.common.util.Torus;
|
||||
import techreborn.api.reactor.FusionReactorRecipe;
|
||||
import techreborn.api.reactor.FusionReactorRecipeHelper;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.storage.TileEnergyStorage;
|
||||
|
|
|
@ -34,9 +34,9 @@ import reborncore.common.RebornCoreConfig;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.blocks.storage.BlockLapotronicSU;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.storage.TileEnergyStorage;
|
||||
|
|
|
@ -32,9 +32,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -35,9 +35,9 @@ import reborncore.common.util.FluidUtils;
|
|||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.api.fluidreplicator.FluidReplicatorRecipeCrafter;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
|
|
@ -31,9 +31,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -40,9 +40,9 @@ import techreborn.api.Reference;
|
|||
import techreborn.api.recipe.ITileRecipeHandler;
|
||||
import techreborn.api.recipe.machines.BlastFurnaceRecipe;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.multiblocks.MultiBlockCasing;
|
||||
|
|
|
@ -44,9 +44,9 @@ import reborncore.common.util.Tank;
|
|||
import techreborn.api.Reference;
|
||||
import techreborn.api.recipe.ITileRecipeHandler;
|
||||
import techreborn.api.recipe.machines.IndustrialGrinderRecipe;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -44,9 +44,9 @@ import reborncore.common.util.Tank;
|
|||
import techreborn.api.Reference;
|
||||
import techreborn.api.recipe.ITileRecipeHandler;
|
||||
import techreborn.api.recipe.machines.IndustrialSawmillRecipe;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -30,9 +30,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -31,9 +31,9 @@ import reborncore.api.power.EnumPowerTier;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -35,10 +35,10 @@ import reborncore.api.power.EnumPowerTier;
|
|||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.IC2ItemCharger;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.blocks.storage.BlockEnergyStorage;
|
||||
import techreborn.compat.CompatManager;
|
||||
import techreborn.utils.IC2ItemCharger;
|
||||
|
||||
/**
|
||||
* Created by Rushmead
|
||||
|
|
|
@ -26,9 +26,9 @@ package techreborn.tiles.storage;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,9 +26,9 @@ package techreborn.tiles.storage;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,9 +26,9 @@ package techreborn.tiles.storage;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,9 +42,9 @@ import reborncore.common.util.Inventory;
|
|||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.api.recipe.machines.AlloySmelterRecipe;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ import reborncore.common.blocks.BlockMachineBase;
|
|||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
|
||||
public class TileIronFurnace extends TileLegacyMachineBase
|
||||
implements IInventoryProvider, IContainerProvider {
|
||||
|
|
|
@ -33,9 +33,9 @@ import reborncore.common.util.Inventory;
|
|||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.api.recipe.machines.AlloySmelterRecipe;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -30,9 +30,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -43,9 +43,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModSounds;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
|
|
@ -30,9 +30,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -30,9 +30,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -36,9 +36,9 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -30,9 +30,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileGenericMachine;
|
||||
|
|
|
@ -31,9 +31,9 @@ import reborncore.common.registration.impl.ConfigRegistry;
|
|||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.items.DynamicCell;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
|
|
@ -35,9 +35,9 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
|
|||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.items.ingredients.ItemParts;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
|
|
@ -41,9 +41,9 @@ import reborncore.common.registration.impl.ConfigRegistry;
|
|||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.api.RollingMachineRecipe;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ import reborncore.common.registration.RebornRegistry;
|
|||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.recipe.ScrapboxRecipeCrafter;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.utils;
|
||||
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IElectricItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
|
||||
public class IC2ItemCharger {
|
||||
|
||||
public static void chargeIc2Item(TilePowerAcceptor tilePowerAcceptor, ItemStack stack){
|
||||
if(stack.isEmpty()){
|
||||
return;
|
||||
}
|
||||
if(stack.getItem() instanceof IElectricItem){
|
||||
tilePowerAcceptor.useEnergy(ElectricItem.manager.charge(stack, tilePowerAcceptor.getEnergy(), 4, false, false));
|
||||
}
|
||||
}
|
||||
|
||||
public static void dischargeIc2Item(TilePowerAcceptor tilePowerAcceptor, ItemStack stack){
|
||||
if(stack.isEmpty()){
|
||||
return;
|
||||
}
|
||||
if(stack.getItem() instanceof IElectricItem){
|
||||
tilePowerAcceptor.addEnergy(ElectricItem.manager.discharge(stack, tilePowerAcceptor.getFreeSpace(), 4, false, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isIC2PoweredItem(ItemStack stack){
|
||||
if(stack.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
return stack.getItem() instanceof IElectricItem;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue