This commit is contained in:
modmuss50 2020-04-09 01:47:11 +01:00
parent 0bf6159801
commit 55f9a5df52
33 changed files with 195 additions and 360 deletions

View file

@ -65,15 +65,15 @@ license {
group = 'TechReborn'
dependencies {
minecraft "com.mojang:minecraft:20w13a"
mappings "net.fabricmc:yarn:20w13a+build.1:v2"
modImplementation "net.fabricmc:fabric-loader:0.7.8+build.189"
minecraft "com.mojang:minecraft:20w15a"
mappings "net.fabricmc:yarn:20w15a+build.2:v2"
modImplementation "net.fabricmc:fabric-loader:0.8.2+build.194"
//Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:0.5.6+build.313-1.16"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.5.9+build.319-1.16"
optionalDependency ("me.shedaniel:RoughlyEnoughItems:4.1.1-unstable")
optionalDependency ('io.github.cottonmc:LibCD:2.3.0+1.15.2')
disabledOptionalDependency ('io.github.cottonmc:LibCD:2.3.0+1.15.2')
def rcVersion = 'RebornCore:RebornCore-1.16:+'
modApi (rcVersion) {
@ -100,6 +100,13 @@ def optionalDependency(String dep) {
}
}
def disabledOptionalDependency(String dep) {
dependencies.modCompileOnly (dep) {
exclude group: "net.fabricmc.fabric-api"
exclude module: "nbt-crafting"
}
}
processResources {
inputs.property "version", project.version

View file

@ -85,7 +85,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
// Check cells input slot 2 time per second
if (ticksSinceLastChange >= 10) {
ItemStack inputStack = inventory.getInvStack(0);
ItemStack inputStack = inventory.getStack(0);
if (!inputStack.isEmpty()) {
if (FluidUtils.isContainerEmpty(inputStack) && !tank.getFluidAmount().isEmpty()) {
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid());
@ -144,8 +144,8 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
}
protected boolean acceptFluid() {
if (!inventory.getInvStack(0).isEmpty()) {
FluidInstance stack = FluidUtils.getFluidStackInContainer(inventory.getInvStack(0));
if (!inventory.getStack(0).isEmpty()) {
FluidInstance stack = FluidUtils.getFluidStackInContainer(inventory.getStack(0));
if (stack != null)
return recipes.getRecipeForFluid(stack.getFluid()).isPresent();
}

View file

@ -94,15 +94,15 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
if (burnTime == 0) {
updateState();
burnTime = totalBurnTime = SolidFuelGeneratorBlockEntity.getItemBurnTime(inventory.getInvStack(fuelSlot));
burnTime = totalBurnTime = SolidFuelGeneratorBlockEntity.getItemBurnTime(inventory.getStack(fuelSlot));
if (burnTime > 0) {
updateState();
burnItem = inventory.getInvStack(fuelSlot);
if (inventory.getInvStack(fuelSlot).getCount() == 1) {
if (inventory.getInvStack(fuelSlot).getItem() == Items.LAVA_BUCKET || inventory.getInvStack(fuelSlot).getItem() instanceof BucketItem) {
inventory.setInvStack(fuelSlot, new ItemStack(Items.BUCKET));
burnItem = inventory.getStack(fuelSlot);
if (inventory.getStack(fuelSlot).getCount() == 1) {
if (inventory.getStack(fuelSlot).getItem() == Items.LAVA_BUCKET || inventory.getStack(fuelSlot).getItem() instanceof BucketItem) {
inventory.setStack(fuelSlot, new ItemStack(Items.BUCKET));
} else {
inventory.setInvStack(fuelSlot, ItemStack.EMPTY);
inventory.setStack(fuelSlot, ItemStack.EMPTY);
}
} else {

View file

@ -155,16 +155,16 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
}
if (!isBurning && canSmelt()) {
burnTime = totalBurnTime = getItemBurnTime(inventory.getInvStack(fuelSlot));
burnTime = totalBurnTime = getItemBurnTime(inventory.getStack(fuelSlot));
if (burnTime > 0) {
// Fuel slot
ItemStack fuelStack = inventory.getInvStack(fuelSlot);
ItemStack fuelStack = inventory.getStack(fuelSlot);
if (fuelStack.getItem().hasRecipeRemainder()) {
inventory.setInvStack(fuelSlot, new ItemStack(fuelStack.getItem().getRecipeRemainder()));
inventory.setStack(fuelSlot, new ItemStack(fuelStack.getItem().getRecipeRemainder()));
} else if (fuelStack.getCount() > 1) {
inventory.shrinkSlot(fuelSlot, 1);
} else if (fuelStack.getCount() == 1) {
inventory.setInvStack(fuelSlot, ItemStack.EMPTY);
inventory.setStack(fuelSlot, ItemStack.EMPTY);
}
}
}

View file

@ -54,7 +54,7 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
for (RebornIngredient ingredient : recipeType.getRebornIngredients()) {
boolean hasItem = false;
for (int inputslot = 0; inputslot < 2; inputslot++) {
if (ingredient.test(inventory.getInvStack(inputslot))) {
if (ingredient.test(inventory.getStack(inputslot))) {
hasItem = true;
}
}
@ -66,7 +66,7 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
@Override
protected boolean canSmelt() {
if (inventory.getInvStack(input1).isEmpty() || inventory.getInvStack(input2).isEmpty()) {
if (inventory.getStack(input1).isEmpty() || inventory.getStack(input2).isEmpty()) {
return false;
}
ItemStack itemstack = null;
@ -79,12 +79,12 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
if (itemstack == null)
return false;
if (inventory.getInvStack(output).isEmpty())
if (inventory.getStack(output).isEmpty())
return true;
if (!inventory.getInvStack(output).isItemEqualIgnoreDamage(itemstack))
if (!inventory.getStack(output).isItemEqualIgnoreDamage(itemstack))
return false;
int result = inventory.getInvStack(output).getCount() + itemstack.getCount();
return result <= inventory.getStackLimit() && result <= inventory.getInvStack(output).getMaxCount();
int result = inventory.getStack(output).getCount() + itemstack.getCount();
return result <= inventory.getStackLimit() && result <= inventory.getStack(output).getMaxCount();
}
@Override
@ -108,15 +108,15 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
if (outputStack.isEmpty()) {
return;
}
if (inventory.getInvStack(output).isEmpty()) {
inventory.setInvStack(output, outputStack.copy());
} else if (inventory.getInvStack(output).getItem() == outputStack.getItem()) {
if (inventory.getStack(output).isEmpty()) {
inventory.setStack(output, outputStack.copy());
} else if (inventory.getStack(output).getItem() == outputStack.getItem()) {
inventory.shrinkSlot(output, -outputStack.getCount());
}
for (RebornIngredient ingredient : currentRecipe.getRebornIngredients()) {
for (int inputSlot = 0; inputSlot < 2; inputSlot++) {
if (ingredient.test(inventory.getInvStack(inputSlot))) {
if (ingredient.test(inventory.getStack(inputSlot))) {
inventory.shrinkSlot(inputSlot, ingredient.getCount());
break;
}

View file

@ -88,35 +88,35 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
if (!canSmelt()) {
return;
}
ItemStack inputStack = inventory.getInvStack(inputSlot);
ItemStack inputStack = inventory.getStack(inputSlot);
ItemStack resultStack = getResultFor(inputStack);
if (inventory.getInvStack(outputSlot).isEmpty()) {
inventory.setInvStack(outputSlot, resultStack.copy());
} else if (inventory.getInvStack(outputSlot).isItemEqualIgnoreDamage(resultStack)) {
inventory.getInvStack(outputSlot).increment(resultStack.getCount());
if (inventory.getStack(outputSlot).isEmpty()) {
inventory.setStack(outputSlot, resultStack.copy());
} else if (inventory.getStack(outputSlot).isItemEqualIgnoreDamage(resultStack)) {
inventory.getStack(outputSlot).increment(resultStack.getCount());
}
experience += getExperienceFor(inputStack);
if (inputStack.getCount() > 1) {
inventory.shrinkSlot(inputSlot, 1);
} else {
inventory.setInvStack(inputSlot, ItemStack.EMPTY);
inventory.setStack(inputSlot, ItemStack.EMPTY);
}
}
@Override
protected boolean canSmelt() {
if (inventory.getInvStack(inputSlot).isEmpty()) {
if (inventory.getStack(inputSlot).isEmpty()) {
return false;
}
ItemStack outputStack = getResultFor(inventory.getInvStack(inputSlot));
ItemStack outputStack = getResultFor(inventory.getStack(inputSlot));
if (outputStack.isEmpty())
return false;
if (inventory.getInvStack(outputSlot).isEmpty())
if (inventory.getStack(outputSlot).isEmpty())
return true;
if (!inventory.getInvStack(outputSlot).isItemEqualIgnoreDamage(outputStack))
if (!inventory.getStack(outputSlot).isItemEqualIgnoreDamage(outputStack))
return false;
int result = inventory.getInvStack(outputSlot).getCount() + outputStack.getCount();
int result = inventory.getStack(outputSlot).getCount() + outputStack.getCount();
return result <= inventory.getStackLimit() && result <= outputStack.getMaxCount();
}

View file

@ -57,7 +57,7 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
return;
}
for (int i = 0; i < 6; i++) {
ItemStack stack = inventory.getInvStack(i);
ItemStack stack = inventory.getStack(i);
if (Energy.valid(stack)) {
Energy.of(this)

View file

@ -83,7 +83,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
ticksSinceLastChange++;
// Check cells input slot 2 time per second
if (!world.isClient && ticksSinceLastChange >= 10) {
if (!inventory.getInvStack(1).isEmpty()) {
if (!inventory.getStack(1).isEmpty()) {
FluidUtils.fillContainers(tank, inventory, 1, 2, tank.getFluid());
}
ticksSinceLastChange = 0;

View file

@ -126,11 +126,11 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
if (stack.isEmpty()) {
return true;
}
if (inventory.getInvStack(slot).isEmpty()) {
if (inventory.getStack(slot).isEmpty()) {
return true;
}
if (ItemUtils.isItemEqual(inventory.getInvStack(slot), stack, true, tags)) {
return stack.getCount() + inventory.getInvStack(slot).getCount() <= stack.getMaxCount();
if (ItemUtils.isItemEqual(inventory.getStack(slot), stack, true, tags)) {
return stack.getCount() + inventory.getStack(slot).getCount() <= stack.getMaxCount();
}
return false;
}
@ -186,8 +186,8 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
}
for (RebornIngredient ingredient : recipeType.getRebornIngredients()) {
boolean hasItem = false;
if (ingredient.test(inventory.getInvStack(topStackSlot))
|| ingredient.test(inventory.getInvStack(bottomStackSlot))) {
if (ingredient.test(inventory.getStack(topStackSlot))
|| ingredient.test(inventory.getStack(bottomStackSlot))) {
hasItem = true;
}
if (!hasItem) {
@ -207,7 +207,7 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
return;
}
for (RebornIngredient ingredient : currentRecipe.getRebornIngredients()) {
if (ingredient.test(inventory.getInvStack(slot))) {
if (ingredient.test(inventory.getStack(slot))) {
inventory.shrinkSlot(slot, ingredient.getCount());
break;
}
@ -288,8 +288,8 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
} else if (crafingTickTime >= currentRecipe.getTime()) {
ItemStack result = currentRecipe.getOutputs().get(0);
if (canFitStack(result, outputStackSlot, true)) {
if (inventory.getInvStack(outputStackSlot).isEmpty()) {
inventory.setInvStack(outputStackSlot, result.copy());
if (inventory.getStack(outputStackSlot).isEmpty()) {
inventory.setStack(outputStackSlot, result.copy());
} else {
inventory.shrinkSlot(outputStackSlot, -result.getCount());
}

View file

@ -89,7 +89,7 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
ticksSinceLastChange++;
// Check cells input slot 2 time per second
if (!world.isClient && ticksSinceLastChange >= 10) {
if (!inventory.getInvStack(1).isEmpty()) {
if (!inventory.getStack(1).isEmpty()) {
FluidUtils.drainContainers(tank, inventory, 1, 6);
FluidUtils.fillContainers(tank, inventory, 1, 6, tank.getFluid());
}

View file

@ -89,7 +89,7 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
ticksSinceLastChange++;
// Check cells input slot 2 time per second
if (!world.isClient && ticksSinceLastChange >= 10) {
if (!inventory.getInvStack(1).isEmpty()) {
if (!inventory.getStack(1).isEmpty()) {
FluidUtils.drainContainers(tank, inventory, 1, 5);
FluidUtils.fillContainers(tank, inventory, 1, 5, tank.getFluidInstance().getFluid());
}

View file

@ -83,7 +83,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
@Nullable
public CraftingRecipe getCurrentRecipe() {
CraftingInventory crafting = getCraftingInventory();
if (!crafting.isInvEmpty()) {
if (!crafting.isEmpty()) {
if (lastRecipe != null) {
if (lastRecipe.matches(crafting, world)) {
return lastRecipe;
@ -108,7 +108,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
}, 3, 3);
}
for (int i = 0; i < 9; i++) {
inventoryCrafting.setInvStack(i, inventory.getInvStack(i));
inventoryCrafting.setStack(i, inventory.getStack(i));
}
return inventoryCrafting;
}
@ -118,7 +118,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
boolean missingOutput = false;
int[] stacksInSlots = new int[9];
for (int i = 0; i < 9; i++) {
stacksInSlots[i] = inventory.getInvStack(i).getCount();
stacksInSlots[i] = inventory.getStack(i).getCount();
}
DefaultedList<Ingredient> ingredients = recipe.getPreviewInputs();
@ -130,7 +130,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
if(checkedSlots.contains(i)) {
continue;
}
ItemStack stack = inventory.getInvStack(i);
ItemStack stack = inventory.getStack(i);
int requiredSize = locked ? 1 : 0;
if (stack.getMaxCount() == 1) {
requiredSize = 0;
@ -160,7 +160,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
}
boolean hasRoomForExtraItem(ItemStack stack) {
ItemStack extraOutputSlot = inventory.getInvStack(10);
ItemStack extraOutputSlot = inventory.getStack(10);
if (extraOutputSlot.isEmpty()) {
return true;
}
@ -168,7 +168,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
}
public boolean hasOutputSpace(ItemStack output, int slot) {
ItemStack stack = inventory.getInvStack(slot);
ItemStack stack = inventory.getStack(slot);
if (stack.isEmpty()) {
return true;
}
@ -188,34 +188,34 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
DefaultedList<Ingredient> ingredients = recipe.getPreviewInputs();
Ingredient ingredient = ingredients.get(i);
// Looks for the best slot to take it from
ItemStack bestSlot = inventory.getInvStack(i);
ItemStack bestSlot = inventory.getStack(i);
if (ingredient.test(bestSlot)) {
ItemStack remainderStack = getRemainderItem(bestSlot);
if(remainderStack.isEmpty()) {
bestSlot.decrement(1);
} else {
inventory.setInvStack(i, remainderStack);
inventory.setStack(i, remainderStack);
}
} else {
for (int j = 0; j < 9; j++) {
ItemStack stack = inventory.getInvStack(j);
ItemStack stack = inventory.getStack(j);
if (ingredient.test(stack)) {
ItemStack remainderStack = getRemainderItem(stack);
if(remainderStack.isEmpty()) {
stack.decrement(1);
} else {
inventory.setInvStack(j, remainderStack);
inventory.setStack(j, remainderStack);
}
break;
}
}
}
}
ItemStack output = inventory.getInvStack(9);
ItemStack output = inventory.getStack(9);
ItemStack outputStack = recipe.craft(getCraftingInventory());
if (output.isEmpty()) {
inventory.setInvStack(9, outputStack.copy());
inventory.setStack(9, outputStack.copy());
} else {
output.increment(recipe.getOutput().getCount());
}
@ -295,15 +295,15 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
if (world.isClient) {
return Optional.empty();
}
if (craftCache.isInvEmpty()) {
if (craftCache.isEmpty()) {
return Optional.empty();
}
balanceSlot++;
if (balanceSlot > craftCache.getInvSize()) {
if (balanceSlot > craftCache.size()) {
balanceSlot = 0;
}
//Find the best slot for each item in a recipe, and move it if needed
ItemStack sourceStack = inventory.getInvStack(balanceSlot);
ItemStack sourceStack = inventory.getStack(balanceSlot);
if (sourceStack.isEmpty()) {
return Optional.empty();
}
@ -313,7 +313,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
if(possibleSlots.contains(i)) {
continue;
}
ItemStack stackInSlot = inventory.getInvStack(i);
ItemStack stackInSlot = inventory.getStack(i);
Ingredient ingredient = currentRecipe.getPreviewInputs().get(s);
if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) {
if (stackInSlot.getItem() == sourceStack.getItem()) {
@ -327,7 +327,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
if(!possibleSlots.isEmpty()){
int totalItems = possibleSlots.stream()
.mapToInt(value -> inventory.getInvStack(value).getCount()).sum();
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
int slots = possibleSlots.size();
//This makes an array of ints with the best possible slot EnvTyperibution
@ -344,7 +344,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
}
List<Integer> slotEnvTyperubution = possibleSlots.stream()
.mapToInt(value -> inventory.getInvStack(value).getCount())
.mapToInt(value -> inventory.getStack(value).getCount())
.boxed().collect(Collectors.toList());
boolean needsBalance = false;
@ -367,7 +367,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
//Slot, count
Pair<Integer, Integer> bestSlot = null;
for (Integer slot : possibleSlots) {
ItemStack slotStack = inventory.getInvStack(slot);
ItemStack slotStack = inventory.getStack(slot);
if (slotStack.isEmpty()) {
bestSlot = Pair.of(slot, 0);
}
@ -380,12 +380,12 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
if (bestSlot == null
|| bestSlot.getLeft() == balanceSlot
|| bestSlot.getRight() == sourceStack.getCount()
|| inventory.getInvStack(bestSlot.getLeft()).isEmpty()
|| !ItemUtils.isItemEqual(sourceStack, inventory.getInvStack(bestSlot.getLeft()), true, true)) {
|| inventory.getStack(bestSlot.getLeft()).isEmpty()
|| !ItemUtils.isItemEqual(sourceStack, inventory.getStack(bestSlot.getLeft()), true, true)) {
return Optional.empty();
}
sourceStack.decrement(1);
inventory.getInvStack(bestSlot.getLeft()).increment(1);
inventory.getStack(bestSlot.getLeft()).increment(1);
inventory.setChanged();
return Optional.of(getCraftingInventory());

View file

@ -72,7 +72,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
}
private void updateCurrentRecipe() {
if (inventory.getInvStack(inputSlot).isEmpty()) {
if (inventory.getStack(inputSlot).isEmpty()) {
resetCrafter();
return;
}
@ -95,17 +95,17 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
if (recipeOutput.isEmpty()) {
return false;
}
if (inventory.getInvStack(slot).isEmpty()) {
if (inventory.getStack(slot).isEmpty()) {
return true;
}
if (ItemUtils.isItemEqual(inventory.getInvStack(slot), recipeOutput, true, true)) {
return recipeOutput.getCount() + inventory.getInvStack(slot).getCount() <= recipeOutput.getMaxCount();
if (ItemUtils.isItemEqual(inventory.getStack(slot), recipeOutput, true, true)) {
return recipeOutput.getCount() + inventory.getStack(slot).getCount() <= recipeOutput.getMaxCount();
}
return false;
}
public boolean canCraftAgain() {
if (inventory.getInvStack(inputSlot).isEmpty()) {
if (inventory.getStack(inputSlot).isEmpty()) {
return false;
}
if (currentRecipe == null) {
@ -139,7 +139,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
if (recipe == null) {
return false;
}
if (inventory.getInvStack(inputSlot).isEmpty()) {
if (inventory.getStack(inputSlot).isEmpty()) {
return false;
}
@ -153,16 +153,16 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
if (!canAcceptOutput(recipe, outputSlot)) {
return;
}
ItemStack outputStack = inventory.getInvStack(outputSlot);
ItemStack outputStack = inventory.getStack(outputSlot);
if (outputStack.isEmpty()) {
inventory.setInvStack(outputSlot, recipe.getOutput().copy());
inventory.setStack(outputSlot, recipe.getOutput().copy());
}
else {
// Just increment. We already checked stack match and stack size
outputStack.increment(1);
}
inventory.getInvStack(inputSlot).decrement(1);
inventory.getStack(inputSlot).decrement(1);
}
public int getProgressScaled(int scale) {

View file

@ -192,9 +192,9 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
}
private boolean insertIntoInv(int slot, ItemStack stack) {
ItemStack targetStack = inventory.getInvStack(slot);
ItemStack targetStack = inventory.getStack(slot);
if (targetStack.isEmpty()) {
inventory.setInvStack(slot, stack.copy());
inventory.setStack(slot, stack.copy());
stack.decrement(stack.getCount());
return true;
} else {

View file

@ -75,24 +75,24 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
final int randomchance = this.world.random.nextInt(chance);
if (randomchance == 1) {
if (inventory.getInvStack(1).isEmpty()) {
inventory.setInvStack(1, itemstack.copy());
if (inventory.getStack(1).isEmpty()) {
inventory.setStack(1, itemstack.copy());
}
else {
inventory.getInvStack(1).increment(itemstack.getCount());
inventory.getStack(1).increment(itemstack.getCount());
}
}
inventory.shrinkSlot(0, 1);
}
public boolean canRecycle() {
return !inventory.getInvStack(0) .isEmpty() && hasSlotGotSpace(1);
return !inventory.getStack(0) .isEmpty() && hasSlotGotSpace(1);
}
public boolean hasSlotGotSpace(int slot) {
if (inventory.getInvStack(slot).isEmpty()) {
if (inventory.getStack(slot).isEmpty()) {
return true;
} else if (inventory.getInvStack(slot).getCount() < inventory.getInvStack(slot).getMaxCount()) {
} else if (inventory.getStack(slot).getCount() < inventory.getStack(slot).getMaxCount()) {
return true;
}
return false;

View file

@ -131,16 +131,16 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
currentRecipeOutput = findMatchingRecipeOutput(craftMatrix, world);
if (!currentRecipeOutput.isEmpty()) {
boolean hasCrafted = false;
if (inventory.getInvStack(outputSlot).isEmpty()) {
inventory.setInvStack(outputSlot, currentRecipeOutput.copy());
if (inventory.getStack(outputSlot).isEmpty()) {
inventory.setStack(outputSlot, currentRecipeOutput.copy());
tickTime = 0;
hasCrafted = true;
} else {
if (inventory.getInvStack(outputSlot).getCount()
if (inventory.getStack(outputSlot).getCount()
+ currentRecipeOutput.getCount() <= currentRecipeOutput.getMaxCount()) {
final ItemStack stack = inventory.getInvStack(outputSlot);
final ItemStack stack = inventory.getStack(outputSlot);
stack.setCount(stack.getCount() + currentRecipeOutput.getCount());
inventory.setInvStack(outputSlot, stack);
inventory.setStack(outputSlot, stack);
tickTime = 0;
hasCrafted = true;
} else {
@ -148,7 +148,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
}
}
if (hasCrafted) {
for (int i = 0; i < craftMatrix.getInvSize(); i++) {
for (int i = 0; i < craftMatrix.size(); i++) {
inventory.shrinkSlot(i, 1);
}
currentRecipeOutput = ItemStack.EMPTY;
@ -198,21 +198,21 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
if (!locked) {
return Optional.empty();
}
if (craftCache.isInvEmpty()) {
if (craftCache.isEmpty()) {
return Optional.empty();
}
balanceSlot++;
if (balanceSlot > craftCache.getInvSize()) {
if (balanceSlot > craftCache.size()) {
balanceSlot = 0;
}
//Find the best slot for each item in a recipe, and move it if needed
ItemStack sourceStack = inventory.getInvStack(balanceSlot);
ItemStack sourceStack = inventory.getStack(balanceSlot);
if (sourceStack.isEmpty()) {
return Optional.empty();
}
List<Integer> possibleSlots = new ArrayList<>();
for (int s = 0; s < currentRecipe.getPreviewInputs().size(); s++) {
ItemStack stackInSlot = inventory.getInvStack(s);
ItemStack stackInSlot = inventory.getStack(s);
Ingredient ingredient = (Ingredient) currentRecipe.getPreviewInputs().get(s);
if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) {
if (stackInSlot.isEmpty()) {
@ -225,7 +225,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
if(!possibleSlots.isEmpty()){
int totalItems = possibleSlots.stream()
.mapToInt(value -> inventory.getInvStack(value).getCount()).sum();
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
int slots = possibleSlots.size();
//This makes an array of ints with the best possible slot EnvTyperibution
@ -242,7 +242,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
}
List<Integer> slotEnvTyperubution = possibleSlots.stream()
.mapToInt(value -> inventory.getInvStack(value).getCount())
.mapToInt(value -> inventory.getStack(value).getCount())
.boxed().collect(Collectors.toList());
boolean needsBalance = false;
@ -265,7 +265,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
//Slot, count
Pair<Integer, Integer> bestSlot = null;
for (Integer slot : possibleSlots) {
ItemStack slotStack = inventory.getInvStack(slot);
ItemStack slotStack = inventory.getStack(slot);
if (slotStack.isEmpty()) {
bestSlot = Pair.of(slot, 0);
}
@ -278,12 +278,12 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
if (bestSlot == null
|| bestSlot.getLeft() == balanceSlot
|| bestSlot.getRight() == sourceStack.getCount()
|| inventory.getInvStack(bestSlot.getLeft()).isEmpty()
|| !ItemUtils.isItemEqual(sourceStack, inventory.getInvStack(bestSlot.getLeft()), true, true)) {
|| inventory.getStack(bestSlot.getLeft()).isEmpty()
|| !ItemUtils.isItemEqual(sourceStack, inventory.getStack(bestSlot.getLeft()), true, true)) {
return Optional.empty();
}
sourceStack.decrement(1);
inventory.getInvStack(bestSlot.getLeft()).increment(1);
inventory.getStack(bestSlot.getLeft()).increment(1);
inventory.setChanged();
return Optional.of(getCraftingMatrix());
@ -295,7 +295,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
}
if (inventory.hasChanged()) {
for (int i = 0; i < 9; i++) {
craftCache.setInvStack(i, inventory.getInvStack(i).copy());
craftCache.setStack(i, inventory.getStack(i).copy());
}
inventory.resetChanged();
}
@ -305,8 +305,8 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
public boolean canMake(CraftingInventory craftMatrix) {
ItemStack stack = findMatchingRecipeOutput(craftMatrix, this.world);
if (locked) {
for (int i = 0; i < craftMatrix.getInvSize(); i++) {
ItemStack stack1 = craftMatrix.getInvStack(i);
for (int i = 0; i < craftMatrix.size(); i++) {
ItemStack stack1 = craftMatrix.getStack(i);
if (!stack1.isEmpty() && stack1.getCount() < 2) {
return false;
}
@ -315,7 +315,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
if (stack.isEmpty()) {
return false;
}
ItemStack output = inventory.getInvStack(outputSlot);
ItemStack output = inventory.getStack(outputSlot);
if (output.isEmpty()) {
return true;
}
@ -393,7 +393,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
.slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22)
.slot(3, 30, 40).slot(4, 48, 40).slot(5, 66, 40)
.slot(6, 30, 58).slot(7, 48, 58).slot(8, 66, 58)
.onCraft(inv -> this.inventory.setInvStack(1, findMatchingRecipeOutput(getCraftingMatrix(), this.world)))
.onCraft(inv -> this.inventory.setStack(1, findMatchingRecipeOutput(getCraftingMatrix(), this.world)))
.outputSlot(9, 124, 40)
.energySlot(10, 8, 70)
.syncEnergyValue().sync(this::getBurnTime, this::setBurnTime).sync(this::getLockedInt, this::setLockedInt).addInventory().create(this, syncID);

View file

@ -59,9 +59,9 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
}
private boolean spaceForOutput(int slot) {
return inventory.getInvStack(slot).isEmpty()
|| ItemUtils.isItemEqual(inventory.getInvStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)
&& inventory.getInvStack(slot).getCount() < 64;
return inventory.getStack(slot).isEmpty()
|| ItemUtils.isItemEqual(inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)
&& inventory.getStack(slot).getCount() < 64;
}
private void addOutputProducts() {
@ -74,11 +74,11 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
}
private void addOutputProducts(int slot) {
if (inventory.getInvStack(slot).isEmpty()) {
inventory.setInvStack(slot, TRContent.Parts.UU_MATTER.getStack());
if (inventory.getStack(slot).isEmpty()) {
inventory.setStack(slot, TRContent.Parts.UU_MATTER.getStack());
}
else if (ItemUtils.isItemEqual(this.inventory.getInvStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) {
inventory.getInvStack(slot).setCount((Math.min(64, 1 + inventory.getInvStack(slot).getCount())));
else if (ItemUtils.isItemEqual(this.inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) {
inventory.getStack(slot).setCount((Math.min(64, 1 + inventory.getStack(slot).getCount())));
}
}
@ -131,7 +131,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
this.charge(11);
for (int i = 0; i < 6; i++) {
final ItemStack stack = inventory.getInvStack(i);
final ItemStack stack = inventory.getStack(i);
if (!stack.isEmpty() && spaceForOutput()) {
final int amp = getValue(stack);
final int euNeeded = amp * TechRebornConfig.matterFabricatorEnergyPerAmp;

View file

@ -71,8 +71,8 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
if (world.isClient) {
return;
}
if (!inventory.getInvStack(0).isEmpty()) {
ItemStack stack = inventory.getInvStack(0);
if (!inventory.getStack(0).isEmpty()) {
ItemStack stack = inventory.getStack(0);
if (Energy.valid(stack)) {
Energy.of(this)
@ -80,7 +80,7 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
.move(tier.getMaxInput());
}
}
if (!inventory.getInvStack(1).isEmpty()) {
if (!inventory.getStack(1).isEmpty()) {
charge(1);
}
}

View file

@ -55,8 +55,8 @@ public class QuantumTankBlockEntity extends TankUnitBaseBlockEntity {
Tank tank = this.getTank();
ItemStack inputSlotStack = getInvStack(0).copy();
ItemStack outputSlotStack = getInvStack(1).copy();
ItemStack inputSlotStack = getStack(0).copy();
ItemStack outputSlotStack = getStack(1).copy();
inventory.clear();
world.setBlockState(pos, TRContent.TankUnit.QUANTUM.block.getDefaultState());
@ -65,7 +65,7 @@ public class QuantumTankBlockEntity extends TankUnitBaseBlockEntity {
tankEntity.setTank(tank);
tankEntity.setInvStack(0, inputSlotStack);
tankEntity.setInvStack(1, outputSlotStack);
tankEntity.setStack(0, inputSlotStack);
tankEntity.setStack(1, outputSlotStack);
}
}

View file

@ -51,7 +51,7 @@ public class DigitalChestBlockEntity extends StorageUnitBaseBlockEntity {
}
ItemStack storedStack = this.getAll();
ItemStack inputSlotStack = this.getInvStack(0).copy();
ItemStack inputSlotStack = this.getStack(0).copy();
this.clear();
@ -61,7 +61,7 @@ public class DigitalChestBlockEntity extends StorageUnitBaseBlockEntity {
if (!storedStack.isEmpty() && storageEntity != null) {
storageEntity.setStoredStack(storedStack);
storageEntity.setInvStack(0, inputSlotStack);
storageEntity.setStack(0, inputSlotStack);
}
}
}

View file

@ -52,7 +52,7 @@ public class QuantumChestBlockEntity extends StorageUnitBaseBlockEntity {
}
ItemStack storedStack = this.getAll();
ItemStack inputSlotStack = this.getInvStack(0).copy();
ItemStack inputSlotStack = this.getStack(0).copy();
this.clear();
@ -62,7 +62,7 @@ public class QuantumChestBlockEntity extends StorageUnitBaseBlockEntity {
if (!storedStack.isEmpty() && storageEntity != null) {
storageEntity.setStoredStack(storedStack);
storageEntity.setInvStack(0, inputSlotStack);
storageEntity.setStack(0, inputSlotStack);
}
}
}

View file

@ -104,14 +104,14 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
// If there is an item in the input AND stored is less than max capacity
if (!inventory.getInvStack(INPUT_SLOT).isEmpty() && !isFull()) {
inventory.setInvStack(INPUT_SLOT, processInput(inventory.getInvStack(INPUT_SLOT)));
if (!inventory.getStack(INPUT_SLOT).isEmpty() && !isFull()) {
inventory.setStack(INPUT_SLOT, processInput(inventory.getStack(INPUT_SLOT)));
shouldUpdate = true;
}
// Fill output slot with goodies when stored has items and output count is less than max stack size
if (storeItemStack.getCount() > 0 && inventory.getInvStack(OUTPUT_SLOT).getCount() < getStoredStack().getMaxCount()) {
if (storeItemStack.getCount() > 0 && inventory.getStack(OUTPUT_SLOT).getCount() < getStoredStack().getMaxCount()) {
populateOutput();
shouldUpdate = true;
@ -138,7 +138,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
// Set to storeItemStack to get the stack type
ItemStack output = storeItemStack.copy();
int outputSlotCount = inventory.getInvStack(OUTPUT_SLOT).getCount();
int outputSlotCount = inventory.getStack(OUTPUT_SLOT).getCount();
// Set to current outputSlot count
output.setCount(outputSlotCount);
@ -159,7 +159,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
storeItemStack = ItemStack.EMPTY;
}
inventory.setInvStack(OUTPUT_SLOT, output);
inventory.setStack(OUTPUT_SLOT, output);
}
private void addStoredItemCount(int amount) {
@ -167,7 +167,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
}
public ItemStack getStoredStack() {
return storeItemStack.isEmpty() ? inventory.getInvStack(OUTPUT_SLOT) : storeItemStack;
return storeItemStack.isEmpty() ? inventory.getStack(OUTPUT_SLOT) : storeItemStack;
}
public ItemStack getAll() {
@ -233,7 +233,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
storeItemStack = getStoredStack();
storeItemStack.setCount(maxCapacity);
inventory.setInvStack(OUTPUT_SLOT, ItemStack.EMPTY);
inventory.setStack(OUTPUT_SLOT, ItemStack.EMPTY);
}
public boolean isFull() {
@ -245,7 +245,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
}
public int getCurrentCapacity() {
return storeItemStack.getCount() + inventory.getInvStack(OUTPUT_SLOT).getCount();
return storeItemStack.getCount() + inventory.getStack(OUTPUT_SLOT).getCount();
}
public int getMaxCapacity() {
@ -383,10 +383,10 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
}
@Override
public boolean isValidInvStack(int slot, ItemStack stack) {
public boolean isValid(int slot, ItemStack stack) {
if (slot == INPUT_SLOT && !(isEmpty() || isSameType(stack))) {
return false;
}
return super.isValidInvStack(slot, stack);
return super.isValid(slot, stack);
}
}

View file

@ -66,10 +66,10 @@ public class StorageUnitBlock extends BlockMachineBase {
if (storageEntity != null && storageEntity.isSameType(stackInHand)) {
// Add item which is the same type (in users inventory) into storage
for (int i = 0; i < playerIn.inventory.getInvSize() && !storageEntity.isFull(); i++) {
ItemStack curStack = playerIn.inventory.getInvStack(i);
for (int i = 0; i < playerIn.inventory.size() && !storageEntity.isFull(); i++) {
ItemStack curStack = playerIn.inventory.getStack(i);
if (storageEntity.isSameType(curStack)) {
playerIn.inventory.setInvStack(i, storageEntity.processInput(curStack));
playerIn.inventory.setStack(i, storageEntity.processInput(curStack));
}
}

View file

@ -1,177 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 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.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.RebornCore;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import techreborn.blockentity.data.DataDrivenBEProvider;
import techreborn.blockentity.data.DataDrivenGui;
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
import techreborn.blockentity.generator.SolarPanelBlockEntity;
import techreborn.blockentity.generator.advanced.DieselGeneratorBlockEntity;
import techreborn.blockentity.generator.advanced.GasTurbineBlockEntity;
import techreborn.blockentity.generator.advanced.SemiFluidGeneratorBlockEntity;
import techreborn.blockentity.generator.advanced.ThermalGeneratorBlockEntity;
import techreborn.blockentity.generator.basic.SolidFuelGeneratorBlockEntity;
import techreborn.blockentity.machine.iron.IronAlloyFurnaceBlockEntity;
import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity;
import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity;
import techreborn.blockentity.machine.multiblock.*;
import techreborn.blockentity.machine.tier1.*;
import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity;
import techreborn.blockentity.machine.tier3.IndustrialCentrifugeBlockEntity;
import techreborn.blockentity.machine.tier3.MatterFabricatorBlockEntity;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.energy.HighVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.LowVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.MediumVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.idsu.InterdimensionalSUBlockEntity;
import techreborn.blockentity.storage.energy.lesu.LapotronicSUBlockEntity;
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.client.gui.*;
public class GuiHandler {
public static void register() {
EGui.stream().forEach(gui -> ContainerProviderRegistry.INSTANCE.registerFactory(gui.getID(), (syncID, identifier, playerEntity, packetByteBuf) -> {
final BlockEntity blockEntity = playerEntity.world.getBlockEntity(packetByteBuf.readBlockPos());
return ((BuiltScreenHandlerProvider) blockEntity).createScreenHandler(syncID, playerEntity);
}));
RebornCore.clientOnly(() -> () -> EGui.stream().forEach(gui -> ScreenProviderRegistry.INSTANCE.registerFactory(gui.getID(), (syncID, identifier, playerEntity, packetByteBuf) -> getClientGuiElement(EGui.byID(identifier), playerEntity, packetByteBuf.readBlockPos(), syncID))));
}
@Environment(EnvType.CLIENT)
private static HandledScreen<?> getClientGuiElement(final EGui gui, final PlayerEntity player, BlockPos pos, int syncID) {
final BlockEntity blockEntity = player.world.getBlockEntity(pos);
if (blockEntity instanceof DataDrivenBEProvider.DataDrivenBlockEntity) {
return new DataDrivenGui(syncID, player, (DataDrivenBEProvider.DataDrivenBlockEntity) blockEntity);
}
switch (gui) {
case AESU:
return new GuiAESU(syncID, player, (AdjustableSUBlockEntity) blockEntity);
case ALLOY_FURNACE:
return new GuiAlloyFurnace(syncID, player, (IronAlloyFurnaceBlockEntity) blockEntity);
case ALLOY_SMELTER:
return new GuiAlloySmelter(syncID, player, (AlloySmelterBlockEntity) blockEntity);
case ASSEMBLING_MACHINE:
return new GuiAssemblingMachine(syncID, player, (AssemblingMachineBlockEntity) blockEntity);
case LOW_VOLTAGE_SU:
return new GuiBatbox(syncID, player, (LowVoltageSUBlockEntity) blockEntity);
case BLAST_FURNACE:
return new GuiBlastFurnace(syncID, player, (IndustrialBlastFurnaceBlockEntity) blockEntity);
case CENTRIFUGE:
return new GuiCentrifuge(syncID, player, (IndustrialCentrifugeBlockEntity) blockEntity);
case CHARGEBENCH:
return new GuiChargeBench(syncID, player, (ChargeOMatBlockEntity) blockEntity);
case CHEMICAL_REACTOR:
return new GuiChemicalReactor(syncID, player, (ChemicalReactorBlockEntity) blockEntity);
case CHUNK_LOADER:
return new GuiChunkLoader(syncID, player, (ChunkLoaderBlockEntity) blockEntity);
case COMPRESSOR:
return new GuiCompressor(syncID, player, (CompressorBlockEntity) blockEntity);
case DIESEL_GENERATOR:
return new GuiDieselGenerator(syncID, player, (DieselGeneratorBlockEntity) blockEntity);
case ELECTRIC_FURNACE:
return new GuiElectricFurnace(syncID, player, (ElectricFurnaceBlockEntity) blockEntity);
case EXTRACTOR:
return new GuiExtractor(syncID, player, (ExtractorBlockEntity) blockEntity);
case FUSION_CONTROLLER:
return new GuiFusionReactor(syncID, player, (FusionControlComputerBlockEntity) blockEntity);
case GAS_TURBINE:
return new GuiGasTurbine(syncID, player, (GasTurbineBlockEntity) blockEntity);
case GENERATOR:
return new GuiGenerator(syncID, player, (SolidFuelGeneratorBlockEntity) blockEntity);
case IDSU:
return new GuiIDSU(syncID, player, (InterdimensionalSUBlockEntity) blockEntity);
case IMPLOSION_COMPRESSOR:
return new GuiImplosionCompressor(syncID, player, (ImplosionCompressorBlockEntity) blockEntity);
case INDUSTRIAL_ELECTROLYZER:
return new GuiIndustrialElectrolyzer(syncID, player, (IndustrialElectrolyzerBlockEntity) blockEntity);
case INDUSTRIAL_GRINDER:
return new GuiIndustrialGrinder(syncID, player, (IndustrialGrinderBlockEntity) blockEntity);
case IRON_FURNACE:
return new GuiIronFurnace(syncID, player, (IronFurnaceBlockEntity) blockEntity);
case LESU:
return new GuiLESU(syncID, player, (LapotronicSUBlockEntity) blockEntity);
case MATTER_FABRICATOR:
return new GuiMatterFabricator(syncID, player, (MatterFabricatorBlockEntity) blockEntity);
case MEDIUM_VOLTAGE_SU:
return new GuiMFE(syncID, player, (MediumVoltageSUBlockEntity) blockEntity);
case HIGH_VOLTAGE_SU:
return new GuiMFSU(syncID, player, (HighVoltageSUBlockEntity) blockEntity);
case STORAGE_UNIT:
return new GuiStorageUnit(syncID, player, (StorageUnitBaseBlockEntity) blockEntity);
case TANK_UNIT:
return new GuiTankUnit(syncID, player, (TankUnitBaseBlockEntity) blockEntity);
case RECYCLER:
return new GuiRecycler(syncID, player, (RecyclerBlockEntity) blockEntity);
case ROLLING_MACHINE:
return new GuiRollingMachine(syncID, player, (RollingMachineBlockEntity) blockEntity);
case SAWMILL:
return new GuiIndustrialSawmill(syncID, player, (IndustrialSawmillBlockEntity) blockEntity);
case SCRAPBOXINATOR:
return new GuiScrapboxinator(syncID, player, (ScrapboxinatorBlockEntity) blockEntity);
case SOLAR_PANEL:
return new GuiSolar(syncID, player, (SolarPanelBlockEntity) blockEntity);
case SEMIFLUID_GENERATOR:
return new GuiSemifluidGenerator(syncID, player, (SemiFluidGeneratorBlockEntity) blockEntity);
case THERMAL_GENERATOR:
return new GuiThermalGenerator(syncID, player, (ThermalGeneratorBlockEntity) blockEntity);
case VACUUM_FREEZER:
return new GuiVacuumFreezer(syncID, player, (VacuumFreezerBlockEntity) blockEntity);
case AUTO_CRAFTING_TABLE:
return new GuiAutoCrafting(syncID, player, (AutoCraftingTableBlockEntity) blockEntity);
case PLASMA_GENERATOR:
return new GuiPlasmaGenerator(syncID, player, (PlasmaGeneratorBlockEntity) blockEntity);
case DISTILLATION_TOWER:
return new GuiDistillationTower(syncID, player, (DistillationTowerBlockEntity) blockEntity);
case FLUID_REPLICATOR:
return new GuiFluidReplicator(syncID, player, (FluidReplicatorBlockEntity) blockEntity);
case SOLID_CANNING_MACHINE:
return new GuiSolidCanningMachine(syncID, player, (SoildCanningMachineBlockEntity) blockEntity);
case WIRE_MILL:
return new GuiWireMill(syncID, player, (WireMillBlockEntity) blockEntity);
case GREENHOUSE_CONTROLLER:
return new GuiGreenhouseController(syncID, player, (GreenhouseControllerBlockEntity) blockEntity);
default:
break;
}
return null;
}
}

View file

@ -6,15 +6,16 @@ import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
import net.fabricmc.fabric.api.container.ContainerFactory;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.RebornCore;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.client.containerBuilder.IContainerProvider;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
import techreborn.blockentity.data.DataDrivenBEProvider;
import techreborn.blockentity.data.DataDrivenGui;
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
@ -195,7 +196,7 @@ public final class GuiType<T extends BlockEntity> implements IMachineGuiHandler
private void register() {
ContainerProviderRegistry.INSTANCE.registerFactory(identifier, (syncID, identifier, playerEntity, packetByteBuf) -> {
final BlockEntity blockEntity = playerEntity.world.getBlockEntity(packetByteBuf.readBlockPos());
return ((IContainerProvider) blockEntity).createContainer(syncID, playerEntity);
return ((BuiltScreenHandlerProvider) blockEntity).createScreenHandler(syncID, playerEntity);
});
RebornCore.clientOnly(() -> () -> ScreenProviderRegistry.INSTANCE.registerFactory(identifier, getFactory()));
}
@ -205,11 +206,11 @@ public final class GuiType<T extends BlockEntity> implements IMachineGuiHandler
}
@Environment(EnvType.CLIENT)
public interface GuiFactory<T extends BlockEntity> extends ContainerFactory<ContainerScreen> {
ContainerScreen<?> create(int syncId, PlayerEntity playerEntity, T blockEntity);
public interface GuiFactory<T extends BlockEntity> extends ContainerFactory<HandledScreen> {
HandledScreen<?> create(int syncId, PlayerEntity playerEntity, T blockEntity);
@Override
default ContainerScreen create(int syncId, Identifier identifier, PlayerEntity playerEntity, PacketByteBuf packetByteBuf) {
default HandledScreen create(int syncId, Identifier identifier, PlayerEntity playerEntity, PacketByteBuf packetByteBuf) {
//noinspection unchecked
T blockEntity = (T) playerEntity.world.getBlockEntity(packetByteBuf.readBlockPos());
return create(syncId, playerEntity, blockEntity);

View file

@ -45,7 +45,7 @@ public class NukeRenderer extends EntityRenderer<EntityNukePrimed> {
public NukeRenderer(EntityRenderDispatcher renderManager) {
super(renderManager);
this.shadowSize = 0.5F;
this.shadowRadius = 0.5F;
}
@Nullable

View file

@ -68,10 +68,10 @@ public class BatpackItem extends ArmorItem implements EnergyHolder, ItemDurabili
return;
}
for (int i = 0; i < player.inventory.getInvSize(); i++) {
if (Energy.valid(player.inventory.getInvStack(i))) {
for (int i = 0; i < player.inventory.size(); i++) {
if (Energy.valid(player.inventory.getStack(i))) {
Energy.of(itemStack)
.into(Energy.of(player.inventory.getInvStack(i)))
.into(Energy.of(player.inventory.getStack(i)))
.move(maxOutput);
}
}

View file

@ -25,10 +25,12 @@
package techreborn.items.armor;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.effect.StatusEffectInstance;
@ -65,18 +67,18 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
}
@Override
public void getAttributeModifiers(EquipmentSlot equipmentSlot, ItemStack stack, Multimap<String, EntityAttributeModifier> attributes) {
attributes.removeAll(EntityAttributes.MOVEMENT_SPEED.getId());
public void getAttributeModifiers(EquipmentSlot equipmentSlot, ItemStack stack, Multimap<EntityAttribute, EntityAttributeModifier> attributes) {
attributes.removeAll(EntityAttributes.GENERIC_MOVEMENT_SPEED);
if (this.slot == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS) {
if (Energy.of(stack).getEnergy() > sprintingCost) {
attributes.put(EntityAttributes.MOVEMENT_SPEED.getId(), new EntityAttributeModifier(MODIFIERS[equipmentSlot.getEntitySlotId()], "Movement Speed", 0.15, EntityAttributeModifier.Operation.ADDITION));
attributes.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(MODIFIERS[equipmentSlot.getEntitySlotId()], "Movement Speed", 0.15, EntityAttributeModifier.Operation.ADDITION));
}
}
if (equipmentSlot == this.slot && Energy.of(stack).getEnergy() > 0) {
attributes.put(EntityAttributes.ARMOR.getId(), new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Armor modifier", 20, EntityAttributeModifier.Operation.ADDITION));
attributes.put(EntityAttributes.KNOCKBACK_RESISTANCE.getId(), new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Knockback modifier", 2, EntityAttributeModifier.Operation.ADDITION));
attributes.put(EntityAttributes.GENERIC_ARMOR, new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Armor modifier", 20, EntityAttributeModifier.Operation.ADDITION));
attributes.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Knockback modifier", 2, EntityAttributeModifier.Operation.ADDITION));
}
}
@ -123,7 +125,7 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers,
}
@Override
public Multimap<String, EntityAttributeModifier> getModifiers(EquipmentSlot slot) {
public Multimap<EntityAttribute, EntityAttributeModifier> getModifiers(EquipmentSlot slot) {
return HashMultimap.create();
}

View file

@ -24,6 +24,7 @@
package techreborn.items.tool.industrial;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@ -31,6 +32,7 @@ import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.player.PlayerEntity;
@ -176,13 +178,13 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
// ItemStackModifiers
@Override
public void getAttributeModifiers(EquipmentSlot slot, ItemStack stack, Multimap<String, EntityAttributeModifier> attributes) {
attributes.removeAll(EntityAttributes.ATTACK_DAMAGE.getId());
attributes.removeAll(EntityAttributes.ATTACK_SPEED.getId());
public void getAttributeModifiers(EquipmentSlot slot, ItemStack stack, Multimap<EntityAttribute, EntityAttributeModifier> attributes) {
attributes.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE);
attributes.removeAll(EntityAttributes.GENERIC_ATTACK_SPEED);
if (slot== EquipmentSlot.MAINHAND && ItemUtils.isActive(stack)) {
attributes.put(EntityAttributes.ATTACK_DAMAGE.getId(), new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_UUID, "Weapon modifier", TechRebornConfig.nanosaberDamage, EntityAttributeModifier.Operation.ADDITION));
attributes.put(EntityAttributes.ATTACK_SPEED.getId(), new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_UUID, "Weapon modifier", 3, EntityAttributeModifier.Operation.ADDITION));
attributes.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_UUID, "Weapon modifier", TechRebornConfig.nanosaberDamage, EntityAttributeModifier.Operation.ADDITION));
attributes.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_UUID, "Weapon modifier", 3, EntityAttributeModifier.Operation.ADDITION));
}
}
}

View file

@ -115,10 +115,10 @@ public class ServerboundPackets {
}
context.getTaskQueue().execute(() -> {
PlayerEntity playerMP = context.getPlayer();
for (int i = 0; i < playerMP.inventory.getInvSize(); i++) {
ItemStack stack = playerMP.inventory.getInvStack(i);
for (int i = 0; i < playerMP.inventory.size(); i++) {
ItemStack stack = playerMP.inventory.getStack(i);
if (stack.getItem() == TRContent.MANUAL) {
playerMP.inventory.removeInvStack(i);
playerMP.inventory.removeStack(i);
playerMP.inventory.insertStack(new ItemStack(Items.BOOK));
playerMP.inventory.insertStack(TRContent.Ingots.REFINED_IRON.getStack());
return;

View file

@ -56,8 +56,8 @@ public class FluidUtils {
}
public static boolean drainContainers(GenericFluidContainer<Direction> target, Inventory inventory, int inputSlot, int outputSlot) {
ItemStack inputStack = inventory.getInvStack(inputSlot);
ItemStack outputStack = inventory.getInvStack(outputSlot);
ItemStack inputStack = inventory.getStack(inputSlot);
ItemStack outputStack = inventory.getStack(outputSlot);
if(!(inputStack.getItem() instanceof ItemFluidInfo)) return false;
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
@ -82,7 +82,7 @@ public class FluidUtils {
targetFluidInstance.addAmount(FluidValue.BUCKET);
if(outputStack.isEmpty()){
inventory.setInvStack(outputSlot, itemFluidInfo.getEmpty());
inventory.setStack(outputSlot, itemFluidInfo.getEmpty());
} else {
outputStack.increment(1);
}
@ -93,8 +93,8 @@ public class FluidUtils {
}
public static boolean fillContainers(GenericFluidContainer<Direction> source, Inventory inventory, int inputSlot, int outputSlot, Fluid fluidToFill) {
ItemStack inputStack = inventory.getInvStack(inputSlot);
ItemStack outputStack = inventory.getInvStack(outputSlot);
ItemStack inputStack = inventory.getStack(inputSlot);
ItemStack outputStack = inventory.getStack(outputSlot);
if(!(inputStack.getItem() instanceof ItemFluidInfo)) return false;
if (!FluidUtils.isContainerEmpty(inputStack)) return false;
@ -119,7 +119,7 @@ public class FluidUtils {
}
if(outputStack.isEmpty()){
inventory.setInvStack(outputSlot, itemFluidInfo.getFull(sourceFluid.getFluid()));
inventory.setStack(outputSlot, itemFluidInfo.getFull(sourceFluid.getFluid()));
} else {
outputStack.increment(1);
}

View file

@ -50,8 +50,8 @@ public final class PoweredCraftingHandler implements ItemCraftCallback {
@Override
public void onCraft(ItemStack stack, CraftingInventory craftingInventory, PlayerEntity playerEntity) {
if (Energy.valid(stack)) {
double totalEnergy = IntStream.range(0, craftingInventory.getInvSize())
.mapToObj(craftingInventory::getInvStack)
double totalEnergy = IntStream.range(0, craftingInventory.size())
.mapToObj(craftingInventory::getStack)
.filter(s -> !s.isEmpty())
.filter(Energy::valid)
.mapToDouble(s -> Energy.of(s).getEnergy())
@ -64,8 +64,8 @@ public final class PoweredCraftingHandler implements ItemCraftCallback {
return;
}
Map<Enchantment, Integer> map = Maps.newLinkedHashMap();
for (int i = 0; i < craftingInventory.getInvSize(); i++){
ItemStack ingredient = craftingInventory.getInvStack(i);
for (int i = 0; i < craftingInventory.size(); i++){
ItemStack ingredient = craftingInventory.getStack(i);
if (ingredient.isEmpty()){
continue;
}

View file

@ -24,6 +24,7 @@
package techreborn.world;
import com.google.common.collect.ImmutableList;
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
import net.minecraft.block.Blocks;
import net.minecraft.util.Identifier;
@ -32,6 +33,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.Category;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.BeehiveTreeDecorator;
import net.minecraft.world.gen.decorator.CountExtraChanceDecoratorConfig;
import net.minecraft.world.gen.decorator.Decorator;
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
@ -42,6 +44,7 @@ import net.minecraft.world.gen.feature.OreFeatureConfig.Target;
import net.minecraft.world.gen.foliage.BlobFoliagePlacer;
import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider;
import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider;
import net.minecraft.world.gen.trunk.StraightTrunkPlacer;
import reborncore.common.world.CustomOreFeature;
import reborncore.common.world.CustomOreFeatureConfig;
import techreborn.blocks.misc.BlockRubberLog;
@ -92,13 +95,10 @@ public class WorldGenerator {
RUBBER_TREE_CONFIG = new BranchedTreeFeatureConfig.Builder(
logProvider,
new SimpleBlockStateProvider(TRContent.RUBBER_LEAVES.getDefaultState()),
new BlobFoliagePlacer(2, 0))
.baseHeight(TechRebornConfig.RubberTreeBaseHeight)
.heightRandA(2)
.foliageHeight(3)
new BlobFoliagePlacer(2, 0, 0, 0, 3),
new StraightTrunkPlacer(TechRebornConfig.RubberTreeBaseHeight, 3, 0))
.noVines()
.build();
}
private static void addToBiome(Biome biome){