Skip to content

Commit fc6c862

Browse files
committed
things and stuff
1 parent 9da461a commit fc6c862

14 files changed

Lines changed: 51 additions & 81 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mod_name=Productive Lib
2929
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3030
mod_license=All Rights Reserved
3131
# The mod version. See https://semver.org/
32-
mod_version=1.21.0-0.1.17
32+
mod_version=1.21.0-0.1.24
3333
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
3434
# This should match the base package used for the mod sources.
3535
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

src/main/java/cy/jdkdigital/productivelib/common/block/entity/IUpgradeableBlockEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ default int getUpgradeCount(Item item) {
2424
if (handler != null) {
2525
for (int slot = 0; slot < handler.getSlots(); ++slot) {
2626
ItemStack stack = handler.getStackInSlot(slot);
27-
if (stack.getItem().equals(item)) {
27+
if (stack.is(item)) {
2828
numberOfUpgrades.getAndIncrement();
2929
}
3030
}
@@ -37,7 +37,7 @@ default List<ItemStack> getInstalledUpgrades(@Nullable Item upgradeItem) {
3737
IItemHandler handler = getUpgradeHandler();
3838
if (handler != null) {
3939
for (int slot = 0; slot < handler.getSlots(); ++slot) {
40-
if (upgradeItem == null || handler.getStackInSlot(slot).getItem().equals(upgradeItem)) {
40+
if (upgradeItem == null || handler.getStackInSlot(slot).is(upgradeItem)) {
4141
upgrades.add(handler.getStackInSlot(slot));
4242
}
4343
}

src/main/java/cy/jdkdigital/productivelib/common/block/entity/InventoryHandlerHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import javax.annotation.Nonnull;
99
import javax.annotation.Nullable;
1010

11+
import cy.jdkdigital.productivelib.ProductiveLib;
1112
import cy.jdkdigital.productivelib.common.item.AbstractUpgradeItem;
1213
import cy.jdkdigital.productivelib.event.CollectValidUpgradesEvent;
1314
import net.minecraft.core.HolderLookup;
@@ -210,7 +211,7 @@ public boolean canFitStacks(List<ItemStack> stacks) {
210211
List<Integer> usedSlots = new ArrayList<>();
211212
for (ItemStack stack : stacks) {
212213
int slot = getAvailableOutputSlot(this, stack, usedSlots);
213-
if (slot == 0) {
214+
if (slot < 0) {
214215
return false;
215216
}
216217
}

src/main/java/cy/jdkdigital/productivelib/common/item/AbstractUpgradeItem.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public InteractionResult useOn(UseOnContext context) {
3030
if (handler instanceof InventoryHandlerHelper.UpgradeHandler upgradeHandler && upgradeHandler.isValidUpgrade(context.getItemInHand())) {
3131
for (int slot = 0; slot < handler.getSlots(); ++slot) {
3232
if (handler.getStackInSlot(slot).equals(ItemStack.EMPTY)) {
33-
handler.insertItem(slot, new ItemStack(context.getItemInHand().getItem()), false);
33+
var upgradeStack = context.getItemInHand().copy();
34+
upgradeStack.setCount(1);
35+
handler.insertItem(slot, upgradeStack, false);
3436
hasInsertedUpgrade.set(true);
3537
break;
3638
}

src/main/java/cy/jdkdigital/productivelib/event/ClientModEventHandler.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/main/java/cy/jdkdigital/productivelib/registry/LibItems.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class LibItems
2626
public static final DeferredHolder<Item, ? extends Item> UPGRADE_ANTI_TELEPORT = createItem("upgrade_anti_teleport", () -> new UpgradeItem((new Item.Properties())));
2727
public static final DeferredHolder<Item, ? extends Item> UPGRADE_BLOCK = createItem("upgrade_block", () -> new UpgradeItem((new Item.Properties())));
2828
public static final DeferredHolder<Item, ? extends Item> UPGRADE_STABILITY = createItem("upgrade_stability", () -> new UpgradeItem((new Item.Properties())));
29+
public static final DeferredHolder<Item, ? extends Item> UPGRADE_POLLEN_SIEVE = createItem("upgrade_pollen_sieve", () -> new UpgradeItem((new Item.Properties())));
2930

3031
public static <I extends Item> DeferredHolder<Item, I> createItem(String name, Supplier<? extends I> supplier) {
3132
return ProductiveLib.ITEMS.register(name, supplier);

src/main/java/cy/jdkdigital/productivelib/util/ColorUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,13 @@ public static int blend(int a, int b, float f) {
9191

9292
return A << 24 | R << 16 | G << 8 | B;
9393
}
94+
95+
public static int darkenColor(int color, float ratio){
96+
int a = (color >> 24) & 0xFF;
97+
int r = (int) (((color >> 16) & 0xFF) * ratio);
98+
int g = (int) (((color >> 8) & 0xFF) * ratio);
99+
int b = (int) ((color & 0xFF) * ratio);
100+
101+
return (a << 24) | (r << 16) | (g << 8) | b;
102+
}
94103
}

src/main/java/cy/jdkdigital/productivelib/util/LangUtil.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ public class LangUtil
1414
put("Peach", "Peaches");
1515
put("Copoazu", "Copoazu");
1616
put("Cempedak", "Cempedak");
17+
put("Potatos", "Potatoes");
18+
put("Kadsura", "Kadsura");
19+
put("Blackberry", "Blackberries");
20+
put("Blueberry", "Blueberries");
21+
put("Boysenberry", "Boysenberries");
22+
put("Cloudberry", "Cloudberries");
23+
put("Cranberry", "Cranberries");
24+
put("Golden Raspberry", "Golden Raspberries");
25+
put("Gooseberry", "Gooseberries");
26+
put("Huckleberry", "Huckleberries");
27+
put("Lingoberry", "Lingoberries");
28+
put("Miracle Berry", "Miracle Berries");
29+
put("Raspberry", "Raspberries");
30+
put("Thimbleberry", "Thimbleberries");
31+
put("Thimbleberry", "Thimbleberries");
1732
}};
1833

1934
public static String capName(String name) {

src/main/java/cy/jdkdigital/productivelib/util/MultiBlockDetector.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ public static MultiBlockData detectStructure(Level level, BlockPos controllerPos
6262
while (height < maxHeight && !level.getBlockState(bottomCornerRelativePosition.move(Direction.DOWN)).is(bottomBlocks)) {
6363
height++;
6464
}
65+
height++;
6566

6667
if (!level.getBlockState(bottomCornerRelativePosition).is(bottomBlocks)) {
67-
throw new InvalidStructureException("Invalid bottom starting block", topCorners.getFirst().relative(controllerFacing.getOpposite()).relative(controllerFacing.getCounterClockWise()).mutable());
68+
throw new InvalidStructureException("Invalid or missing bottom starting block. Valid blocks are " + bottomBlocks, topCorners.getFirst().relative(controllerFacing.getOpposite()).relative(controllerFacing.getCounterClockWise()).mutable());
6869
}
6970

7071
// validate bottom
@@ -76,7 +77,7 @@ public static MultiBlockData detectStructure(Level level, BlockPos controllerPos
7677
return uniformBottom ? !level.getBlockState(pos).is(firstBottomBlock.get().getBlock()) : !level.getBlockState(pos).is(bottomBlocks);
7778
}).toList();
7879
if (!notBottomBlocks.isEmpty()) {
79-
throw new InvalidStructureException("Invalid bottom block", notBottomBlocks.getFirst());
80+
throw new InvalidStructureException("Invalid or missing bottom block." + (uniformBottom ? "All bottom blocks must be of the same type." : ""), notBottomBlocks.getFirst());
8081
}
8182
} else {
8283
// check how far the wall under the controller continues
@@ -95,18 +96,21 @@ public static MultiBlockData detectStructure(Level level, BlockPos controllerPos
9596

9697
// validate each ring between top and bottom
9798
for (int i = 1; i <= height; i++) {
98-
// skip validating lowest ring if corners can be empty
99-
if (optionalCorners && i == height) continue;
99+
// skip validating lowest ring if corners can be empty and there's no wall block in the start position
100+
if (optionalCorners && i == height && !level.getBlockState(top.below(i)).is(wallBlocks)) continue;
100101
findStructureSliceCorners(level, controllerPos, controllerFacing.getClockWise(), top.below(i), wallBlocks, optionalCorners, maxCirc, peripherals);
101102
}
102103

103-
int volume = (int) BlockPos.betweenClosedStream(topCorners.getFirst().relative(controllerFacing.getOpposite()).relative(controllerFacing.getCounterClockWise()), topCorners.getSecond().relative(controllerFacing).relative(controllerFacing.getClockWise()).below(height)).count();
104+
int volume = (int) BlockPos.betweenClosedStream(topCorners.getFirst().relative(controllerFacing.getOpposite()).relative(controllerFacing.getCounterClockWise()), topCorners.getSecond().relative(controllerFacing).relative(controllerFacing.getClockWise()).below(height - 1)).count();
104105
if (volume > maxVolume) {
105106
throw new InvalidStructureException("Internal structure area is too big " + volume + "/" + maxVolume, controllerPos);
106107
}
107108

108109
if (hollow) {
109-
List<BlockPos> notAirBlocks = BlockPos.betweenClosedStream(topCorners.getFirst().relative(controllerFacing.getOpposite()).relative(controllerFacing.getCounterClockWise()), topCorners.getSecond().relative(controllerFacing).relative(controllerFacing.getClockWise()).below(height)).filter(pos -> !level.getBlockState(pos).isAir()).toList();
110+
List<BlockPos> notAirBlocks = BlockPos.betweenClosedStream(
111+
topCorners.getFirst().relative(controllerFacing.getOpposite()).relative(controllerFacing.getCounterClockWise()),
112+
topCorners.getSecond().relative(controllerFacing).relative(controllerFacing.getClockWise()).below(height - 1)
113+
).filter(pos -> !level.getBlockState(pos).isAir()).toList();
110114
if (!notAirBlocks.isEmpty()) {
111115
throw new InvalidStructureException("Internal structure area is not clear", notAirBlocks.getFirst());
112116
}

src/main/resources/META-INF/neoforge.mods.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ license="${mod_license}"
1818
file="META-INF/accesstransformer.cfg"
1919

2020
[[mixins]]
21-
config="productivelib.mixin.json"
21+
config="${mod_id}.mixin.json"
2222

2323
[[mods]]
2424
modId="${mod_id}"

0 commit comments

Comments
 (0)