Skip to content

Commit

Permalink
added jei plugin. refactored surrounding logic. removed unneded toolt…
Browse files Browse the repository at this point in the history
…ip hack stuff. made some stuff protected
  • Loading branch information
MehVahdJukaar committed Aug 6, 2024
1 parent ae85883 commit 0090b77
Show file tree
Hide file tree
Showing 56 changed files with 658 additions and 266 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ minecraft {

accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')


// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
Expand Down Expand Up @@ -98,6 +99,10 @@ dependencies {
jarJar.ranged(it, "[0.3.2,)")
}

// deps
implementation fg.deobf("curse.maven:jei-238222:${deps.jei}")


annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

Expand Down
3 changes: 2 additions & 1 deletion dependencies.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
forge=47.1.3
forge=47.1.3
jei=4712868
7 changes: 2 additions & 5 deletions src/main/java/org/violetmoon/zeta/Zeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.BlockHitResult;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.zeta.advancement.AdvancementModifierRegistry;
Expand All @@ -28,7 +27,6 @@
import org.violetmoon.zeta.util.RegistryUtil;
import org.violetmoon.zeta.util.ZetaSide;
import org.violetmoon.zeta.util.handler.FuelHandler;
import org.violetmoon.zeta.util.handler.RequiredModTooltipHandler;
import org.violetmoon.zeta.util.zetalist.IZeta;
import org.violetmoon.zeta.util.zetalist.ZetaList;
import org.violetmoon.zeta.world.EntitySpawnHandler;
Expand All @@ -45,7 +43,7 @@ public Zeta(String modid, Logger log, ZetaSide side, boolean isProduction) {

this.modid = modid;
this.side = side;
this.isProduction = isProduction;
this.isProduction = isProduction; //TODO: either have all these constants or static helpers here or in Utils. Not both


this.modules = createModuleManager();
Expand Down Expand Up @@ -87,14 +85,13 @@ public Zeta(String modid, Logger log, ZetaSide side, boolean isProduction) {

//registry
public final ZetaRegistry registry;
public final RegistryUtil registryUtil = new RegistryUtil(this); //TODO: Delete this, only needed cause there's no way to get early registry names.
public final RegistryUtil registryUtil = new RegistryUtil(this); //TODO: !!Delete this, only needed cause there's no way to get early registry names.
public final RenderLayerRegistry renderLayerRegistry;
public final DyeablesRegistry dyeables;
public final CraftingExtensionsRegistry craftingExtensions;
public final BrewingRegistry brewingRegistry;
public final AdvancementModifierRegistry advancementModifierRegistry;
public final PottedPlantRegistry pottedPlantRegistry;
public final RequiredModTooltipHandler requiredModTooltipHandler = new RequiredModTooltipHandler(); //TODO, find better spot or remove this.
public final VariantRegistry variantRegistry = new VariantRegistry(this);

//extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public AdvancementModifier setCondition(BooleanSupplier cond) {

@Override
public boolean isActive() {
return (module == null || module.enabled) && cond.getAsBoolean() && ZetaGeneralConfig.enableAdvancementModification;
return (module == null || module.isEnabled()) && cond.getAsBoolean() && ZetaGeneralConfig.enableAdvancementModification;
}

}
4 changes: 1 addition & 3 deletions src/main/java/org/violetmoon/zeta/block/ZetaBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public ZetaBlock(String regname, @Nullable ZetaModule module, Properties propert
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname);
if(module.category.isAddon())
module.zeta.requiredModTooltipHandler.map(this, module.category.requiredMod);
module.zeta().registry.registerBlock(this, regname);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/violetmoon/zeta/block/ZetaBushBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public ZetaBushBlock(String regname, @Nullable ZetaModule module, ResourceKey<Cr
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, true);
module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
module.zeta().registry.registerBlock(this, regname, true);
module.zeta().renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
if(tab != null)
setCreativeTab(tab);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ZetaButtonBlock(BlockSetType setType, int ticksToStayPressed, boolean arr
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, true);
module.zeta().registry.registerBlock(this, regname, true);
CreativeTabManager.addToCreativeTabNextTo(CreativeModeTabs.REDSTONE_BLOCKS, this, Blocks.STONE_BUTTON, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ZetaCeilingHangingSignBlock(String regname, @Nullable ZetaModule module,
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, false);
module.zeta().registry.registerBlock(this, regname, false);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/violetmoon/zeta/block/ZetaDoorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public ZetaDoorBlock(BlockSetType setType, String regname, @Nullable ZetaModule
if(module == null) //auto registration below this line
return;

module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
module.zeta.registry.registerBlock(this, regname, true);
module.zeta().renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
module.zeta().registry.registerBlock(this, regname, true);
CreativeTabManager.addToCreativeTab(CreativeModeTabs.BUILDING_BLOCKS, this);
CreativeTabManager.addToCreativeTab(CreativeModeTabs.REDSTONE_BLOCKS, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ZetaFenceBlock(String regname, @Nullable ZetaModule module, Properties pr
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, true);
module.zeta().registry.registerBlock(this, regname, true);
CreativeTabManager.addToCreativeTab(CreativeModeTabs.BUILDING_BLOCKS, this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ZetaFenceGateBlock(String regname, @Nullable ZetaModule module, SoundEven
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, true);
module.zeta().registry.registerBlock(this, regname, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ZetaGlassBlock(String regname, @Nullable ZetaModule module, boolean trans
if(module == null) //auto registration below this line
return;

module.zeta.renderLayerRegistry.put(this, translucent ? RenderLayerRegistry.Layer.TRANSLUCENT : RenderLayerRegistry.Layer.CUTOUT);
module.zeta().renderLayerRegistry.put(this, translucent ? RenderLayerRegistry.Layer.TRANSLUCENT : RenderLayerRegistry.Layer.CUTOUT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public ZetaInheritedPaneBlock(IZetaBlock parent, String name, Block.Properties p
if(module == null || parent.getModule() == null) //auto registration below this line
return;

parent.getModule().zeta.renderLayerRegistry.mock(this, parent.getBlock());
parent.getModule().zeta().renderLayerRegistry.mock(this, parent.getBlock());
}

public ZetaInheritedPaneBlock(IZetaBlock parent, Block.Properties properties) {
this(parent, Objects.requireNonNull(parent.getModule(), "Can only use this constructor on blocks with a ZetaModule").zeta.registryUtil.inheritQuark(parent, "%s_pane"), properties);
this(parent, Objects.requireNonNull(parent.getModule(), "Can only use this constructor on blocks with a ZetaModule").zeta().registryUtil.inheritQuark(parent, "%s_pane"), properties);
}

public ZetaInheritedPaneBlock(IZetaBlock parent) {
Expand All @@ -46,7 +46,7 @@ public boolean isEnabled() {
@Override
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
BlockState parentState = parent.getBlock().defaultBlockState();
return parent.getModule().zeta.blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
return parent.getModule().zeta().blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/violetmoon/zeta/block/ZetaLeavesBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public ZetaLeavesBlock(String name, @Nullable ZetaModule module, MapColor color)
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, name + "_leaves", true);
module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT_MIPPED);
module.zeta().registry.registerBlock(this, name + "_leaves", true);
module.zeta().renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT_MIPPED);
setCreativeTab(CreativeModeTabs.NATURAL_BLOCKS, Blocks.BROWN_MUSHROOM_BLOCK, true);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/violetmoon/zeta/block/ZetaPaneBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public ZetaPaneBlock(String name, @Nullable ZetaModule module, Block.Properties
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, name, true);
module.zeta().registry.registerBlock(this, name, true);
if(renderLayer != null)
module.zeta.renderLayerRegistry.put(this, renderLayer);
module.zeta().renderLayerRegistry.put(this, renderLayer);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ZetaPillarBlock(String regname, @Nullable ZetaModule module, Properties p
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, true);
module.zeta().registry.registerBlock(this, regname, true);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ZetaPressurePlateBlock(Sensitivity sensitivity, String regname, @Nullable
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, true);
module.zeta().registry.registerBlock(this, regname, true);
setCreativeTab(CreativeModeTabs.REDSTONE_BLOCKS, Blocks.HEAVY_WEIGHTED_PRESSURE_PLATE, false);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/violetmoon/zeta/block/ZetaSaplingBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public ZetaSaplingBlock(String name, @Nullable ZetaModule module, AbstractTreeGr
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, name + "_sapling", true);
module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
module.zeta().registry.registerBlock(this, name + "_sapling", true);
module.zeta().renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
setCreativeTab(CreativeModeTabs.NATURAL_BLOCKS, Blocks.AZALEA, true);
}

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/violetmoon/zeta/block/ZetaSlabBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ public ZetaSlabBlock(IZetaBlock parent, @Nullable ResourceKey<CreativeModeTab> t
if(module == null)
throw new IllegalArgumentException("Can only create ZetaSlabBlock with blocks belonging to a module"); //for various reasons

String resloc = module.zeta.registryUtil.inheritQuark(parent, "%s_slab");
parent.getModule().zeta.registry.registerBlock(this, resloc, true);
parent.getModule().zeta.renderLayerRegistry.mock(this, parent.getBlock());
String resloc = module.zeta().registryUtil.inheritQuark(parent, "%s_slab");
parent.getModule().zeta().registry.registerBlock(this, resloc, true);
parent.getModule().zeta().renderLayerRegistry.mock(this, parent.getBlock());
setCreativeTab(tab == null ? CreativeModeTabs.BUILDING_BLOCKS : tab, parent.getBlock(), false);
}

@Override
public boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
BlockState parentState = parent.getBlock().defaultBlockState();
return parent.getModule().zeta.blockExtensions.get(parentState).isFlammableZeta(parentState, world, pos, face);
return parent.getModule().zeta().blockExtensions.get(parentState).isFlammableZeta(parentState, world, pos, face);
}

@Override
public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
BlockState parentState = parent.getBlock().defaultBlockState();
return parent.getModule().zeta.blockExtensions.get(parentState).getFlammabilityZeta(parentState, world, pos, face);
return parent.getModule().zeta().blockExtensions.get(parentState).getFlammabilityZeta(parentState, world, pos, face);
}

@Nullable
Expand All @@ -68,11 +68,10 @@ public boolean doesConditionApply() {
return enabledSupplier.getAsBoolean();
}

@Nullable
@Override
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
BlockState parentState = parent.getBlock().defaultBlockState();
return parent.getModule().zeta.blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
return parent.getModule().zeta().blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
}

@Override
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/violetmoon/zeta/block/ZetaStairsBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ public ZetaStairsBlock(IZetaBlock parent, @Nullable ResourceKey<CreativeModeTab>
if(module == null)
throw new IllegalArgumentException("Can only create ZetaStairsBlock with blocks belonging to a module"); //for various reasons

String resloc = module.zeta.registryUtil.inheritQuark(parent, "%s_stairs");
parent.getModule().zeta.registry.registerBlock(this, resloc, true);
parent.getModule().zeta.renderLayerRegistry.mock(this, parent.getBlock());
String resloc = module.zeta().registryUtil.inheritQuark(parent, "%s_stairs");
parent.getModule().zeta().registry.registerBlock(this, resloc, true);
parent.getModule().zeta().renderLayerRegistry.mock(this, parent.getBlock());
setCreativeTab(tab == null ? CreativeModeTabs.BUILDING_BLOCKS : tab, parent.getBlock(), false);
}

@Override
public boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
BlockState parentState = parent.getBlock().defaultBlockState();
return parent.getModule().zeta.blockExtensions.get(parentState).isFlammableZeta(parentState, world, pos, face);
return parent.getModule().zeta().blockExtensions.get(parentState).isFlammableZeta(parentState, world, pos, face);
}

@Override
public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
BlockState parentState = parent.getBlock().defaultBlockState();
return parent.getModule().zeta.blockExtensions.get(parentState).getFlammabilityZeta(parentState, world, pos, face);
return parent.getModule().zeta().blockExtensions.get(parentState).getFlammabilityZeta(parentState, world, pos, face);
}

@Nullable
Expand All @@ -68,11 +68,10 @@ public boolean doesConditionApply() {
return enabledSupplier.getAsBoolean();
}

@Nullable
@Override
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
BlockState parentState = parent.getBlock().defaultBlockState();
return parent.getModule().zeta.blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
return parent.getModule().zeta().blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ZetaStandingSignBlock(String regname, @Nullable ZetaModule module, WoodTy
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, false);
module.zeta().registry.registerBlock(this, regname, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public ZetaTrapdoorBlock(BlockSetType setType, String regname, ZetaModule module
if(module == null) //auto registration below this line
throw new IllegalArgumentException("Must provide a module for ZetaTrapdoorBlock"); //isLadderZeta

module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
module.zeta.registry.registerBlock(this, regname, true);
module.zeta().renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
module.zeta().registry.registerBlock(this, regname, true);
CreativeTabManager.addToCreativeTab(CreativeModeTabs.BUILDING_BLOCKS, this);
CreativeTabManager.addToCreativeTab(CreativeModeTabs.REDSTONE_BLOCKS, this);
}
Expand All @@ -39,7 +39,7 @@ public boolean isLadderZeta(BlockState state, LevelReader level, BlockPos pos, L
if(state.getValue(OPEN)) {
BlockPos downPos = pos.below();
BlockState down = level.getBlockState(downPos);
return module.zeta.blockExtensions.get(down).makesOpenTrapdoorAboveClimbableZeta(down, level, downPos, state);
return module.zeta().blockExtensions.get(down).makesOpenTrapdoorAboveClimbableZeta(down, level, downPos, state);
} else return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/violetmoon/zeta/block/ZetaVineBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public ZetaVineBlock(@Nullable ZetaModule module, String name, boolean creative)
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, name, true);
module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
module.zeta().registry.registerBlock(this, name, true);
module.zeta().renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);

if (creative)
setCreativeTab(CreativeModeTabs.NATURAL_BLOCKS);
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/violetmoon/zeta/block/ZetaWallBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public ZetaWallBlock(IZetaBlock parent, @Nullable ResourceKey<CreativeModeTab> t
if(module == null)
throw new IllegalArgumentException("Can only create ZetaWallBlock with blocks belonging to a module"); //getBeaconColorMultiplierZeta

String resloc = module.zeta.registryUtil.inheritQuark(parent, "%s_wall");
parent.getModule().zeta.registry.registerBlock(this, resloc, true);
parent.getModule().zeta.renderLayerRegistry.mock(this, parent.getBlock());
String resloc = module.zeta().registryUtil.inheritQuark(parent, "%s_wall");
parent.getModule().zeta().registry.registerBlock(this, resloc, true);
parent.getModule().zeta().renderLayerRegistry.mock(this, parent.getBlock());
setCreativeTab(tab == null ? CreativeModeTabs.BUILDING_BLOCKS : tab, parent.getBlock(), false);
}

Expand All @@ -54,11 +54,10 @@ public boolean doesConditionApply() {
return enabledSupplier.getAsBoolean();
}

@Nullable
@Override
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
BlockState parentState = parent.getBlock().defaultBlockState();
return parent.getModule().zeta.blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
return parent.getModule().zeta().blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ZetaWallHangingSignBlock(String regname, @Nullable ZetaModule module, Woo
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, false);
module.zeta().registry.registerBlock(this, regname, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ZetaWallSignBlock(String regname, ZetaModule module, WoodType type, Prope
if(module == null) //auto registration below this line
return;

module.zeta.registry.registerBlock(this, regname, false);
module.zeta().registry.registerBlock(this, regname, false);
}

@Override
Expand Down
Loading

0 comments on commit 0090b77

Please sign in to comment.