ProcessingBenchBlock class
Пакет: com.hypixel.hytale.builtin.crafting.component
Файл: com/hypixel/hytale/builtin/crafting/component/ProcessingBenchBlock.java
implements: Component<ChunkStore>
Поля (136)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
break |
|
|
break |
|
|
return |
|
|
return |
|
List |
var1 |
|
ProcessingBench.ProcessingSlot[] |
var1 |
|
ProcessingBenchBlock |
var1 |
|
int |
var10 |
|
ObjectArrayList |
var10 |
|
boolean |
var10 |
|
String |
var10 |
|
ListTransaction |
var10 |
|
float |
var10 |
|
Vector3d |
var10 |
|
|
var10 |
|
|
var10 |
|
|
var10 |
|
IntArrayList |
var10 |
|
ProcessingBench.ProcessingSlot[] |
var11 |
|
|
var11 |
|
int |
var11 |
|
ResourceQuantity |
var11 |
|
BlockBoundingBoxes |
var11 |
|
short |
var12 |
|
|
var12 |
|
float |
var12 |
|
ItemStack |
var12 |
|
ItemStack |
var12 |
|
double |
var12 |
|
float |
var13 |
|
double |
var13 |
|
Holder[] |
var13 |
|
ProcessingBench.ProcessingSlot |
var14 |
|
int |
var14 |
|
double |
var14 |
|
String |
var15 |
|
int |
var15 |
|
int |
var15 |
|
ResourceTransaction |
var15 |
|
float |
var15 |
|
String |
var15 |
|
boolean |
var16 |
|
int |
var16 |
|
int |
var16 |
|
|
var16 |
|
ProcessingBench.ExtraOutput |
var16 |
|
float |
var16 |
|
String |
var16 |
|
ObjectArrayList |
var17 |
|
int |
var17 |
|
float |
var17 |
|
ObjectArrayList |
var17 |
|
Holder |
var17 |
|
int |
var17 |
|
ListTransaction |
var18 |
|
List |
var18 |
|
ThreadLocalRandom |
var18 |
|
BsonDocument |
var18 |
|
ObjectArrayList |
var19 |
|
int |
var19 |
|
|
var19 |
|
ObjectArrayList |
var19 |
|
MaterialQuantity |
var19 |
|
Bench |
var2 |
|
float |
var2 |
|
String |
var2 |
|
BenchTierLevel |
var2 |
|
float |
var2 |
|
int |
var2 |
|
|
var2 |
|
float |
var2 |
|
Map |
var2 |
|
int |
var20 |
|
|
var20 |
|
List |
var21 |
|
int |
var21 |
|
int |
var21 |
|
int |
var22 |
|
int |
var22 |
|
short |
var23 |
|
int |
var23 |
|
|
var23 |
|
Store |
var24 |
|
float |
var24 |
|
|
var24 |
|
CraftingRecipe |
var24 |
|
Holder[] |
var26 |
|
boolean |
var26 |
|
float |
var27 |
|
|
var27 |
|
|
var27 |
|
Instant |
var28 |
|
ProcessingBench.ProcessingSlot |
var29 |
|
float |
var29 |
|
Item |
var3 |
|
float |
var3 |
|
ObjectArrayList |
var3 |
|
int |
var3 |
|
float |
var30 |
|
float |
var30 |
|
String |
var31 |
|
float |
var32 |
|
|
var32 |
|
Map |
var4 |
|
ProcessingBenchWindow |
var4 |
|
int |
var4 |
|
ItemStack |
var4 |
|
List |
var4 |
|
Vector3d |
var5 |
|
Iterator |
var5 |
|
int |
var5 |
|
int |
var5 |
|
List |
var5 |
|
MaterialQuantity |
var6 |
|
int |
var6 |
|
int |
var6 |
|
int |
var7 |
|
ProcessingBench.ProcessingSlot[] |
var7 |
|
float |
var7 |
|
ItemStack |
var8 |
|
int |
var8 |
|
List |
var8 |
|
ListTransaction |
var8 |
|
List |
var8 |
|
float |
var8 |
|
RotationTuple |
var8 |
|
Vector3d |
var8 |
|
MaterialQuantity[] |
var8 |
|
List |
var9 |
|
List |
var9 |
|
ProcessingBench.ProcessingSlot |
var9 |
|
List |
var9 |
|
List |
var9 |
|
float |
var9 |
|
Vector3d |
var9 |
|
int |
var9 |
Методы (100)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
private |
void |
addOutputAndEjectRemaindervoid addOutputAndEjectRemainder(@Nonnull List<ItemStack> var1, @Nonnull Store<EntityStore> var2, int var3, int var4, int var5, @Nonnull BlockType var6, int var7) |
public |
int |
advanceProcessingint advanceProcessing(float var1,
@Nonnull Store<EntityStore> var2,
@Nonnull BenchBlock var3,
@Nonnull BlockModule.BlockStateInfo var4,
int var5,
int var6,
int var7,
@Nonnull BlockType var8,
int var9) |
private |
float |
calculateTotalAvailableFuelfloat calculateTotalAvailableFuel() |
private |
boolean |
canFitScaledOutputboolean canFitScaledOutput(@Nonnull List<ItemStack> var1, int var2) |
public |
void |
checkForRecipeUpdatevoid checkForRecipeUpdate(@Nonnull BenchBlock var1) |
public |
void |
clearCurrentRecipevoid clearCurrentRecipe() |
private |
void |
clearRecipevoid clearRecipe(@Nonnull Map<UUID, BenchWindow> var1) |
private |
void |
completeRecipesvoid completeRecipes(int var1, @Nonnull Store<EntityStore> var2, int var3, int var4, int var5, @Nonnull BlockType var6, int var7) |
public |
void |
consumeFuelForDurationvoid consumeFuelForDuration(float var1, @Nonnull Store<EntityStore> var2, int var3, int var4, int var5, @Nonnull BlockType var6, int var7) |
private |
int |
consumeOneFuelint consumeOneFuel(@Nonnull Store<EntityStore> var1, int var2, int var3, int var4, @Nonnull BlockType var5, int var6) |
private |
int |
countAvailableInputSetsint countAvailableInputSets() |
public |
void |
dropFuelItemsvoid dropFuelItems(@Nonnull List<ItemStack> var1) |
|
|
for for(short var13 = 0; var13 < var12; var13++) |
|
|
for for(int var27 = 0; var27 < var11.length; var27++) |
|
|
for for(MaterialQuantity var4 : var1) |
|
|
for for(int var3 = 0; var3 < var1.length; var3++) |
|
|
for for(ItemStack var5 : var1) |
|
|
for for(MaterialQuantity var12 : var8) |
|
|
for for(ItemStack var14 : var9) |
|
|
for for(int var8 = 0; var8 < var7.length; var8++) |
|
|
for for(ItemStack var20 : var2) |
|
|
for for(CraftingRecipe var7 : var4) |
|
|
for for(MaterialQuantity var14 : var8) |
|
|
for for(CraftingRecipe var25 : var5) |
abstract |
|
for for(short var7 = 0; var7 < this.inputContainer.getCapacity() |
abstract |
|
for for(int var11 = 0; var11 < this.inputContainer.getCapacity() |
abstract |
|
for for(int var20 = 0; var20 < var10.size() |
static |
ComponentType<ChunkStore, ProcessingBenchBlock> |
getComponentTypeComponentType<ChunkStore, ProcessingBenchBlock> getComponentType() |
private |
float |
getCraftingTimeReductionModifierfloat getCraftingTimeReductionModifier(int var1) |
public |
ItemContainer |
getFuelContainerItemContainer getFuelContainer() |
public |
float |
getFuelTimefloat getFuelTime() |
public |
ItemContainer |
getInputContainerItemContainer getInputContainer() |
public |
float |
getInputProgressfloat getInputProgress() |
public |
ItemContainer |
getOutputContainerItemContainer getOutputContainer() |
public |
float |
getRecipeTimeSecondsfloat getRecipeTimeSeconds(int var1) |
|
|
if if(var2 == null) |
|
|
if if(this.nextExtra == -1) |
|
|
if if(var15 != null) |
|
|
if if(var4x == null) |
|
|
if if(var12 > 0) |
|
|
if if(var31 != null) |
|
|
if if(var23 > 0) |
|
|
if if(var26.length > 0) |
|
|
if if(this.lastTickGameTime != null) |
|
|
if if(this.active != var1) |
|
|
if if(!var1) |
|
|
if if(var3 != null) |
|
|
if if(this.fuelTime > this.lastConsumedFuelTotal) |
|
|
if if(var2 != null) |
|
|
if if(var3 == null) |
|
|
if if(this.recipe == null) |
|
|
if if(this.recipe == null) |
|
|
if if(var1 == null) |
|
|
if if(var4 != null) |
|
|
if if(var2 <= 0) |
|
|
if if(this.recipe != null && var1 > 0) |
|
|
if if(var10 && !this.active) |
|
|
if if(var12 <= 0.0F) |
|
|
if if(this.recipe == null) |
|
|
if if(var10 && this.active && this.recipe == null) |
|
|
if if(var10) |
|
|
if if(var23 > 0) |
|
|
if if(var10 && var27 > 0.0F) |
|
|
if if(var10 && var30 > 0.0F) |
|
|
if if(var23 > 0) |
|
|
if if(this.inputProgress < 0.0F) |
|
|
if if(var10 && this.active && this.recipe == null) |
|
|
if if(this.fuelTime < 0.0F) |
|
|
if if(var12 != null) |
|
|
if if(this.nextExtra <= 0) |
|
|
if if(this.recipe == null) |
|
|
if if(this.inputProgress < var7) |
|
|
if if(this.fuelTime > 0.0F) |
|
|
if if(var4 == null) |
|
|
if if(var11 == null) |
|
|
if if(var17 != null) |
|
|
if if(var1 != 0) |
|
|
if if(this.recipe == null && this.recipeId != null) |
|
|
if if(var22 == 0) |
|
|
if if(var9 == var8.length) |
|
|
if if(this.recipeId != null) |
public |
boolean |
initializeBenchConfigboolean initializeBenchConfig(@Nonnull BlockType var1) |
public |
boolean |
isActiveboolean isActive() |
public |
void |
playSoundvoid playSound(int var1, @Nonnull ComponentAccessor<EntityStore> var2, @Nonnull BlockType var3, int var4, int var5, int var6, int var7) |
public |
void |
sendProcessingFuelSlotsvoid sendProcessingFuelSlots(@Nonnull Map<UUID, BenchWindow> var1) |
public |
void |
sendProcessingSlotsvoid sendProcessingSlots(@Nonnull Map<UUID, BenchWindow> var1) |
public |
void |
sendProgressvoid sendProgress(float var1, @Nonnull Map<UUID, BenchWindow> var2) |
public |
boolean |
setActiveboolean setActive(boolean var1, @Nonnull BenchBlock var2, @Nullable BlockModule.BlockStateInfo var3) |
public |
void |
setBlockInteractionStatevoid setBlockInteractionState(@Nonnull String var1, @Nonnull BlockType var2, @Nonnull World var3, int var4, int var5, int var6) |
public |
void |
setInputProgressvoid setInputProgress(float var1) |
public |
void |
setLastConsumedFuelTotalvoid setLastConsumedFuelTotal(int var1) |
public |
void |
setLastTickGameTimevoid setLastTickGameTime(@Nullable Instant var1) |
public |
void |
setupSlotsvoid setupSlots(@Nonnull World var1, @Nonnull BenchBlock var2, @Nonnull BlockModule.BlockStateInfo var3, int var4, int var5, int var6, @Nonnull BlockType var7, int var8) |
private |
boolean |
tryCompleteOneRecipeboolean tryCompleteOneRecipe(@Nonnull Store<EntityStore> var1, int var2, int var3, int var4, @Nonnull BlockType var5, int var6) |
public |
void |
updateFuelValuesvoid updateFuelValues(@Nonnull Map<UUID, BenchWindow> var1) |
private |
void |
updateRecipevoid updateRecipe(@Nonnull BenchBlock var1) |
|
|
while while(var4 > 0) |
|
|
while while(var6 > 0) |
|
|
while while(var15 > 0) |
|
|
while while(var19 < var20) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.crafting.component;
class="kw">import com.hypixel.hytale.builtin.crafting.CraftingPlugin;
class="kw">import com.hypixel.hytale.builtin.crafting.window.BenchWindow;
class="kw">import com.hypixel.hytale.builtin.crafting.window.ProcessingBenchWindow;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.Component;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.event.EventPriority;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.Bench;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.BenchTierLevel;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.ProcessingBench;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.CraftingRecipe;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.Item;
class="kw">import com.hypixel.hytale.server.core.inventory.ItemStack;
class="kw">import com.hypixel.hytale.server.core.inventory.MaterialQuantity;
class="kw">import com.hypixel.hytale.server.core.inventory.ResourceQuantity;
class="kw">import com.hypixel.hytale.server.core.inventory.container.CombinedItemContainer;
class="kw">import com.hypixel.hytale.server.core.inventory.container.InternalContainerUtilMaterial;
class="kw">import com.hypixel.hytale.server.core.inventory.container.ItemContainer;
class="kw">import com.hypixel.hytale.server.core.inventory.container.SimpleItemContainer;
class="kw">import com.hypixel.hytale.server.core.inventory.container.filter.FilterActionType;
class="kw">import com.hypixel.hytale.server.core.inventory.container.filter.FilterType;
class="kw">import com.hypixel.hytale.server.core.inventory.container.filter.ResourceFilter;
class="kw">import com.hypixel.hytale.server.core.inventory.transaction.ItemStackTransaction;
class="kw">import com.hypixel.hytale.server.core.inventory.transaction.ListTransaction;
class="kw">import com.hypixel.hytale.server.core.inventory.transaction.MaterialTransaction;
class="kw">import com.hypixel.hytale.server.core.inventory.transaction.ResourceTransaction;
class="kw">import com.hypixel.hytale.server.core.modules.block.BlockModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent;
class="kw">import com.hypixel.hytale.server.core.modules.time.WorldTimeResource;
class="kw">import com.hypixel.hytale.server.core.universe.world.SoundUtil;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.ints.IntArrayList;
class="kw">import it.unimi.dsi.fastutil.objects.ObjectArrayList;
class="kw">import it.unimi.dsi.fastutil.shorts.ShortOpenHashSet;
class="kw">import it.unimi.dsi.fastutil.shorts.ShortSet;
class="kw">import java.time.Instant;
class="kw">import java.util.Collections;
class="kw">import java.util.Comparator;
class="kw">import java.util.Iterator;
class="kw">import java.util.List;
class="kw">import java.util.Map;
class="kw">import java.util.Objects;
class="kw">import java.util.UUID;
class="kw">import java.util.concurrent.ThreadLocalRandom;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.bson.BsonDocument;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3i;
class="kw">public class ProcessingBenchBlock class="kw">implements Component<ChunkStore> {
@Nonnull
class="kw">public class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
class="kw">public class="kw">static class="kw">final boolean EXACT_RESOURCE_AMOUNTS = true;
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<ProcessingBenchBlock> CODEC = BuilderCodec.builder(ProcessingBenchBlock.class, ProcessingBenchBlock::new)
.append(new KeyedCodec<>("InputContainer", ItemContainer.CODEC), (var0, var1) -> var0.inputContainer = var1, var0 -> var0.inputContainer)
.add()
.append(new KeyedCodec<>("FuelContainer", ItemContainer.CODEC), (var0, var1) -> var0.fuelContainer = var1, var0 -> var0.fuelContainer)
.add()
.append(new KeyedCodec<>("OutputContainer", ItemContainer.CODEC), (var0, var1) -> var0.outputContainer = var1, var0 -> var0.outputContainer)
.add()
.append(new KeyedCodec<>("Progress", Codec.DOUBLE), (var0, var1) -> var0.inputProgress = var1.floatValue(), var0 -> (double)var0.inputProgress)
.add()
.append(new KeyedCodec<>("FuelTime", Codec.DOUBLE), (var0, var1) -> var0.fuelTime = var1.floatValue(), var0 -> (double)var0.fuelTime)
.add()
.append(new KeyedCodec<>("Active", Codec.BOOLEAN), (var0, var1) -> var0.active = var1, var0 -> var0.active)
.add()
.append(new KeyedCodec<>("NextExtra", Codec.INTEGER), (var0, var1) -> var0.nextExtra = var1, var0 -> var0.nextExtra)
.add()
.append(new KeyedCodec<>("RecipeId", Codec.STRING), (var0, var1) -> var0.recipeId = var1, var0 -> var0.recipeId)
.add()
.append(new KeyedCodec<>("LastTickGameTime", Codec.INSTANT), (var0, var1) -> var0.lastTickGameTime = var1, var0 -> var0.lastTickGameTime)
.add()
.build();
@Nonnull
class="kw">public class="kw">static class="kw">final String PROCESSING = "Processing";
@Nonnull
class="kw">public class="kw">static class="kw">final String PROCESS_COMPLETED = "ProcessCompleted";
class="kw">private class="kw">static class="kw">final float MAX_UNLOAD_ELAPSED_SECONDS = 86400.0F;
class="kw">private class="kw">static class="kw">final float EJECT_VELOCITY = 2.0F;
class="kw">private class="kw">static class="kw">final float EJECT_SPREAD_VELOCITY = 1.0F;
class="kw">private class="kw">static class="kw">final float EJECT_VERTICAL_VELOCITY = 3.25F;
@Nonnull
class="kw">private class="kw">final ShortSet processingSlots = new ShortOpenHashSet();
@Nonnull
class="kw">private class="kw">final ShortSet processingFuelSlots = new ShortOpenHashSet();
class="kw">private class="kw">transient Bench bench;
class="kw">private class="kw">transient ProcessingBench processingBench;
class="kw">private ItemContainer inputContainer;
class="kw">private ItemContainer fuelContainer;
class="kw">private ItemContainer outputContainer;
class="kw">private CombinedItemContainer combinedItemContainer;
class="kw">private float inputProgress;
class="kw">private float fuelTime;
class="kw">private int lastConsumedFuelTotal;
class="kw">private int nextExtra = -1;
@Nullable
class="kw">private String recipeId;
@Nullable
class="kw">private CraftingRecipe recipe;
class="kw">private boolean active = false;
@Nullable
class="kw">private Instant lastTickGameTime;
class="kw">public ProcessingBenchBlock() {
}
class="kw">public class="kw">static ComponentType<ChunkStore, ProcessingBenchBlock> getComponentType() {
class="kw">return CraftingPlugin.get().getProcessingBenchBlockComponentType();
}
@Nonnull
class="kw">private class="kw">static Vector3d getCenteredBlockPosition(@Nonnull BlockType var0, int var1, int var2, int var3, int var4) {
Vector3d var5 = new Vector3d();
var0.getBlockCenter(var1, var5);
class="kw">return var5.add(var2, var3, var4);
}
@Nullable
class="kw">public Bench getBench() {
class="kw">return this.bench;
}
@Nullable
class="kw">public ProcessingBench getProcessingBench() {
class="kw">return this.processingBench;
}
class="kw">public ItemContainer getOutputContainer() {
class="kw">return this.outputContainer;
}
class="kw">public ItemContainer getInputContainer() {
class="kw">return this.inputContainer;
}
class="kw">public ItemContainer getFuelContainer() {
class="kw">return this.fuelContainer;
}
class="kw">public float getFuelTime() {
class="kw">return this.fuelTime;
}
@Nonnull
class="kw">public ShortSet getProcessingSlots() {
class="kw">return this.processingSlots;
}
@Nonnull
class="kw">public ShortSet getProcessingFuelSlots() {
class="kw">return this.processingFuelSlots;
}
@Nullable
class="kw">public Instant getLastTickGameTime() {
class="kw">return this.lastTickGameTime;
}
class="kw">public void setLastTickGameTime(@Nullable Instant var1) {
this.lastTickGameTime = var1;
}
class="kw">public void setLastConsumedFuelTotal(int var1) {
this.lastConsumedFuelTotal = var1;
}
class="kw">public void clearCurrentRecipe() {
this.recipeId = null;
this.recipe = null;
}
class="kw">public boolean initializeBenchConfig(@Nonnull BlockType var1) {
Bench var2 = var1.getBench();
if (var2 == null) {
class="kw">return false;
}
if (!(var2 class="kw">instanceof ProcessingBench)) {
LOGGER.at(Level.SEVERE).log("Wrong bench type for processing. Got %s", var2.getClass().getName());
class="kw">return false;
}
this.bench = var2;
this.processingBench = (ProcessingBench)var2;
if (this.nextExtra == -1) {
this.nextExtra = this.processingBench.getExtraOutput() != null ? this.processingBench.getExtraOutput().getPerFuelItemsConsumed() : 0;
}
class="kw">return true;
}
class="kw">public void setupSlots(
@Nonnull World var1, @Nonnull BenchBlock var2, @Nonnull BlockModule.BlockStateInfo var3, int var4, int var5, int var6, @Nonnull BlockType var7, int var8
) {
List var9 = new ObjectArrayList();
int var10 = var2.getTierLevel();
ProcessingBench.ProcessingSlot[] var11 = this.processingBench.getInput(var10);
short var12 = (short)var11.length;
this.inputContainer = ItemContainer.ensureContainerCapacity(this.inputContainer, var12, SimpleItemContainer::getNewContainer, var9);
this.inputContainer.registerChangeEvent(EventPriority.LAST, var1x -> var3.markNeedsSaving());
for (short var13 = 0; var13 < var12; var13++) {
ProcessingBench.ProcessingSlot var14 = var11[var13];
String var15 = var14.getResourceTypeId();
boolean var16 = var14.shouldFilterValidIngredients();
if (var15 != null) {
this.inputContainer.setSlotFilter(FilterActionType.ADD, var13, new ResourceFilter(new ResourceQuantity(var15, 1)));
} else if (var16) {
ObjectArrayList var17 = new ObjectArrayList();
for (CraftingRecipe var20 : CraftingPlugin.getBenchRecipes(this.bench.getType(), this.bench.getId())) {
if (!var20.isRestrictedByBenchTierLevel(this.bench.getId(), var10)) {
List var21 = CraftingManager.getInputMaterials(var20);
var17.addAll(var21);
}
}
this.inputContainer.setSlotFilter(FilterActionType.ADD, var13, (var1x, var2x, var3x, var4x) -> {
if (var4x == null) {
class="kw">return true;
}
Iterator var5 = var17.iterator();
while (var5.hasNext()) {
MaterialQuantity var6 = (MaterialQuantity)var5.next();
if (CraftingManager.matches(var6, var4x)) {
class="kw">return true;
}
}
class="kw">return false;
});
}
}
var11 = this.processingBench.getFuel();
var12 = (short)(var11 != null ? var11.length : 0);
this.fuelContainer = ItemContainer.ensureContainerCapacity(this.fuelContainer, var12, SimpleItemContainer::getNewContainer, var9);
this.fuelContainer.registerChangeEvent(EventPriority.LAST, var1x -> var3.markNeedsSaving());
if (var12 > 0) {
for (int var27 = 0; var27 < var11.length; var27++) {
ProcessingBench.ProcessingSlot var29 = var11[var27];
String var31 = var29.getResourceTypeId();
if (var31 != null) {
this.fuelContainer.setSlotFilter(FilterActionType.ADD, (short)var27, new ResourceFilter(new ResourceQuantity(var31, 1)));
}
}
}
short var23 = (short)this.processingBench.getOutputSlotsCount(var10);
this.outputContainer = ItemContainer.ensureContainerCapacity(this.outputContainer, var23, SimpleItemContainer::getNewContainer, var9);
this.outputContainer.registerChangeEvent(EventPriority.LAST, var1x -> var3.markNeedsSaving());
if (var23 > 0) {
this.outputContainer.setGlobalFilter(FilterType.ALLOW_OUTPUT_ONLY);
}
this.combinedItemContainer = new CombinedItemContainer(this.fuelContainer, this.inputContainer, this.outputContainer);
Store var24 = var1.getEntityStore().getStore();
Holder[] var26 = this.ejectItems(var24, var9, var8, var7, var4, var5, var6);
if (var26.length > 0) {
var1.execute(() -> var24.addEntities(var26, AddReason.SPAWN));
}
this.inputContainer.registerChangeEvent(EventPriority.LAST, var2x -> this.updateRecipe(var2));
this.outputContainer.registerChangeEvent(EventPriority.LAST, var2x -> this.updateRecipe(var2));
if (this.processingBench.getFuel() == null) {
this.setActive(true, var2, var3);
}
if (this.lastTickGameTime != null) {
Instant var28 = var24.getResource(WorldTimeResource.getResourceType()).getGameTime();
float var30 = (float)Math.max(0L, var28.toEpochMilli() - this.lastTickGameTime.toEpochMilli()) / 1000.0F;
float var32 = (float)(var30 / WorldTimeResource.getSecondsPerTick(var1));
var32 = Math.min(var32, 86400.0F);
this.checkForRecipeUpdate(var2);
this.advanceProcessing(var32, var24, var2, var3, var4, var5, var6, var7, var8);
this.lastTickGameTime = var28;
var3.markNeedsSaving();
}
}
class="kw">public boolean isActive() {
class="kw">return this.active;
}
class="kw">public boolean setActive(boolean var1, @Nonnull BenchBlock var2, @Nullable BlockModule.BlockStateInfo var3) {
if (this.active != var1) {
if (var1 && this.processingBench.getFuel() != null && this.fuelContainer.isEmpty()) {
class="kw">return false;
}
this.active = var1;
Map var4 = var2.getWindows();
if (!var1) {
this.processingSlots.clear();
this.processingFuelSlots.clear();
this.sendProcessingSlots(var4);
this.sendProcessingFuelSlots(var4);
}
this.updateRecipe(var2);
var4.forEach((var1x, var2x) -> ((ProcessingBenchWindow)var2x).setActive(var1));
if (var3 != null) {
var3.markNeedsSaving();
}
class="kw">return true;
} else {
class="kw">return false;
}
}
class="kw">public void updateFuelValues(@Nonnull Map<UUID, BenchWindow> var1) {
if (this.fuelTime > this.lastConsumedFuelTotal) {
this.lastConsumedFuelTotal = MathUtil.ceil(this.fuelTime);
}
float var2 = this.lastConsumedFuelTotal > 0 ? this.fuelTime / this.lastConsumedFuelTotal : 0.0F;
var1.forEach((var2x, var3) -> {
ProcessingBenchWindow var4 = (ProcessingBenchWindow)var3;
var4.setFuelTime(var2);
var4.setMaxFuel(this.lastConsumedFuelTotal);
var4.setProcessingFuelSlots(this.processingFuelSlots);
});
}
@Nullable
class="kw">public CombinedItemContainer getItemContainer() {
class="kw">return this.combinedItemContainer;
}
@Nullable
class="kw">public CraftingRecipe getRecipe() {
class="kw">return this.recipe;
}
class="kw">public float getInputProgress() {
class="kw">return this.inputProgress;
}
class="kw">public void setInputProgress(float var1) {
this.inputProgress = var1;
}
class="kw">public void dropFuelItems(@Nonnull List<ItemStack> var1) {
String var2 = this.processingBench.getFuelDropItemId();
if (var2 != null) {
Item var3 = Item.getAssetMap().getAsset(var2);
if (var3 == null) {
LOGGER.at(Level.WARNING).log("Unknown FuelDropItemId %s for %s, fuel value of %s will be lost!", var2, this.bench.getId(), this.fuelTime);
this.fuelTime = 0.0F;
class="kw">return;
}
int var4 = (int)this.fuelTime;
this.fuelTime = 0.0F;
while (var4 > 0) {
int var5 = Math.min(var4, var3.getMaxStack());
var1.add(new ItemStack(var2, var5));
var4 -= var5;
}
} else {
LOGGER.at(Level.WARNING).log("No FuelDropItemId defined for %s fuel value of %s will be lost!", this.bench.getId(), this.fuelTime);
}
}
class="kw">private float getCraftingTimeReductionModifier(int var1) {
BenchTierLevel var2 = this.bench.getTierLevel(var1);
class="kw">return var2 != null ? var2.getCraftingTimeReductionModifier() : 0.0F;
}
class="kw">public float getRecipeTimeSeconds(int var1) {
if (this.recipe == null) {
class="kw">return 0.0F;
}
float var2 = this.recipe.getTimeSeconds();
float var3 = this.getCraftingTimeReductionModifier(var1);
class="kw">return var3 > 0.0F ? var2 - var2 * var3 : var2;
}
class="kw">private int countAvailableInputSets() {
if (this.recipe == null) {
class="kw">return 0;
}
List var1 = CraftingManager.getInputMaterials(this.recipe);
if (var1.isEmpty()) {
class="kw">return 0;
}
int var2 = Integer.MAX_VALUE;
for (MaterialQuantity var4 : var1) {
int var5 = var4.getQuantity();
int var6 = 0;
for (short var7 = 0; var7 < this.inputContainer.getCapacity(); var7++) {
ItemStack var8 = this.inputContainer.getItemStack(var7);
if (var8 != null && CraftingManager.matches(var4, var8)) {
var6 += var8.getQuantity();
}
}
var2 = Math.min(var2, var6 / var5);
}
class="kw">return var2;
}
class="kw">private float calculateTotalAvailableFuel() {
ProcessingBench.ProcessingSlot[] var1 = this.processingBench.getFuel();
if (var1 == null) {
class="kw">return 0.0F;
}
float var2 = 0.0F;
for (int var3 = 0; var3 < var1.length; var3++) {
ItemStack var4 = this.fuelContainer.getItemStack((short)var3);
if (var4 != null) {
var2 += (float)(var4.getQuantity() * var4.getItem().getFuelQuality());
}
}
class="kw">return var2;
}
class="kw">private boolean canFitScaledOutput(@Nonnull List<ItemStack> var1, int var2) {
if (var2 <= 0) {
class="kw">return true;
}
ObjectArrayList var3 = new ObjectArrayList();
for (ItemStack var5 : var1) {
int var6 = var5.getQuantity() * var2;
int var7 = var5.getItem().getMaxStack();
while (var6 > 0) {
int var8 = Math.min(var6, var7);
var3.add(var5.withQuantity(var8));
var6 -= var8;
}
}
class="kw">return this.outputContainer.canAddItemStacks(var3, false, false);
}
class="kw">private void completeRecipes(int var1, @Nonnull Store<EntityStore> var2, int var3, int var4, int var5, @Nonnull BlockType var6, int var7) {
if (this.recipe != null && var1 > 0) {
List var8 = CraftingManager.getInputMaterials(this.recipe);
List var9 = CraftingManager.getOutputItemStacks(this.recipe);
ObjectArrayList var10 = new ObjectArrayList(var8.size());
for (MaterialQuantity var12 : var8) {
var10.add(var12.clone(var12.getQuantity() * var1));
}
ListTransaction var18 = this.inputContainer.removeMaterials(var10, true, true, true);
if (var18.succeeded()) {
ObjectArrayList var19 = new ObjectArrayList();
for (ItemStack var14 : var9) {
int var15 = var14.getQuantity() * var1;
int var16 = var14.getItem().getMaxStack();
while (var15 > 0) {
int var17 = Math.min(var15, var16);
var19.add(var14.withQuantity(var17));
var15 -= var17;
}
}
this.addOutputAndEjectRemainder(var19, var2, var3, var4, var5, var6, var7);
}
}
}
class="kw">public int advanceProcessing(
float var1,
@Nonnull Store<EntityStore> var2,
@Nonnull BenchBlock var3,
@Nonnull BlockModule.BlockStateInfo var4,
int var5,
int var6,
int var7,
@Nonnull BlockType var8,
int var9
) {
if (this.recipe != null && !(var1 <= 0.0F)) {
boolean var10 = this.processingBench.getFuel() != null;
if (var10 && !this.active) {
class="kw">return 0;
}
int var11 = var3.getTierLevel();
float var12 = this.getRecipeTimeSeconds(var11);
if (var12 <= 0.0F) {
int var22 = 0;
while (this.tryCompleteOneRecipe(var2, var5, var6, var7, var8, var9)) {
var22++;
this.updateRecipe(var3);
if (this.recipe == null) {
break;
}
}
if (var10 && this.active && this.recipe == null) {
this.setActive(false, var3, var4);
}
class="kw">return var22;
} else {
float var13 = this.inputProgress;
int var14 = (int)((this.inputProgress + var1) / var12);
int var15 = this.countAvailableInputSets();
int var16 = Integer.MAX_VALUE;
if (var10) {
float var17 = this.fuelTime + this.calculateTotalAvailableFuel();
var16 = (int)((this.inputProgress + var17) / var12);
}
int var23 = Math.min(var14, Math.min(var15, var16));
if (var23 > 0) {
List var18 = CraftingManager.getOutputItemStacks(this.recipe);
int var19 = 0;
int var20 = var23;
while (var19 < var20) {
int var21 = (var19 + var20 + 1) / 2;
if (this.canFitScaledOutput(var18, var21)) {
var19 = var21;
} else {
var20 = var21 - 1;
}
}
var23 = var19;
}
float var24 = var23 > 0 ? var23 * var12 - this.inputProgress : 0.0F;
var24 = Math.max(0.0F, var24);
boolean var26 = var23 < var15;
float var27 = var26 ? Math.min(var1 - var24, var12) : 0.0F;
var27 = Math.max(0.0F, var27);
if (var10 && var27 > 0.0F) {
float var29 = this.fuelTime + this.calculateTotalAvailableFuel();
var27 = Math.min(var27, Math.max(0.0F, var29 - var24));
}
float var30 = var24 + var27;
if (var10 && var30 > 0.0F) {
this.consumeFuelForDuration(var30, var2, var5, var6, var7, var8, var9);
}
if (var23 > 0) {
this.completeRecipes(var23, var2, var5, var6, var7, var8, var9);
}
this.inputProgress = var13 + var30 - var23 * var12;
if (this.inputProgress < 0.0F) {
this.inputProgress = 0.0F;
}
this.updateRecipe(var3);
if (var10 && this.active && this.recipe == null) {
this.setActive(false, var3, var4);
}
class="kw">return var23;
}
} else {
class="kw">return 0;
}
}
class="kw">private int consumeOneFuel(@Nonnull Store<EntityStore> var1, int var2, int var3, int var4, @Nonnull BlockType var5, int var6) {
ProcessingBench.ProcessingSlot[] var7 = this.processingBench.getFuel();
if (var7 != null
&& var7.length != 0
&& this.active
&& (this.processingBench.getMaxFuel() <= 0 || this.fuelTime < this.processingBench.getMaxFuel())
&& !this.fuelContainer.isEmpty()) {
if (this.fuelTime < 0.0F) {
this.fuelTime = 0.0F;
}
for (int var8 = 0; var8 < var7.length; var8++) {
ProcessingBench.ProcessingSlot var9 = var7[var8];
String var10 = var9.getResourceTypeId() != null ? var9.getResourceTypeId() : "Fuel";
ResourceQuantity var11 = new ResourceQuantity(var10, 1);
ItemStack var12 = this.fuelContainer.getItemStack((short)var8);
if (var12 != null) {
double var13 = var12.getItem().getFuelQuality();
ResourceTransaction var15 = this.fuelContainer.removeResource(var11, true, true, true);
if (var15.getRemainder() <= 0) {
ProcessingBench.ExtraOutput var16 = this.processingBench.getExtraOutput();
if (var16 != null && !var16.isIgnoredFuelSource(var12.getItem())) {
this.nextExtra--;
if (this.nextExtra <= 0) {
this.nextExtra = var16.getPerFuelItemsConsumed();
ObjectArrayList var17 = new ObjectArrayList(var16.getOutputs().length);
for (MaterialQuantity var21 : var16.getOutputs()) {
var17.add(var21.toItemStack());
}
this.addOutputAndEjectRemainder(var17, var1, var2, var3, var4, var5, var6);
}
}
this.fuelTime = this.fuelTime + (float)(var15.getConsumed() * var13);
class="kw">return var8;
}
}
}
class="kw">return -1;
} else {
class="kw">return -1;
}
}
class="kw">private void addOutputAndEjectRemainder(
@Nonnull List<ItemStack> var1, @Nonnull Store<EntityStore> var2, int var3, int var4, int var5, @Nonnull BlockType var6, int var7
) {
ListTransaction var8 = this.outputContainer.addItemStacks(var1, false, false, false);
List var9 = new ObjectArrayList();
for (ItemStackTransaction var11 : var8.getList()) {
ItemStack var12 = var11.getRemainder();
if (var12 != null && !var12.isEmpty()) {
var9.add(var12);
}
}
if (!var9.isEmpty()) {
Holder[] var13 = this.ejectItems(var2, var9, var7, var6, var3, var4, var5);
var2.addEntities(var13, AddReason.SPAWN);
}
}
class="kw">private boolean tryCompleteOneRecipe(@Nonnull Store<EntityStore> var1, int var2, int var3, int var4, @Nonnull BlockType var5, int var6) {
if (this.recipe == null) {
class="kw">return false;
}
float var7 = this.recipe.getTimeSeconds();
if (this.inputProgress < var7) {
class="kw">return false;
}
List var8 = CraftingManager.getInputMaterials(this.recipe);
List var9 = CraftingManager.getOutputItemStacks(this.recipe);
if (!this.outputContainer.canAddItemStacks(var9, false, false)) {
class="kw">return false;
}
if (this.inputContainer.getSlotMaterialsToRemove(var8, true, true).isEmpty()) {
class="kw">return false;
}
ListTransaction var10 = this.inputContainer.removeMaterials(var8, true, true, true);
if (!var10.succeeded()) {
class="kw">return false;
}
this.inputProgress -= var7;
this.addOutputAndEjectRemainder(var9, var1, var2, var3, var4, var5, var6);
class="kw">return true;
}
class="kw">public void consumeFuelForDuration(float var1, @Nonnull Store<EntityStore> var2, int var3, int var4, int var5, @Nonnull BlockType var6, int var7) {
if (!(var1 <= 0.0F)) {
float var8 = 0.0F;
if (this.fuelTime > 0.0F) {
float var9 = Math.min(this.fuelTime, var1);
this.fuelTime -= var9;
var8 += var9;
}
while (var8 < var1 && this.consumeOneFuel(var2, var3, var4, var5, var6, var7) >= 0) {
float var10 = Math.min(this.fuelTime, var1 - var8);
this.fuelTime -= var10;
var8 += var10;
}
}
}
@Nonnull
class="kw">private Holder<EntityStore>[] ejectItems(
@Nonnull ComponentAccessor<EntityStore> var1, @Nonnull List<ItemStack> var2, int var3, @Nullable BlockType var4, int var5, int var6, int var7
) {
if (var2.isEmpty()) {
class="kw">return Holder.emptyArray();
}
RotationTuple var8 = RotationTuple.get(var3);
Vector3d var9 = new Vector3d(0.0, 0.0, 1.0);
var8.yaw().rotateY(var9, var9);
Vector3d var10;
if (var4 == null) {
var10 = new Vector3d(var5 + 0.5, var6, var7 + 0.5);
} else {
BlockBoundingBoxes var11 = BlockBoundingBoxes.getAssetMap().getAsset(var4.getHitboxTypeIndex());
if (var11 == null) {
var10 = new Vector3d(var5 + 0.5, var6, var7 + 0.5);
} else {
double var12 = var11.get(0).getBoundingBox().depth();
double var14 = var12 / 2.0 + 0.1F;
var10 = getCenteredBlockPosition(var4, var3, var5, var6, var7);
var10.add(var9.x * var14, 0.0, var9.z * var14);
}
}
ThreadLocalRandom var18 = ThreadLocalRandom.current();
ObjectArrayList var19 = new ObjectArrayList(var2.size());
for (ItemStack var20 : var2) {
float var15 = (float)(var9.x * 2.0 + 2.0 * (var18.nextDouble() - 0.5));
float var16 = (float)(var9.z * 2.0 + 2.0 * (var18.nextDouble() - 0.5));
Holder var17 = ItemComponent.generateItemDrop(var1, var20, var10, Rotation3f.IDENTITY, var15, 3.25F, var16);
if (var17 != null) {
var19.add(var17);
}
}
class="kw">return (Holder<EntityStore>[])var19.toArray(Holder[]::new);
}
class="kw">public void sendProgress(float var1, @Nonnull Map<UUID, BenchWindow> var2) {
var2.forEach((var1x, var2x) -> ((ProcessingBenchWindow)var2x).setProgress(var1));
}
class="kw">public void sendProcessingSlots(@Nonnull Map<UUID, BenchWindow> var1) {
var1.forEach((var1x, var2) -> ((ProcessingBenchWindow)var2).setProcessingSlots(this.processingSlots));
}
class="kw">public void sendProcessingFuelSlots(@Nonnull Map<UUID, BenchWindow> var1) {
var1.forEach((var1x, var2) -> ((ProcessingBenchWindow)var2).setProcessingFuelSlots(this.processingFuelSlots));
}
class="kw">public void setBlockInteractionState(@Nonnull String var1, @Nonnull BlockType var2, @Nonnull World var3, int var4, int var5, int var6) {
var3.setBlockInteractionState(new Vector3i(var4, var5, var6), var2, var1);
}
class="kw">public void playSound(int var1, @Nonnull ComponentAccessor<EntityStore> var2, @Nonnull BlockType var3, int var4, int var5, int var6, int var7) {
if (var1 != 0) {
Vector3d var8 = getCenteredBlockPosition(var3, var4, var5, var6, var7);
SoundUtil.playSoundEvent3d(var1, SoundCategory.SFX, var8, var2);
}
}
class="kw">public void checkForRecipeUpdate(@Nonnull BenchBlock var1) {
if (this.recipe == null && this.recipeId != null) {
this.updateRecipe(var1);
}
}
class="kw">private void updateRecipe(@Nonnull BenchBlock var1) {
Map var2 = var1.getWindows();
int var3 = var1.getTierLevel();
List var4 = CraftingPlugin.getBenchRecipes(this.bench.getType(), this.bench.getId());
if (var4.isEmpty()) {
this.clearRecipe(var2);
} else {
List var5 = new ObjectArrayList();
for (CraftingRecipe var7 : var4) {
if (!var7.isRestrictedByBenchTierLevel(this.bench.getId(), var3)) {
MaterialQuantity[] var8 = var7.getInput();
int var9 = 0;
IntArrayList var10 = new IntArrayList();
for (int var11 = 0; var11 < this.inputContainer.getCapacity(); var11++) {
var10.add(var11);
}
for (MaterialQuantity var14 : var8) {
String var15 = var14.getItemId();
String var16 = var14.getResourceTypeId();
int var17 = var14.getQuantity();
BsonDocument var18 = var14.getMetadata();
MaterialQuantity var19 = new MaterialQuantity(var15, var16, null, var17, var18);
for (int var20 = 0; var20 < var10.size(); var20++) {
int var21 = var10.getInt(var20);
int var22 = InternalContainerUtilMaterial.testRemoveMaterialFromSlot(this.inputContainer, (short)var21, var19, var19.getQuantity(), true);
if (var22 == 0) {
var9++;
var10.removeInt(var20);
break;
}
}
}
if (var9 == var8.length) {
var5.add(var7);
}
}
}
if (var5.isEmpty()) {
this.clearRecipe(var2);
} else {
var5.sort(Comparator.comparingInt(var0 -> CraftingManager.getInputMaterials(var0).size()));
Collections.reverse(var5);
if (this.recipeId != null) {
for (CraftingRecipe var25 : var5) {
if (Objects.equals(this.recipeId, var25.getId())) {
LOGGER.at(Level.FINE).log("Keeping existing Recipe %s %s", this.recipeId, var25);
this.recipe = var25;
class="kw">return;
}
}
}
CraftingRecipe var24 = var5.getFirst();
if (this.recipeId == null || !Objects.equals(this.recipeId, var24.getId())) {
this.inputProgress = 0.0F;
this.sendProgress(0.0F, var2);
}
this.recipeId = var24.getId();
this.recipe = var24;
LOGGER.at(Level.FINE).log("Found Recipe %s %s", this.recipeId, this.recipe);
}
}
}
class="kw">private void clearRecipe(@Nonnull Map<UUID, BenchWindow> var1) {
this.recipeId = null;
this.recipe = null;
this.lastConsumedFuelTotal = 0;
this.inputProgress = 0.0F;
this.sendProgress(0.0F, var1);
LOGGER.at(Level.FINE).log("Cleared Recipe");
}
@Nullable
@Override
class="kw">public Component<ChunkStore> clone() {
ProcessingBenchBlock var1 = new ProcessingBenchBlock();
var1.inputContainer = this.inputContainer;
var1.fuelContainer = this.fuelContainer;
var1.outputContainer = this.outputContainer;
var1.inputProgress = this.inputProgress;
var1.fuelTime = this.fuelTime;
var1.lastConsumedFuelTotal = this.lastConsumedFuelTotal;
var1.active = this.active;
var1.nextExtra = this.nextExtra;
var1.recipeId = this.recipeId;
var1.lastTickGameTime = this.lastTickGameTime;
class="kw">return var1;
}
}