Skip to content

Commit

Permalink
Merge branch 'architectury-1.17.1' into architectury-1.18.1
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Nov 1, 2023
2 parents 14b52d4 + 8c231b6 commit bff3af1
Show file tree
Hide file tree
Showing 29 changed files with 204 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.unlikepaladin.pfm.runtime.PFMDataGen;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.texture.MissingSprite;
import net.minecraft.data.client.model.Texture;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourceType;
Expand Down Expand Up @@ -201,6 +200,8 @@ public static Identifier getPlankId(Block block) {
Identifier id4 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "_planks");
Identifier id5 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "plankstext");
Identifier id6 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "plankretext");
Identifier id7 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "_planks0");
Identifier id8 = new Identifier(namespace, "block/" + path.replace("planks_", "") + "_planks1");

if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES))
return id;
Expand All @@ -214,6 +215,10 @@ else if (idExists(id5, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES))
return id5;
else if (idExists(id6, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES))
return id6;
else if (idExists(id7, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES))
return id7;
else if (idExists(id8, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES))
return id8;
else
return new Identifier(namespace, "block/wood/" + path+ "_0");
}
Expand Down Expand Up @@ -270,8 +275,7 @@ public static Identifier getLogId(Block block, String postFix) {
}
String loc = identifier.getPath().contains("stripped") || identifier.getPath().contains("striped") ? "stripped_log" : "log";
path = path.replace("striped_", "").replace(postFix, "").replace("_log", "");
if (!identifier.getPath().contains("stripped") && namespace.equals("byg"))
System.out.println("paused");

id = new Identifier(namespace, "block/" + path+ "/" + loc + postFix);
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
Expand All @@ -280,6 +284,14 @@ public static Identifier getLogId(Block block, String postFix) {
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
id = new Identifier(namespace, "block/" + path+ "/" + loc + "/" + postFix.replace("_", ""));
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
id = new Identifier(namespace, "block/" + path+ "/" + loc.replace("log", "stem") + "/" + postFix.replace("_", ""));
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
id = new Identifier(namespace, "block/" + path+ "/" + loc);
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
Expand All @@ -288,6 +300,22 @@ public static Identifier getLogId(Block block, String postFix) {
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
id = new Identifier(namespace, "block/stripped_" + path+ "_log");
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
id = new Identifier(namespace, "block/stripped_" + path+ "_stem");
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
id = new Identifier(namespace, "block/" + path+ "_log_stripped");
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
id = new Identifier(namespace, "block/" + path+ "_stem_stripped");
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
} else if (path.contains("reed")) {
path = path.replace("nether_", "").replace("reed", "reeds");
Identifier id = new Identifier(namespace, "block/" + path);
Expand All @@ -304,8 +332,8 @@ public static Identifier getLogId(Block block, String postFix) {
return id;
}
}
if (path.contains("alpha_")) {
path = path.replace("alpha", "alpha_oak");
if (path.contains("alpha_") && namespace.contains("regions")) {
path = !path.contains("alpha_oak") ? path.replace("alpha", "alpha_oak") : path;
Identifier id = new Identifier(namespace, "block/" + path);
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)){
return id;
Expand All @@ -315,6 +343,10 @@ public static Identifier getLogId(Block block, String postFix) {
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
id = new Identifier(namespace, "block/alpha_oak_log" + postFix);
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
}
return new Identifier(namespace, "block/" + path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected void drawMouseoverTooltip(MatrixStack matrices, int x, int y) {
int itemCount = 0;
Style style = Style.EMPTY.withColor(Formatting.GRAY);
for (ItemStack stack1 : handler.getPlayerInventory().main) {
if (stack1.isItemEqual(item.getDefaultStack())) {
if (stack1.isOf(item)) {
itemCount += stack1.getCount();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
import java.util.Optional;

public class PFMImmersivePortals implements PFMModCompatibility {
private final PFMClientModCompatibility clientModCompatibility;
private PFMClientModCompatibility clientModCompatibility;
public PFMImmersivePortals(){
clientModCompatibility = new PFMImmersivePortalsClient(this);
}
public static final EntityType<PFMMirrorEntity> MIRROR = EntityType.Builder.create(PFMMirrorEntity::new, SpawnGroup.MISC).setDimensions(0.0F, 0.0F).makeFireImmune().disableSummon().build("mirror_entity");

Expand All @@ -39,6 +38,8 @@ public String getModId() {

@Override
public Optional<PFMClientModCompatibility> getClientModCompatiblity() {
if (clientModCompatibility == null)
clientModCompatibility = new PFMImmersivePortalsClient(this);
return Optional.of(clientModCompatibility);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ boolean craft() {
List<Ingredient> ingredients = furnitureRecipe.getIngredients();
for (Ingredient ingredient : ingredients) {
for (ItemStack stack : ingredient.getMatchingStacks()) {
if (playerInventory.indexOf(stack) != -1) {
int indexOfStack = playerInventory.indexOf(stack);
if (FurnitureRecipe.getSlotWithStackIgnoreNBT(playerInventory, stack) != -1) {
int indexOfStack = FurnitureRecipe.getSlotWithStackIgnoreNBT(playerInventory, stack);
if (playerInventory.getStack(indexOfStack).getCount() >= stack.getCount()) {
ItemStack stack1 = playerInventory.getStack(indexOfStack);
stack1.decrement(stack.getCount());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.unlikepaladin.pfm.recipes;

import com.google.gson.*;
import com.mojang.datafixers.DataFixUtils;
import com.mojang.datafixers.DataFixerUpper;
import com.mojang.serialization.JsonOps;
import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems;
import com.unlikepaladin.pfm.registry.RecipeTypes;
Expand All @@ -13,7 +11,6 @@
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.NbtString;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.recipe.*;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -47,27 +44,30 @@ public DefaultedList<Ingredient> getIngredients() {
public boolean matches(PlayerInventory playerInventory, World world) {
List<Ingredient> ingredients = this.getIngredients();
BitSet hasIngredients = new BitSet(ingredients.size());
if (this.output.getItem().equals(PaladinFurnitureModBlocksItems.GLASS_MODERN_PENDANT.asItem())) {
System.out.println("wtf");
}
HashMap<Item, Integer> containedItems = new HashMap<>();
for (int i = 0; i < ingredients.size(); i++) {
Ingredient ingredient = ingredients.get(i);
for (ItemStack stack : ingredient.getMatchingStacks()) {
int itemCount = 0;
for (ItemStack stack1 : playerInventory.main) {
if (stack.isItemEqual(stack1)) {
if (stack.isOf(stack1.getItem())) {
itemCount += stack1.getCount();
}
}
if (itemCount == 0)
break;

if (playerInventory.indexOf(stack) != -1){
if (getSlotWithStackIgnoreNBT(playerInventory, stack) != -1){
if (!containedItems.containsKey(stack.getItem())) {
if (itemCount >= stack.getCount()) {
hasIngredients.set(i, true);
containedItems.put(stack.getItem(), 1);
}
} else {
if (itemCount > containedItems.get(stack.getItem())) {
if (itemCount >= (containedItems.get(stack.getItem()) + 1)) {
hasIngredients.set(i, true);
containedItems.put(stack.getItem(), containedItems.get(stack.getItem()) + 1);
}
Expand All @@ -85,8 +85,23 @@ public boolean matches(PlayerInventory playerInventory, World world) {
return matches;
}

public static int getSlotWithStackIgnoreNBT(PlayerInventory inventory, ItemStack stack) {
for(int i = 0; i < inventory.main.size(); ++i) {
if (!inventory.main.get(i).isEmpty() && stack.isOf(inventory.main.get(i).getItem())) {
return i;
}
}

return -1;
}

@Override
public ItemStack craft(PlayerInventory playerInventory) {
if (this.output.getNbt() != null && this.output.getNbt().isEmpty()) {
ItemStack stack = this.output.copy();
stack.setNbt(null);
return stack;
}
return this.output.copy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class PaladinFurnitureModBlocksItems {
public static final FridgeBlock GRAY_FRIDGE = new FridgeBlock(AbstractBlock.Settings.copy(GRAY_FREEZER).nonOpaque(), () -> PaladinFurnitureModBlocksItems.GRAY_FREEZER);
public static final FreezerBlock IRON_FREEZER = new IronFreezerBlock(AbstractBlock.Settings.of(Material.METAL).resistance(3.5f).strength(5.0f).sounds(BlockSoundGroup.METAL).mapColor(MapColor.IRON_GRAY), () -> PaladinFurnitureModBlocksItems.IRON_FRIDGE);
public static final FridgeBlock IRON_FRIDGE = new IronFridgeBlock(AbstractBlock.Settings.copy(IRON_FREEZER).nonOpaque(), () -> PaladinFurnitureModBlocksItems.IRON_FREEZER);
public static final FridgeBlock XBOX_FRIDGE = new XboxFridgeBlock(AbstractBlock.Settings.copy(WHITE_FREEZER).nonOpaque().mapColor(MapColor.BLACK), null);
public static final FridgeBlock XBOX_FRIDGE = new XboxFridgeBlock(AbstractBlock.Settings.copy(WHITE_FREEZER).resistance(1200.0F).nonOpaque().mapColor(MapColor.BLACK), null);

public static final StoveBlock WHITE_STOVE = new StoveBlock(AbstractBlock.Settings.copy(WHITE_FREEZER));
public static final KitchenRangeHoodBlock WHITE_OVEN_RANGEHOOD = new KitchenRangeHoodBlock(AbstractBlock.Settings.copy(WHITE_FREEZER).nonOpaque());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void generateTranslationForBedMap(HashMap<VariantBase<?>, ? extends List<
variantBaseHashMap.forEach((variant, list) -> {
list.forEach(block1 -> {
Block block = (Block) block1;
if (variant instanceof WoodVariant && !variant.isVanilla()) {
if (variant instanceof WoodVariant) {
String translatedVariantName = getTranslatedVariantName(variant);
String strippedKey = block.getTranslationKey().contains("stripped") ? translate("block.type.stripped") : "";
String translatedFurnitureName = StringUtils.normalizeSpace(blockStringStringStringStringQuadFunc.apply(block, furnitureKey, strippedKey, translatedVariantName));
Expand All @@ -249,7 +249,7 @@ public void generateTranslationForBedMap(HashMap<VariantBase<?>, ? extends List<

public void generateTranslationForVariantBlockMap(Map<VariantBase<?>, ? extends Block> variantBaseHashMap, BufferedWriter writer, String furnitureKey, QuadFunc<Block, String, String, String, String> blockStringStringStringStringQuadFunc) {
variantBaseHashMap.forEach((variant, block) -> {
if (variant instanceof WoodVariant && !variant.isVanilla()) {
if (variant instanceof WoodVariant) {
String translatedVariantName = getTranslatedVariantName(variant);
String strippedKey = block.getTranslationKey().contains("stripped") ? translate("block.type.stripped") : "";
String translatedFurnitureName = StringUtils.normalizeSpace(blockStringStringStringStringQuadFunc.apply(block, furnitureKey, strippedKey, translatedVariantName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,25 @@ public IModelData getModelData(@NotNull BlockRenderView world, @NotNull BlockPos
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull Random rand, @NotNull IModelData extraData) {
List<BakedQuad> quads = new ArrayList<>();
int onOffset = state.get(Properties.LIT) ? 1 : 0;
WoodVariant variant = extraData.getData(VARIANT);
BitSet set = extraData.getData(CONNECTIONS).connections;
if (set.get(0) && set.get(1)) {
quads.addAll(bakedModels.get(variant).get(modelParts.get(1)).getQuads(state, side, rand, extraData));
} else if (set.get(0)) {
quads.addAll(bakedModels.get(variant).get(modelParts.get(0)).getQuads(state, side, rand, extraData));
} else if (set.get(1))
{
quads.addAll(bakedModels.get(variant).get(modelParts.get(3)).getQuads(state, side, rand, extraData));
quads.addAll(bakedModels.get(variant).get(modelParts.get(5+onOffset)).getQuads(state, side, rand, extraData));
quads.addAll(bakedModels.get(variant).get(modelParts.get(4)).getQuads(state, side, rand, extraData));
}
else {
quads.addAll(bakedModels.get(variant).get(modelParts.get(4)).getQuads(state, side, rand, extraData));
quads.addAll(bakedModels.get(variant).get(modelParts.get(2)).getQuads(state, side, rand, extraData));
quads.addAll(bakedModels.get(variant).get(modelParts.get(5+onOffset)).getQuads(state, side, rand, extraData));
if (state != null && extraData.getData(CONNECTIONS) != null && extraData.getData(CONNECTIONS).connections != null) {
int onOffset = state.get(Properties.LIT) ? 1 : 0;
WoodVariant variant = extraData.getData(VARIANT);
BitSet set = extraData.getData(CONNECTIONS).connections;
if (set.get(0) && set.get(1)) {
quads.addAll(bakedModels.get(variant).get(modelParts.get(1)).getQuads(state, side, rand, extraData));
} else if (set.get(0)) {
quads.addAll(bakedModels.get(variant).get(modelParts.get(0)).getQuads(state, side, rand, extraData));
} else if (set.get(1))
{
quads.addAll(bakedModels.get(variant).get(modelParts.get(3)).getQuads(state, side, rand, extraData));
quads.addAll(bakedModels.get(variant).get(modelParts.get(5+onOffset)).getQuads(state, side, rand, extraData));
quads.addAll(bakedModels.get(variant).get(modelParts.get(4)).getQuads(state, side, rand, extraData));
}
else {
quads.addAll(bakedModels.get(variant).get(modelParts.get(4)).getQuads(state, side, rand, extraData));
quads.addAll(bakedModels.get(variant).get(modelParts.get(2)).getQuads(state, side, rand, extraData));
quads.addAll(bakedModels.get(variant).get(modelParts.get(5+onOffset)).getQuads(state, side, rand, extraData));
}
}
return quads;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public IModelData getModelData(@NotNull BlockRenderView world, @NotNull BlockPos
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull Random rand, @NotNull IModelData extraData) {
List<BakedQuad> quads = new ArrayList<>();
if (state.getBlock() instanceof BasicTableBlock) {
if (state != null && state.getBlock() instanceof BasicTableBlock && extraData.getData(CONNECTIONS) != null && extraData.getData(CONNECTIONS).connections != null) {
BitSet set = extraData.getData(CONNECTIONS).connections;
boolean north = set.get(0);
boolean east = set.get(1);
Expand Down
Loading

0 comments on commit bff3af1

Please sign in to comment.