Skip to content

Commit

Permalink
Fix Mixin jsons & port some material stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Nov 18, 2023
1 parent abc84da commit 6610bf1
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void smartTransfer() {

boolean itemEqual = stack.getItem() == stackAt.getItem();
boolean damageEqual = stack.getDamageValue() == stackAt.getDamageValue();
boolean nbtEqual = ItemStack.tagMatches(stackAt, stack);
boolean nbtEqual = ItemStack.isSameItemSameTags(stackAt, stack);

if(itemEqual && damageEqual && nbtEqual)
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.function.Predicate;

public class MiscUtil {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.violetmoon.quark.base.handler;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.InteractionResult;
Expand Down Expand Up @@ -216,7 +217,7 @@ private static ItemStack mergeStackWithOthers(List<ItemStack> list, int index) {
if (stackAt.isEmpty())
continue;

if (stackAt.getCount() < stackAt.getMaxStackSize() && ItemStack.isSame(stack, stackAt) && ItemStack.tagMatches(stack, stackAt)) {
if (stackAt.getCount() < stackAt.getMaxStackSize() && ItemStack.isSameItem(stack, stackAt) && ItemStack.isSameItemSameTags(stack, stackAt)) {
int setSize = stackAt.getCount() + stack.getCount();
int carryover = Math.max(0, setSize - stackAt.getMaxStackSize());
stackAt.setCount(carryover);
Expand Down Expand Up @@ -342,7 +343,7 @@ else if (o instanceof Block block)
else if (o instanceof ItemStack stack)
itemList.add(stack.getItem());
else if (o instanceof String s) {
Item item = Registry.ITEM.get(new ResourceLocation(s));
Item item = BuiltInRegistries.ITEM.get(new ResourceLocation(s));
if (item != Items.AIR)
itemList.add(item);
}
Expand Down Expand Up @@ -404,8 +405,8 @@ private static int armorSlotAndToughnessCompare(ItemStack stack1, ItemStack stac
ArmorItem armor1 = (ArmorItem) stack1.getItem();
ArmorItem armor2 = (ArmorItem) stack2.getItem();

EquipmentSlot slot1 = armor1.getSlot();
EquipmentSlot slot2 = armor2.getSlot();
EquipmentSlot slot1 = armor1.getEquipmentSlot();
EquipmentSlot slot2 = armor2.getEquipmentSlot();

if (slot1 == slot2)
return armor2.getMaterial().getDefenseForSlot(slot2) - armor2.getMaterial().getDefenseForSlot(slot1);
Expand Down Expand Up @@ -449,7 +450,7 @@ public static int potionTypeCompare(ItemStack stack1, ItemStack stack2) {
Potion potion1 = PotionUtils.getPotion(stack1);
Potion potion2 = PotionUtils.getPotion(stack2);

return Registry.POTION.getId(potion2) - Registry.POTION.getId(potion1);
return BuiltInRegistries.POTION.getId(potion2) - BuiltInRegistries.POTION.getId(potion1);
}

static boolean hasCustomSorting(ItemStack stack) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/violetmoon/quark/base/util/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.MapColor;

/**
* Assortment of Block Related Utilities
Expand All @@ -28,6 +29,10 @@ public static boolean isGlassBased(BlockState blockState, BlockGetter blockGette
blockState.getSoundType() == SoundType.GLASS;
}

public static boolean isStoneBased(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) {
return blockState.instrument() == NoteBlockInstrument.BASEDRUM || blockState.getMapColor(blockGetter, blockPos) == MapColor.STONE;
}

public static boolean canFallThrough(BlockState state) {
Block block = state.getBlock();
return state.isAir() || block == Blocks.FIRE || state.liquid() || state.canBeReplaced();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private String getReadout(Minecraft mc, boolean full) {
if(stack.isEmpty())
sb.append(I18n.get("quark.readout.no_item"));
else {
List<Component> tooltip = cnt.getTooltipFromItem(stack);
List<Component> tooltip = cnt.getTooltipFromItem(mc, stack);

for(Component t : tooltip) {
Component print = t.copy();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
package org.violetmoon.quark.content.tweaks.module;

import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.config.Config;
import org.violetmoon.quark.base.handler.MiscUtil;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.bus.PlayEvent;
import org.violetmoon.zeta.event.load.ZCommonSetup;
import org.violetmoon.zeta.event.play.ZBlock;
import org.violetmoon.zeta.module.ZetaLoadModule;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.util.Hint;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -28,13 +17,22 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LevelEvent;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.PlantType;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.ToolActions;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.config.Config;
import org.violetmoon.quark.base.handler.MiscUtil;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.bus.PlayEvent;
import org.violetmoon.zeta.event.load.ZCommonSetup;
import org.violetmoon.zeta.event.play.ZBlock;
import org.violetmoon.zeta.module.ZetaLoadModule;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.util.Hint;

@ZetaLoadModule(category = "tweaks")
public class HoeHarvestingModule extends ZetaModule {
Expand All @@ -51,7 +49,7 @@ public class HoeHarvestingModule extends ZetaModule {


@Hint(key = "hoe_harvesting")
TagKey<Item> hoes = Tags.Items.TOOLS_HOES;
TagKey<Item> hoes = ItemTags.HOES;

public static TagKey<Item> bigHarvestingHoesTag;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.violetmoon.quark.content.world.block;

import org.jetbrains.annotations.NotNull;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
Expand All @@ -12,8 +10,10 @@
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.pathfinder.PathComputationType;
import org.jetbrains.annotations.NotNull;
import org.violetmoon.quark.content.world.block.be.MonsterBoxBlockEntity;
import org.violetmoon.quark.content.world.module.MonsterBoxModule;
import org.violetmoon.zeta.block.ZetaBlock;
Expand All @@ -24,7 +24,9 @@ public class MonsterBoxBlock extends ZetaBlock implements EntityBlock {

public MonsterBoxBlock(ZetaModule module) {
super("monster_box", module, null,
Block.Properties.of(Material.METAL)
Block.Properties.of()
.mapColor(MapColor.METAL)
.instrument(NoteBlockInstrument.IRON_XYLOPHONE)
.strength(25F)
.sound(SoundType.METAL)
.noOcclusion());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package org.violetmoon.quark.content.world.gen;

import org.violetmoon.quark.base.config.type.DimensionConfig;
import org.violetmoon.quark.base.world.generator.Generator;
import org.violetmoon.quark.content.world.module.MonsterBoxModule;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.WorldGenRegion;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.material.Material;
import org.violetmoon.quark.base.config.type.DimensionConfig;
import org.violetmoon.quark.base.util.BlockUtils;
import org.violetmoon.quark.base.world.generator.Generator;
import org.violetmoon.quark.content.world.module.MonsterBoxModule;

public class MonsterBoxGenerator extends Generator {

Expand All @@ -37,7 +36,7 @@ public void generateChunk(WorldGenRegion world, ChunkGenerator generator, Random
testPos = testPos.below();
testState = world.getBlockState(testPos);
moves++;
} while(moves < MonsterBoxModule.searchRange && testState.getMaterial() != Material.STONE && testPos.getY() >= MonsterBoxModule.minY);
} while(moves < MonsterBoxModule.searchRange && BlockUtils.isStoneBased(testState, world, testPos) && testPos.getY() >= MonsterBoxModule.minY);

if(testPos.getY() >= MonsterBoxModule.minY && world.isEmptyBlock(testPos.above()) && world.getBlockState(testPos).isFaceSturdy(world, testPos, Direction.UP)) {
world.setBlock(testPos.above(), MonsterBoxModule.monster_box.defaultBlockState(), 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package org.violetmoon.zeta.advancement.modifier;

import java.util.Set;

import org.violetmoon.zeta.api.IMutableAdvancement;
import org.violetmoon.zeta.advancement.AdvancementModifier;
import org.violetmoon.zeta.module.ZetaModule;

import com.google.common.collect.ImmutableSet;

import net.minecraft.advancements.Criterion;
import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.advancements.critereon.EntityTypePredicate;
import net.minecraft.advancements.critereon.KilledTrigger;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import org.violetmoon.zeta.advancement.AdvancementModifier;
import org.violetmoon.zeta.api.IMutableAdvancement;
import org.violetmoon.zeta.module.ZetaModule;

import java.util.Set;

public class MonsterHunterModifier extends AdvancementModifier {

Expand All @@ -41,7 +39,7 @@ public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
for(EntityType<?> type : entityTypes) {
Criterion criterion = new Criterion(KilledTrigger.TriggerInstance.playerKilledEntity(EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(type))));

String name = Registry.ENTITY_TYPE.getKey(type).toString();
String name = BuiltInRegistries.ENTITY_TYPE.getKey(type).toString();
if(all)
adv.addRequiredCriterion(name, criterion);
else adv.addOrCriterion(name, criterion);
Expand Down
9 changes: 0 additions & 9 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
public net.minecraft.client.gui.components.ChatComponent f_93761_ # drawnChatLines
public net.minecraft.client.gui.components.ChatComponent f_93763_ # scrollPos
public net.minecraft.client.gui.components.ChatComponent m_93790_(Lnet/minecraft/network/chat/Component;IIZ)V # printChatMessageWithOptionalDeletion
public net.minecraft.client.gui.components.ChatComponent m_93818_()Z # getChatOpen
public net.minecraft.client.gui.components.toasts.RecipeToast f_94805_ # recipes
public net.minecraft.client.gui.components.toasts.ToastComponent f_94916_ # toastsQueue
public net.minecraft.client.gui.screens.Screen f_169368_ # narratables
public net.minecraft.client.gui.screens.recipebook.GhostRecipe$GhostIngredient f_100161_ # ingredient
public net.minecraft.client.gui.screens.recipebook.RecipeBookComponent f_100269_ # ghostRecipe
public net.minecraft.client.gui.screens.recipebook.RecipeBookComponent f_100281_ # searchBar
Expand All @@ -14,10 +10,8 @@ public net.minecraft.client.gui.screens.recipebook.RecipeBookPage f_100399_ # re
public net.minecraft.client.multiplayer.PlayerInfo f_105299_ # playerTextures
public net.minecraft.client.player.AbstractClientPlayer f_108546_ # playerInfo
public net.minecraft.client.renderer.LevelRenderer f_109410_ # mapSoundPositions
public net.minecraft.client.renderer.entity.EntityRenderers f_174031_ # PROVIDERS
public net.minecraft.client.renderer.entity.LivingEntityRenderer f_115291_ # layerRenderers
public net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer m_117078_(Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/client/model/HumanoidModel; #func_241736_a_
public net.minecraft.server.network.ServerGamePacketListenerImpl f_9750_ # chatSpamThresholdCount
public net.minecraft.util.random.Weight <init>(I)V # <init>
public net.minecraft.world.entity.LivingEntity f_20899_ # isJumping
public net.minecraft.world.entity.LivingEntity f_20922_ # ticksSinceLastSwing
Expand Down Expand Up @@ -48,7 +42,6 @@ public-f net.minecraft.world.level.levelgen.StructureSettings f_189361_ #configu
public-f net.minecraft.world.level.levelgen.StructureSettings f_64580_ # DEFAULTS
public-f net.minecraft.world.level.levelgen.StructureSettings f_64582_ # structureConfig
public-f net.minecraft.world.level.storage.loot.LootPool f_79023_ # entries
public net.minecraft.world.level.BaseSpawner f_45443_ # spawnPotentials
public net.minecraft.world.level.block.VineBlock m_57887_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z # canSupportAtFace
public net.minecraft.data.worldgen.biome.OverworldBiomes m_194861_(Lnet/minecraft/world/level/biome/Biome$Precipitation;Lnet/minecraft/world/level/biome/Biome$BiomeCategory;FFLnet/minecraft/world/level/biome/MobSpawnSettings$Builder;Lnet/minecraft/world/level/biome/BiomeGenerationSettings$Builder;Lnet/minecraft/sounds/Music;)Lnet/minecraft/world/level/biome/Biome; # biome
public net.minecraft.data.worldgen.biome.OverworldBiomes m_194851_(Lnet/minecraft/world/level/biome/Biome$Precipitation;Lnet/minecraft/world/level/biome/Biome$BiomeCategory;FFIILnet/minecraft/world/level/biome/MobSpawnSettings$Builder;Lnet/minecraft/world/level/biome/BiomeGenerationSettings$Builder;Lnet/minecraft/sounds/Music;)Lnet/minecraft/world/level/biome/Biome; # biome
Expand All @@ -73,8 +66,6 @@ public-f net.minecraft.advancements.Advancement f_138302_ # criteria
public-f net.minecraft.advancements.Advancement f_138303_ # requirements
public net.minecraft.advancements.critereon.EffectsChangedTrigger$TriggerInstance f_26774_ # effects
public net.minecraft.advancements.critereon.ItemInteractWithBlockTrigger$TriggerInstance f_220058_ # location
public net.minecraft.advancements.critereon.LocationPredicate f_52602_ # block
public-f net.minecraft.advancements.critereon.BlockPredicate f_146710_ # blocks
public net.minecraft.world.level.block.entity.BeaconBlockEntity$BeaconBeamSection f_58716_ # height
public net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase f_60598_ # materialColor
public net.minecraft.world.entity.animal.TropicalFish m_30064_(I)I # getPatternVariant
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/quark.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@
"StructureTemplateMixin",
"TemptGoalMixin",
"TripWireHookBlockMixin",
"VariantAccessor",
"VillagerMixin",
"WallBlockMixin",
"accessor.AccessorAbstractArrow",
"accessor.AccessorAbstractChestedHorse",
"accessor.AccessorAxolotlVariant",
"accessor.AccessorLivingEntity",
"accessor.AccessorMerchantOffer",
"accessor.AccessorPotionBrewing",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/zeta.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"mixins": [
"AccessorLootTable",
"AccessorPistonStructureResolver",
"PistonBaseBlockMixin",
"PistonBaseBlockMixin"
],
"client": [
],
Expand Down

0 comments on commit 6610bf1

Please sign in to comment.