More SonarQube fixes.
This commit is contained in:
@@ -230,8 +230,8 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE.apply(cause));
|
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE_ACTION.apply(cause));
|
||||||
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE.apply(cause));
|
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE_ACTION.apply(cause));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -26,7 +26,7 @@ import java.util.UUID;
|
|||||||
public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||||
private static final String NBT_OWNER = "Owner";
|
private static final String NBT_OWNER = "Owner";
|
||||||
private static final String NBT_VERSION = "Version";
|
private static final String NBT_VERSION = "Version";
|
||||||
private static final int VERSION = 1;
|
private static final int CURRENT_VERSION = 1;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected INetwork network;
|
protected INetwork network;
|
||||||
@@ -179,7 +179,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
|||||||
tag.putUniqueId(NBT_OWNER, owner);
|
tag.putUniqueId(NBT_OWNER, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.putInt(NBT_VERSION, VERSION);
|
tag.putInt(NBT_VERSION, CURRENT_VERSION);
|
||||||
|
|
||||||
writeConfiguration(tag);
|
writeConfiguration(tag);
|
||||||
|
|
||||||
|
@@ -150,8 +150,8 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
|||||||
|
|
||||||
LOGGER.debug("Connectivity state of disk drive at {} changed to {} due to {}", pos, state, cause);
|
LOGGER.debug("Connectivity state of disk drive at {} changed to {} due to {}", pos, state, cause);
|
||||||
|
|
||||||
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE_ACTION.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||||
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE_ACTION.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||||
|
|
||||||
WorldUtils.updateBlock(world, pos);
|
WorldUtils.updateBlock(world, pos);
|
||||||
}
|
}
|
||||||
|
@@ -98,7 +98,7 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
|||||||
|
|
||||||
LOGGER.debug("Connectivity state of fluid storage block at {} changed to {} due to {}", pos, state, cause);
|
LOGGER.debug("Connectivity state of fluid storage block at {} changed to {} due to {}", pos, state, cause);
|
||||||
|
|
||||||
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE_ACTION.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,7 +144,9 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
|||||||
IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) world).get(storageId);
|
IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) world).get(storageId);
|
||||||
|
|
||||||
if (disk == null) {
|
if (disk == null) {
|
||||||
API.instance().getStorageDiskManager((ServerWorld) world).set(storageId, disk = API.instance().createDefaultFluidDisk((ServerWorld) world, type.getCapacity(), owner));
|
disk = API.instance().createDefaultFluidDisk((ServerWorld) world, type.getCapacity(), owner);
|
||||||
|
|
||||||
|
API.instance().getStorageDiskManager((ServerWorld) world).set(storageId, disk);
|
||||||
API.instance().getStorageDiskManager((ServerWorld) world).markForSaving();
|
API.instance().getStorageDiskManager((ServerWorld) world).markForSaving();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -98,7 +98,7 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
|||||||
|
|
||||||
LOGGER.debug("Connectivity state of item storage block at {} changed to {} due to {}", pos, state, cause);
|
LOGGER.debug("Connectivity state of item storage block at {} changed to {} due to {}", pos, state, cause);
|
||||||
|
|
||||||
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE_ACTION.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,7 +144,9 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
|||||||
IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) world).get(storageId);
|
IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) world).get(storageId);
|
||||||
|
|
||||||
if (disk == null) {
|
if (disk == null) {
|
||||||
API.instance().getStorageDiskManager((ServerWorld) world).set(storageId, disk = API.instance().createDefaultItemDisk((ServerWorld) world, type.getCapacity(), owner));
|
disk = API.instance().createDefaultItemDisk((ServerWorld) world, type.getCapacity(), owner);
|
||||||
|
|
||||||
|
API.instance().getStorageDiskManager((ServerWorld) world).set(storageId, disk);
|
||||||
API.instance().getStorageDiskManager((ServerWorld) world).markForSaving();
|
API.instance().getStorageDiskManager((ServerWorld) world).markForSaving();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class FluidStorageCache implements IStorageCache<FluidStack> {
|
public class FluidStorageCache implements IStorageCache<FluidStack> {
|
||||||
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE = cause -> network -> network.getFluidStorageCache().invalidate(cause);
|
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE_ACTION = cause -> network -> network.getFluidStorageCache().invalidate(cause);
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(FluidStorageCache.class);
|
private static final Logger LOGGER = LogManager.getLogger(FluidStorageCache.class);
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class ItemStorageCache implements IStorageCache<ItemStack> {
|
public class ItemStorageCache implements IStorageCache<ItemStack> {
|
||||||
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE = cause -> network -> network.getItemStorageCache().invalidate(cause);
|
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE_ACTION = cause -> network -> network.getItemStorageCache().invalidate(cause);
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(ItemStorageCache.class);
|
private static final Logger LOGGER = LogManager.getLogger(ItemStorageCache.class);
|
||||||
|
|
||||||
|
@@ -87,7 +87,7 @@ public class PortableFluidStorageCache implements IStorageCache<FluidStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStackList<FluidStack> getCraftablesList() {
|
public IStackList<FluidStack> getCraftablesList() {
|
||||||
throw new RuntimeException("Unsupported");
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -55,7 +55,7 @@ public class PortableItemStorageCache implements IStorageCache<ItemStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
throw new UnsupportedOperationException("Cannot flush portable grid storage cache");
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -87,7 +87,7 @@ public class PortableItemStorageCache implements IStorageCache<ItemStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStackList<ItemStack> getCraftablesList() {
|
public IStackList<ItemStack> getCraftablesList() {
|
||||||
throw new RuntimeException("Unsupported");
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -33,7 +33,7 @@ public enum BlockDirection {
|
|||||||
case HORIZONTAL:
|
case HORIZONTAL:
|
||||||
return entity.getHorizontalFacing().getOpposite();
|
return entity.getHorizontalFacing().getOpposite();
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unknown direction type");
|
throw new IllegalStateException("Unknown direction type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public enum BlockDirection {
|
|||||||
case HORIZONTAL:
|
case HORIZONTAL:
|
||||||
return previous.rotateYCCW();
|
return previous.rotateYCCW();
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unknown direction type");
|
throw new IllegalStateException("Unknown direction type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,6 +51,14 @@ public class ListNetworkCommand implements Command<CommandSource> {
|
|||||||
this.tickTime = mean(network.getTickTimes()) * 1.0E-6D;
|
this.tickTime = mean(network.getTickTimes()) * 1.0E-6D;
|
||||||
this.tps = Math.min(1000.0 / tickTime, 20);
|
this.tps = Math.min(1000.0 / tickTime, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long mean(long[] values) {
|
||||||
|
long sum = 0L;
|
||||||
|
for (long v : values) {
|
||||||
|
sum += v;
|
||||||
|
}
|
||||||
|
return sum / values.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendInfo(CommandContext<CommandSource> context, NetworkInList listItem, boolean detailed) {
|
public static void sendInfo(CommandContext<CommandSource> context, NetworkInList listItem, boolean detailed) {
|
||||||
@@ -83,12 +91,4 @@ public class ListNetworkCommand implements Command<CommandSource> {
|
|||||||
), false);
|
), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long mean(long[] values) {
|
|
||||||
long sum = 0L;
|
|
||||||
for (long v : values) {
|
|
||||||
sum += v;
|
|
||||||
}
|
|
||||||
return sum / values.length;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -82,7 +82,7 @@ public class CrafterManagerContainer extends BaseContainer {
|
|||||||
if (data == null) { // We're only resizing, get the previous inventory...
|
if (data == null) { // We're only resizing, get the previous inventory...
|
||||||
dummy = dummyInventories.get(category.getKey());
|
dummy = dummyInventories.get(category.getKey());
|
||||||
} else {
|
} else {
|
||||||
dummyInventories.put(category.getKey(), dummy = new BaseItemHandler(category.getValue()) {
|
dummy = new BaseItemHandler(category.getValue()) {
|
||||||
@Override
|
@Override
|
||||||
public int getSlotLimit(int slot) {
|
public int getSlotLimit(int slot) {
|
||||||
return 1;
|
return 1;
|
||||||
@@ -97,7 +97,9 @@ public class CrafterManagerContainer extends BaseContainer {
|
|||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
dummyInventories.put(category.getKey(), dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean foundItemsInCategory = false;
|
boolean foundItemsInCategory = false;
|
||||||
|
@@ -157,7 +157,8 @@ public class GridContainer extends BaseContainer implements ICraftingGridListene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addSlot(craftingResultSlot = new ResultCraftingGridSlot(getPlayer(), grid, 0, 130 + 4, headerAndSlots + 22));
|
craftingResultSlot = new ResultCraftingGridSlot(getPlayer(), grid, 0, 130 + 4, headerAndSlots + 22);
|
||||||
|
addSlot(craftingResultSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPatternSlots() {
|
private void addPatternSlots() {
|
||||||
@@ -216,7 +217,8 @@ public class GridContainer extends BaseContainer implements ICraftingGridListene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addSlot(patternResultSlot = (new LegacyDisabledSlot(grid.getCraftingResult(), 0, 134, headerAndSlots + 22).setEnableHandler(() -> !((GridNetworkNode) grid).isProcessingPattern())));
|
patternResultSlot = new LegacyDisabledSlot(grid.getCraftingResult(), 0, 134, headerAndSlots + 22).setEnableHandler(() -> !((GridNetworkNode) grid).isProcessingPattern());
|
||||||
|
addSlot(patternResultSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IGrid getGrid() {
|
public IGrid getGrid() {
|
||||||
|
@@ -3,16 +3,16 @@ package com.refinedmods.refinedstorage.container.slot;
|
|||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
public class BaseSlot extends SlotItemHandler {
|
public class BaseSlot extends SlotItemHandler {
|
||||||
private Supplier<Boolean> enableHandler = () -> true;
|
private BooleanSupplier enableHandler = () -> true;
|
||||||
|
|
||||||
public BaseSlot(IItemHandler itemHandler, int inventoryIndex, int x, int y) {
|
public BaseSlot(IItemHandler itemHandler, int inventoryIndex, int x, int y) {
|
||||||
super(itemHandler, inventoryIndex, x, y);
|
super(itemHandler, inventoryIndex, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseSlot setEnableHandler(Supplier<Boolean> enableHandler) {
|
public BaseSlot setEnableHandler(BooleanSupplier enableHandler) {
|
||||||
this.enableHandler = enableHandler;
|
this.enableHandler = enableHandler;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -20,6 +20,6 @@ public class BaseSlot extends SlotItemHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enableHandler.get();
|
return enableHandler.getAsBoolean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,16 +3,16 @@ package com.refinedmods.refinedstorage.container.slot.legacy;
|
|||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
public class LegacyBaseSlot extends Slot {
|
public class LegacyBaseSlot extends Slot {
|
||||||
private Supplier<Boolean> enableHandler = () -> true;
|
private BooleanSupplier enableHandler = () -> true;
|
||||||
|
|
||||||
public LegacyBaseSlot(IInventory inventory, int inventoryIndex, int x, int y) {
|
public LegacyBaseSlot(IInventory inventory, int inventoryIndex, int x, int y) {
|
||||||
super(inventory, inventoryIndex, x, y);
|
super(inventory, inventoryIndex, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyBaseSlot setEnableHandler(Supplier<Boolean> enableHandler) {
|
public LegacyBaseSlot setEnableHandler(BooleanSupplier enableHandler) {
|
||||||
this.enableHandler = enableHandler;
|
this.enableHandler = enableHandler;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -20,7 +20,6 @@ public class LegacyBaseSlot extends Slot {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enableHandler.get();
|
return enableHandler.getAsBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -16,52 +16,48 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class RecipeGenerator extends RecipeProvider {
|
public class RecipeGenerator extends RecipeProvider {
|
||||||
|
private static final String GRID_ID = RS.ID + ":grid";
|
||||||
|
|
||||||
public RecipeGenerator(DataGenerator generator) {
|
public RecipeGenerator(DataGenerator generator) {
|
||||||
super(generator);
|
super(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRecipes(Consumer<IFinishedRecipe> consumer) {
|
protected void registerRecipes(Consumer<IFinishedRecipe> recipeAcceptor) {
|
||||||
//Tag + Color -> Colored Block
|
// Tag + Color -> Colored Block
|
||||||
RSItems.COLORED_ITEM_TAGS.forEach((tag, map) -> {
|
RSItems.COLORED_ITEM_TAGS.forEach((tag, map) -> map.forEach((color, item) -> ShapelessRecipeBuilder.shapelessRecipe(item.get())
|
||||||
map.forEach((color, item) -> {
|
.addIngredient(tag)
|
||||||
ShapelessRecipeBuilder.shapelessRecipe(item.get())
|
.addIngredient(color.getTag())
|
||||||
.addIngredient(tag)
|
.setGroup(RS.ID)
|
||||||
.addIngredient(color.getTag())
|
.addCriterion("refinedstorage:controller", InventoryChangeTrigger.Instance.forItems(RSItems.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get()))
|
||||||
.setGroup(RS.ID)
|
.build(recipeAcceptor, new ResourceLocation(RS.ID, "coloring_recipes/" + item.getId().getPath()))
|
||||||
.addCriterion("refinedstorage:controller", InventoryChangeTrigger.Instance.forItems(RSItems.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get()))
|
));
|
||||||
.build(consumer, new ResourceLocation(RS.ID, "coloring_recipes/" + item.getId().getPath()));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Crafting Grid
|
// Crafting Grid
|
||||||
RSItems.CRAFTING_GRID.forEach((color, item) -> {
|
RSItems.CRAFTING_GRID.forEach((color, item) -> ShapelessRecipeBuilder.shapelessRecipe(item.get())
|
||||||
ShapelessRecipeBuilder.shapelessRecipe(item.get())
|
.addIngredient(RSItems.GRID.get(color).get())
|
||||||
.addIngredient(RSItems.GRID.get(color).get())
|
.addIngredient(RSItems.PROCESSORS.get(ProcessorItem.Type.ADVANCED).get())
|
||||||
.addIngredient(RSItems.PROCESSORS.get(ProcessorItem.Type.ADVANCED).get())
|
.addIngredient(ItemTags.makeWrapperTag("refinedstorage:crafting_tables"))
|
||||||
.addIngredient(ItemTags.makeWrapperTag("refinedstorage:crafting_tables"))
|
.addCriterion(GRID_ID, InventoryChangeTrigger.Instance.forItems(RSItems.GRID.get(ColorMap.DEFAULT_COLOR).get()))
|
||||||
.addCriterion("refinedstorage:grid", InventoryChangeTrigger.Instance.forItems(RSItems.GRID.get(ColorMap.DEFAULT_COLOR).get()))
|
.build(recipeAcceptor, new ResourceLocation(RS.ID, "crafting_grid/" + item.getId().getPath()))
|
||||||
.build(consumer, new ResourceLocation(RS.ID, "crafting_grid/" + item.getId().getPath()));
|
);
|
||||||
});
|
|
||||||
|
|
||||||
//Fluid Grid
|
// Fluid Grid
|
||||||
RSItems.FLUID_GRID.forEach((color, item) -> {
|
RSItems.FLUID_GRID.forEach((color, item) -> ShapelessRecipeBuilder.shapelessRecipe(item.get())
|
||||||
ShapelessRecipeBuilder.shapelessRecipe(item.get())
|
.addIngredient(RSItems.GRID.get(color).get())
|
||||||
.addIngredient(RSItems.GRID.get(color).get())
|
.addIngredient(RSItems.PROCESSORS.get(ProcessorItem.Type.ADVANCED).get())
|
||||||
.addIngredient(RSItems.PROCESSORS.get(ProcessorItem.Type.ADVANCED).get())
|
.addIngredient(Items.BUCKET)
|
||||||
.addIngredient(Items.BUCKET)
|
.addCriterion(GRID_ID, InventoryChangeTrigger.Instance.forItems(RSItems.GRID.get(ColorMap.DEFAULT_COLOR).get()))
|
||||||
.addCriterion("refinedstorage:grid", InventoryChangeTrigger.Instance.forItems(RSItems.GRID.get(ColorMap.DEFAULT_COLOR).get()))
|
.build(recipeAcceptor, new ResourceLocation(RS.ID, "fluid_grid/" + item.getId().getPath()))
|
||||||
.build(consumer, new ResourceLocation(RS.ID, "fluid_grid/" + item.getId().getPath()));
|
);
|
||||||
});
|
|
||||||
|
|
||||||
//Pattern Grid
|
// Pattern Grid
|
||||||
RSItems.PATTERN_GRID.forEach((color, item) -> {
|
RSItems.PATTERN_GRID.forEach((color, item) -> ShapelessRecipeBuilder.shapelessRecipe(item.get())
|
||||||
ShapelessRecipeBuilder.shapelessRecipe(item.get())
|
.addIngredient(RSItems.GRID.get(color).get())
|
||||||
.addIngredient(RSItems.GRID.get(color).get())
|
.addIngredient(RSItems.PROCESSORS.get(ProcessorItem.Type.ADVANCED).get())
|
||||||
.addIngredient(RSItems.PROCESSORS.get(ProcessorItem.Type.ADVANCED).get())
|
.addIngredient(RSItems.PATTERN.get())
|
||||||
.addIngredient(RSItems.PATTERN.get())
|
.addCriterion(GRID_ID, InventoryChangeTrigger.Instance.forItems(RSItems.GRID.get(ColorMap.DEFAULT_COLOR).get()))
|
||||||
.addCriterion("refinedstorage:grid", InventoryChangeTrigger.Instance.forItems(RSItems.GRID.get(ColorMap.DEFAULT_COLOR).get()))
|
.build(recipeAcceptor, new ResourceLocation(RS.ID, "pattern_grid/" + item.getId().getPath()))
|
||||||
.build(consumer, new ResourceLocation(RS.ID, "pattern_grid/" + item.getId().getPath()));
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -104,6 +104,33 @@ public class DiskDriveBakedModel extends DelegateBakedModel {
|
|||||||
|
|
||||||
return quads;
|
return quads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IBakedModel getDiskModel(DiskState diskState) {
|
||||||
|
switch (diskState) {
|
||||||
|
case DISCONNECTED:
|
||||||
|
return diskDisconnected;
|
||||||
|
case NEAR_CAPACITY:
|
||||||
|
return diskNearCapacity;
|
||||||
|
case FULL:
|
||||||
|
return diskFull;
|
||||||
|
default:
|
||||||
|
return disk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector3f getDiskTranslation(Direction facing, int x, int y) {
|
||||||
|
Vector3f translation = new Vector3f();
|
||||||
|
|
||||||
|
if (facing == Direction.NORTH || facing == Direction.SOUTH) {
|
||||||
|
translation.add(((2F / 16F) + ((float) x * 7F) / 16F) * (facing == Direction.NORTH ? -1 : 1), 0, 0); // Add to X
|
||||||
|
} else if (facing == Direction.EAST || facing == Direction.WEST) {
|
||||||
|
translation.add(0, 0, ((2F / 16F) + ((float) x * 7F) / 16F) * (facing == Direction.EAST ? -1 : 1)); // Add to Z
|
||||||
|
}
|
||||||
|
|
||||||
|
translation.add(0, -((2F / 16F) + ((float) y * 3F) / 16F), 0); // Remove from Y
|
||||||
|
|
||||||
|
return translation;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public DiskDriveBakedModel(IBakedModel base,
|
public DiskDriveBakedModel(IBakedModel base,
|
||||||
@@ -119,33 +146,6 @@ public class DiskDriveBakedModel extends DelegateBakedModel {
|
|||||||
this.diskDisconnected = diskDisconnected;
|
this.diskDisconnected = diskDisconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBakedModel getDiskModel(DiskState diskState) {
|
|
||||||
switch (diskState) {
|
|
||||||
case DISCONNECTED:
|
|
||||||
return diskDisconnected;
|
|
||||||
case NEAR_CAPACITY:
|
|
||||||
return diskNearCapacity;
|
|
||||||
case FULL:
|
|
||||||
return diskFull;
|
|
||||||
default:
|
|
||||||
return disk;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Vector3f getDiskTranslation(Direction facing, int x, int y) {
|
|
||||||
Vector3f translation = new Vector3f();
|
|
||||||
|
|
||||||
if (facing == Direction.NORTH || facing == Direction.SOUTH) {
|
|
||||||
translation.add(((2F / 16F) + ((float) x * 7F) / 16F) * (facing == Direction.NORTH ? -1 : 1), 0, 0); // Add to X
|
|
||||||
} else if (facing == Direction.EAST || facing == Direction.WEST) {
|
|
||||||
translation.add(0, 0, ((2F / 16F) + ((float) x * 7F) / 16F) * (facing == Direction.EAST ? -1 : 1)); // Add to Z
|
|
||||||
}
|
|
||||||
|
|
||||||
translation.add(0, -((2F / 16F) + ((float) y * 3F) / 16F), 0); // Remove from Y
|
|
||||||
|
|
||||||
return translation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData data) {
|
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData data) {
|
||||||
|
@@ -116,6 +116,33 @@ public class DiskManipulatorBakedModel extends DelegateBakedModel {
|
|||||||
|
|
||||||
return quads;
|
return quads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IBakedModel getDiskModel(DiskState diskState) {
|
||||||
|
switch (diskState) {
|
||||||
|
case DISCONNECTED:
|
||||||
|
return diskDisconnected;
|
||||||
|
case NEAR_CAPACITY:
|
||||||
|
return diskNearCapacity;
|
||||||
|
case FULL:
|
||||||
|
return diskFull;
|
||||||
|
default:
|
||||||
|
return disk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector3f getDiskTranslation(Direction facing, int x, int y) {
|
||||||
|
Vector3f translation = new Vector3f();
|
||||||
|
|
||||||
|
if (facing == Direction.NORTH || facing == Direction.SOUTH) {
|
||||||
|
translation.add((2F / 16F + ((float) x * 7F) / 16F) * (facing == Direction.NORTH ? -1 : 1), 0, 0); // Add to X
|
||||||
|
} else if (facing == Direction.EAST || facing == Direction.WEST) {
|
||||||
|
translation.add(0, 0, (2F / 16F + ((float) x * 7F) / 16F) * (facing == Direction.EAST ? -1 : 1)); // Add to Z
|
||||||
|
}
|
||||||
|
|
||||||
|
translation.add(0, -((6F / 16F) + (3F * y) / 16F), 0); // Remove from Y
|
||||||
|
|
||||||
|
return translation;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public DiskManipulatorBakedModel(IBakedModel baseConnected, IBakedModel baseDisconnected, IBakedModel disk, IBakedModel diskNearCapacity, IBakedModel diskFull, IBakedModel diskDisconnected) {
|
public DiskManipulatorBakedModel(IBakedModel baseConnected, IBakedModel baseDisconnected, IBakedModel disk, IBakedModel diskNearCapacity, IBakedModel diskFull, IBakedModel diskDisconnected) {
|
||||||
@@ -129,33 +156,6 @@ public class DiskManipulatorBakedModel extends DelegateBakedModel {
|
|||||||
this.diskDisconnected = diskDisconnected;
|
this.diskDisconnected = diskDisconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBakedModel getDiskModel(DiskState diskState) {
|
|
||||||
switch (diskState) {
|
|
||||||
case DISCONNECTED:
|
|
||||||
return diskDisconnected;
|
|
||||||
case NEAR_CAPACITY:
|
|
||||||
return diskNearCapacity;
|
|
||||||
case FULL:
|
|
||||||
return diskFull;
|
|
||||||
default:
|
|
||||||
return disk;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Vector3f getDiskTranslation(Direction facing, int x, int y) {
|
|
||||||
Vector3f translation = new Vector3f();
|
|
||||||
|
|
||||||
if (facing == Direction.NORTH || facing == Direction.SOUTH) {
|
|
||||||
translation.add((2F / 16F + ((float) x * 7F) / 16F) * (facing == Direction.NORTH ? -1 : 1), 0, 0); // Add to X
|
|
||||||
} else if (facing == Direction.EAST || facing == Direction.WEST) {
|
|
||||||
translation.add(0, 0, (2F / 16F + ((float) x * 7F) / 16F) * (facing == Direction.EAST ? -1 : 1)); // Add to Z
|
|
||||||
}
|
|
||||||
|
|
||||||
translation.add(0, -((6F / 16F) + (3F * y) / 16F), 0); // Remove from Y
|
|
||||||
|
|
||||||
return translation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData data) {
|
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData data) {
|
||||||
|
@@ -12,16 +12,16 @@ import net.minecraftforge.fluids.FluidStack;
|
|||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.function.Function;
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
public class FluidAmountScreen extends AmountSpecifyingScreen<FluidAmountContainer> {
|
public class FluidAmountScreen extends AmountSpecifyingScreen<FluidAmountContainer> {
|
||||||
private final int containerSlot;
|
private final int containerSlot;
|
||||||
private final FluidStack stack;
|
private final FluidStack stack;
|
||||||
private final int maxAmount;
|
private final int maxAmount;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Function<Screen, Screen> alternativesScreenFactory;
|
private final UnaryOperator<Screen> alternativesScreenFactory;
|
||||||
|
|
||||||
public FluidAmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, FluidStack stack, int maxAmount, @Nullable Function<Screen, Screen> alternativesScreenFactory) {
|
public FluidAmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, FluidStack stack, int maxAmount, @Nullable UnaryOperator<Screen> alternativesScreenFactory) {
|
||||||
super(parent, new FluidAmountContainer(player, stack), alternativesScreenFactory != null ? 194 : 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.fluid_amount"));
|
super(parent, new FluidAmountContainer(player, stack), alternativesScreenFactory != null ? 194 : 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.fluid_amount"));
|
||||||
|
|
||||||
this.containerSlot = containerSlot;
|
this.containerSlot = containerSlot;
|
||||||
|
@@ -12,16 +12,16 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
|||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.function.Function;
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
public class ItemAmountScreen extends AmountSpecifyingScreen<AmountContainer> {
|
public class ItemAmountScreen extends AmountSpecifyingScreen<AmountContainer> {
|
||||||
private final int containerSlot;
|
private final int containerSlot;
|
||||||
private final ItemStack stack;
|
private final ItemStack stack;
|
||||||
private final int maxAmount;
|
private final int maxAmount;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Function<Screen, Screen> alternativesScreenFactory;
|
private final UnaryOperator<Screen> alternativesScreenFactory;
|
||||||
|
|
||||||
public ItemAmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, ItemStack stack, int maxAmount, @Nullable Function<Screen, Screen> alternativesScreenFactory) {
|
public ItemAmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, ItemStack stack, int maxAmount, @Nullable UnaryOperator<Screen> alternativesScreenFactory) {
|
||||||
super(parent, new AmountContainer(player, stack), alternativesScreenFactory != null ? 194 : 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.item_amount"));
|
super(parent, new AmountContainer(player, stack), alternativesScreenFactory != null ? 194 : 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.item_amount"));
|
||||||
|
|
||||||
this.containerSlot = containerSlot;
|
this.containerSlot = containerSlot;
|
||||||
|
@@ -62,7 +62,7 @@ public abstract class NetworkNodeTile<N extends NetworkNode> extends BaseTile im
|
|||||||
INetworkNode node = manager.getNode(pos);
|
INetworkNode node = manager.getNode(pos);
|
||||||
|
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
throw new RuntimeException("No network node present at " + pos.toString() + ", consider removing the block at this position");
|
throw new IllegalStateException("No network node present at " + pos.toString() + ", consider removing the block at this position");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (N) node;
|
return (N) node;
|
||||||
|
@@ -11,7 +11,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
public class TileDataManager {
|
public class TileDataManager {
|
||||||
private static int LAST_ID = 0;
|
private static int lastId = 0;
|
||||||
private static final Map<Integer, TileDataParameter> REGISTRY = new HashMap<>();
|
private static final Map<Integer, TileDataParameter> REGISTRY = new HashMap<>();
|
||||||
|
|
||||||
private final TileEntity tile;
|
private final TileEntity tile;
|
||||||
@@ -60,9 +60,9 @@ public class TileDataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void registerParameter(TileDataParameter parameter) {
|
public static void registerParameter(TileDataParameter parameter) {
|
||||||
parameter.setId(LAST_ID);
|
parameter.setId(lastId);
|
||||||
|
|
||||||
REGISTRY.put(LAST_ID++, parameter);
|
REGISTRY.put(lastId++, parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TileDataParameter getParameter(int id) {
|
public static TileDataParameter getParameter(int id) {
|
||||||
|
Reference in New Issue
Block a user