Skip to content

Commit

Permalink
1.21.1 port fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrokenK3yboard committed Jan 5, 2025
1 parent ce86903 commit 3d5c052
Show file tree
Hide file tree
Showing 47 changed files with 225 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class CrateBlock extends ZetaBlock implements EntityBlock {
public static final BooleanProperty PROPERTY_OPEN = BlockStateProperties.OPEN;

public CrateBlock(@Nullable ZetaModule module) {
super("crate", module, Properties.copy(Blocks.BARREL));
super("crate", module, Properties.ofFullCopy(Blocks.BARREL));
registerDefaultState(stateDefinition.any().setValue(PROPERTY_OPEN, false));

if(module == null) //auto registration below this line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MagnetBlock extends ZetaBlock implements EntityBlock{
public static final BooleanProperty WAXED = BooleanProperty.create("waxed");

public MagnetBlock(@Nullable ZetaModule module) {
super("magnet", module, Properties.copy(Blocks.IRON_BLOCK)
super("magnet", module, Properties.ofFullCopy(Blocks.IRON_BLOCK)
.hasPostProcess(MagnetBlock::isPowered)
.lightLevel(state -> state.getValue(POWERED) ? 3 : 0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,16 @@ else if(MatrixEnchantingModule.customInfluences.containsKey(state))
return CandleInfluencer.forBlock(state.getBlock(), world, pos);
}

@Override
public void startOpen(@NotNull Player player) {

}

@Override
public void stopOpen(@NotNull Player player) {

}

private record CandleInfluencer(boolean inverted) implements IEnchantmentInfluencer {

private static final CandleInfluencer INSTANCE = new CandleInfluencer(false);
Expand Down Expand Up @@ -416,7 +426,7 @@ private DyeColor getColor(BlockState state) {
@Override
public float[] getEnchantmentInfluenceColor(BlockGetter world, BlockPos pos, BlockState state) {
DyeColor color = getColor(state);
return color == null ? null : color.getTextureDiffuseColors();
return color == null ? null : color.getTextureDiffuseColor();
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
package org.violetmoon.quark.addons.oddities.client.screen;

import java.util.LinkedList;
import java.util.List;

import net.minecraft.world.entity.monster.Zombie;
import org.jetbrains.annotations.NotNull;
import org.violetmoon.quark.addons.oddities.block.be.MatrixEnchantingTableBlockEntity;
import org.violetmoon.quark.addons.oddities.inventory.EnchantmentMatrix;
import org.violetmoon.quark.addons.oddities.inventory.EnchantmentMatrix.Piece;
import org.violetmoon.quark.addons.oddities.inventory.MatrixEnchantingMenu;
import org.violetmoon.quark.addons.oddities.module.MatrixEnchantingModule;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.QuarkClient;
import org.violetmoon.quark.base.client.handler.ClientUtil;
import org.violetmoon.quark.base.network.message.oddities.MatrixEnchanterOperationMessage;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
Expand All @@ -32,6 +16,19 @@
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.NotNull;
import org.violetmoon.quark.addons.oddities.block.be.MatrixEnchantingTableBlockEntity;
import org.violetmoon.quark.addons.oddities.inventory.EnchantmentMatrix;
import org.violetmoon.quark.addons.oddities.inventory.EnchantmentMatrix.Piece;
import org.violetmoon.quark.addons.oddities.inventory.MatrixEnchantingMenu;
import org.violetmoon.quark.addons.oddities.module.MatrixEnchantingModule;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.QuarkClient;
import org.violetmoon.quark.base.client.handler.ClientUtil;
import org.violetmoon.quark.base.network.message.oddities.MatrixEnchanterOperationMessage;

import java.util.LinkedList;
import java.util.List;

public class MatrixEnchantingScreen extends AbstractContainerScreen<MatrixEnchantingMenu> {

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

import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.Event;
import net.neoforged.bus.api.Event;

import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.violetmoon.quark.api.event;

import net.minecraftforge.eventbus.api.Cancelable;

/**
* Fired when a module's state (enabled/disabled) is changed.
* Cancel the event to force the module disabled.
*/
@Cancelable

public class ModuleStateChangedEvent extends QuarkModuleEvent {

public final boolean enabled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.violetmoon.quark.api.event;

import net.minecraftforge.eventbus.api.Event;
import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.ICancellableEvent;

public class QuarkModuleEvent extends Event {
public class QuarkModuleEvent extends Event implements ICancellableEvent {

public final String eventName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.neoforged.bus.api.Event;

@Cancelable
public class UsageTickerEvent extends Event {

public final EquipmentSlot slot;
Expand Down Expand Up @@ -66,7 +64,5 @@ public int getResultCount() {
public void setResultCount(int resultCount) {
this.resultCount = resultCount;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.MissingMappingsEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import org.violetmoon.quark.base.Quark;

import java.util.HashMap;
import java.util.Map;

@Mod.EventBusSubscriber
@EventBusSubscriber
public class QuarkRemapHandler {
//datafixers could have also been used here but good luck figuring them out

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private static ItemStack mergeStackWithOthers(List<ItemStack> list, int index) {
if(stackAt.isEmpty())
continue;

if(stackAt.getCount() < stackAt.getMaxStackSize() && ItemStack.isSameItem(stack, stackAt) && ItemStack.isSameItemSameTags(stack, stackAt)) {
if(stackAt.getCount() < stackAt.getMaxStackSize() && ItemStack.isSameItem(stack, stackAt) && ItemStack.isSameItemSameComponents(stack, stackAt)) {
int setSize = stackAt.getCount() + stack.getCount();
int carryover = Math.max(0, setSize - stackAt.getMaxStackSize());
stackAt.setCount(carryover);
Expand Down Expand Up @@ -355,7 +355,7 @@ else if(o instanceof String s) {
private static int nutrition(FoodProperties properties) {
if(properties == null)
return 0;
return properties.getNutrition();
return properties.nutrition();
}

private static int foodHealCompare(ItemStack stack1, ItemStack stack2) {
Expand All @@ -365,7 +365,7 @@ private static int foodHealCompare(ItemStack stack1, ItemStack stack2) {
private static float saturation(FoodProperties properties) {
if(properties == null)
return 0;
return Math.min(20, properties.getNutrition() * properties.getSaturationModifier() * 2);
return Math.min(20, properties.nutrition() * properties.saturation() * 2);
}

private static int foodSaturationCompare(ItemStack stack1, ItemStack stack2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Set;
import java.util.stream.Stream;

import net.neoforged.neoforge.common.ItemAbilities;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.client.render.QuarkBoatRenderer;
import org.violetmoon.quark.base.item.boat.QuarkBoat;
Expand Down Expand Up @@ -157,7 +158,7 @@ public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name
set.wallHangingSign = new ZetaWallHangingSignBlock(name + "_wall_hanging_sign", module, type, OldMaterials.wood().forceSolidOn().mapColor(color).noCollission().strength(1.0F).sound(SoundType.WOOD).lootFrom(() -> set.sign));

set.bookshelf = new VariantBookshelfBlock(name, module, true, sound).setCondition(() -> Quark.ZETA.modules.isEnabledOrOverlapping(VariantBookshelvesModule.class));
set.ladder = new VariantLadderBlock(name, module, Block.Properties.copy(Blocks.LADDER).sound(sound), true).setCondition(() -> Quark.ZETA.modules.isEnabledOrOverlapping(VariantLaddersModule.class));
set.ladder = new VariantLadderBlock(name, module, Block.Properties.ofFullCopy(Blocks.LADDER).sound(sound), true).setCondition(() -> Quark.ZETA.modules.isEnabledOrOverlapping(VariantLaddersModule.class));

set.post = new WoodPostBlock(module, set.fence, "", sound).setCondition(() -> Quark.ZETA.modules.isEnabledOrOverlapping(WoodenPostsModule.class));
set.strippedPost = new WoodPostBlock(module, set.fence, "stripped_", sound).setCondition(() -> Quark.ZETA.modules.isEnabledOrOverlapping(WoodenPostsModule.class));
Expand All @@ -172,9 +173,9 @@ public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name

makeSignWork(set.sign, set.wallSign, set.ceilingHangingSign, set.wallHangingSign);

ToolInteractionHandler.registerInteraction(ToolActions.AXE_STRIP, set.log, set.strippedLog);
ToolInteractionHandler.registerInteraction(ToolActions.AXE_STRIP, set.wood, set.strippedWood);
ToolInteractionHandler.registerInteraction(ToolActions.AXE_STRIP, set.post, set.strippedPost);
ToolInteractionHandler.registerInteraction(ItemAbilities.AXE_STRIP, set.log, set.strippedLog);
ToolInteractionHandler.registerInteraction(ItemAbilities.AXE_STRIP, set.wood, set.strippedWood);
ToolInteractionHandler.registerInteraction(ItemAbilities.AXE_STRIP, set.post, set.strippedPost);

VariantLaddersModule.variantLadders.add(set.ladder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.LocalDateTime;
import java.time.Month;

import net.neoforged.fml.ModLoadingContext;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.QuarkClient;
Expand Down
54 changes: 22 additions & 32 deletions src/main/java/org/violetmoon/quark/base/proxy/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package org.violetmoon.quark.base.proxy;

import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;

import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.common.NeoForge;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.api.ICustomSorting;
import org.violetmoon.quark.api.IMagnetTracker;
import org.violetmoon.quark.api.IPistonCallback;
import org.violetmoon.quark.api.IRuneColorProvider;
import org.violetmoon.quark.api.ITransferManager;
import org.violetmoon.quark.api.QuarkCapabilities;
import org.violetmoon.quark.api.event.SimpleHarvestEvent;
import org.violetmoon.quark.api.*;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.capability.CapabilityHandler;
import org.violetmoon.quark.base.capability.QuarkForgeCapabilities;
Expand All @@ -21,26 +23,14 @@
import org.violetmoon.quark.base.handler.WoodSetHandler;
import org.violetmoon.quark.base.network.QuarkNetwork;
import org.violetmoon.quark.base.recipe.ExclusionRecipe;
import org.violetmoon.zeta.config.SyncedFlagHandler;
import org.violetmoon.zeta.event.bus.IZetaPlayEvent;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.load.ZCommonSetup;
import org.violetmoon.zeta.event.load.ZConfigChanged;
import org.violetmoon.zeta.event.load.ZRegister;
import org.violetmoon.zeta.module.ZetaCategory;
import org.violetmoon.zetaimplforge.module.ModFileScanDataModuleFinder;

import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
import net.minecraftforge.fml.event.config.ModConfigEvent;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;

public class CommonProxy {

Expand All @@ -56,12 +46,12 @@ public void start() {
.register(QuarkCapabilities.MAGNET_TRACKER_CAPABILITY, QuarkForgeCapabilities.MAGNET_TRACKER_CAPABILITY)
.register(QuarkCapabilities.RUNE_COLOR, QuarkForgeCapabilities.RUNE_COLOR);
//weird forge capability-implementation-class stuff
MinecraftForge.EVENT_BUS.addListener((RegisterCapabilitiesEvent e) -> {
e.register(ICustomSorting.class);
e.register(ITransferManager.class);
e.register(IPistonCallback.class);
e.register(IMagnetTracker.class);
e.register(IRuneColorProvider.class);
NeoForge.EVENT_BUS.addListener((RegisterCapabilitiesEvent event) -> {
event.register(ICustomSorting.class);
event.register(ITransferManager.class);
event.register(IPistonCallback.class);
event.register(IMagnetTracker.class);
event.register(IRuneColorProvider.class);
});

// GLOBAL EVENT LISTENERS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BlockPropertyUtil {
* Like Property.copy but only copies ones that do not contain a funciton as those are not safe to copy since they could reference states we dont have
*/
public static BlockBehaviour.Properties copyPropertySafe(Block blockBehaviour) {
var p = BlockBehaviour.Properties.copy(blockBehaviour);
var p = BlockBehaviour.Properties.ofFullCopy(blockBehaviour);
BlockState state = blockBehaviour.defaultBlockState();
p.lightLevel(s -> state.getLightEmission());
p.offsetType(BlockBehaviour.OffsetType.NONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class GravisandModule extends ZetaModule {

@LoadEvent
public final void register(ZRegister event) {
gravisand = new GravisandBlock("gravisand", this, Block.Properties.copy(Blocks.SAND));
gravisand = new GravisandBlock("gravisand", this, Block.Properties.ofFullCopy(Blocks.SAND));

gravisandType = EntityType.Builder.<Gravisand>of(Gravisand::new, MobCategory.MISC)
.sized(0.98F, 0.98F)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.violetmoon.quark.content.building.block;

import net.neoforged.neoforge.common.ItemAbility;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.base.Quark;
Expand Down Expand Up @@ -89,7 +90,7 @@ public BlockState mirror(@NotNull BlockState state, @NotNull Mirror mirror) {
Direction face = Direction.getNearest(exactPos.x - (centerPos.getX() + 0.5), exactPos.y - (centerPos.getY() + 0.5), exactPos.z - (centerPos.getZ() + 0.5));
return state.cycle(MiscUtil.directionProperty(face));
}
return super.getToolModifiedStateZeta(state, context, toolActionType, simulate);
return super.getToolModifiedStateZeta(state, context, ItemAbility.get(toolActionType), simulate);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class VariantBookshelfBlock extends ZetaBlock {
private final boolean flammable;

public VariantBookshelfBlock(String type, @Nullable ZetaModule module, boolean flammable, SoundType sound) {
super(type + "_bookshelf", module, Block.Properties.copy(Blocks.BOOKSHELF).sound(sound));
super(type + "_bookshelf", module, Block.Properties.ofFullCopy(Blocks.BOOKSHELF).sound(sound));
this.flammable = flammable;

if(module == null) //auto registration below this line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class CelebratoryLampsModule extends ZetaModule {

@LoadEvent
public final void register(ZRegister event) {
stone_lamp = new CelebratoryLampBlock("stone_lamp", this, Block.Properties.copy(Blocks.STONE).lightLevel(s -> lightLevel)).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS);
stone_brick_lamp = new CelebratoryLampBlock("stone_brick_lamp", this, Block.Properties.copy(Blocks.STONE_BRICKS).lightLevel(s -> lightLevel)).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS);
stone_lamp = new CelebratoryLampBlock("stone_lamp", this, Block.Properties.ofFullCopy(Blocks.STONE).lightLevel(s -> lightLevel)).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS);
stone_brick_lamp = new CelebratoryLampBlock("stone_brick_lamp", this, Block.Properties.ofFullCopy(Blocks.STONE_BRICKS).lightLevel(s -> lightLevel)).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public class DuskboundBlocksModule extends ZetaModule {
@LoadEvent
public final void register(ZRegister event) {
CreativeTabManager.daisyChain();
Block duskbound = new ZetaBlock("duskbound_block", this, Block.Properties.copy(Blocks.PURPUR_BLOCK)).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS, Blocks.COAL_BLOCK, true);
Block duskbound = new ZetaBlock("duskbound_block", this, Block.Properties.ofFullCopy(Blocks.PURPUR_BLOCK)).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS, Blocks.COAL_BLOCK, true);

new ZetaBlock("duskbound_lantern", this,
Block.Properties.copy(Blocks.PURPUR_BLOCK)
Block.Properties.ofFullCopy(Blocks.PURPUR_BLOCK)
.lightLevel(b -> 15))
.setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class GoldBarsModule extends ZetaModule {

@LoadEvent
public final void register(ZRegister event) {
gold_bars = new ZetaPaneBlock("gold_bars", this, Properties.copy(Blocks.IRON_BARS), RenderLayerRegistry.Layer.CUTOUT).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS, Blocks.GOLD_BLOCK, false);
gold_bars = new ZetaPaneBlock("gold_bars", this, Properties.ofFullCopy(Blocks.IRON_BARS), RenderLayerRegistry.Layer.CUTOUT).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS, Blocks.GOLD_BLOCK, false);

StructureBlockReplacementHandler.addReplacement(GoldBarsModule::getGenerationBarBlockState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MoreMudBlocksModule extends ZetaModule {

@LoadEvent
public final void register(ZRegister event) {
BlockBehaviour.Properties props = Properties.copy(Blocks.MUD_BRICKS);
BlockBehaviour.Properties props = Properties.ofFullCopy(Blocks.MUD_BRICKS);

CreativeTabManager.daisyChain();
new ZetaBlock("carved_mud_bricks", this, props).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS, Blocks.MUD_BRICK_STAIRS, false);
Expand Down
Loading

0 comments on commit 3d5c052

Please sign in to comment.