Skip to content

Commit

Permalink
Welcome to Siuol's attempt to make this get closer to compiling
Browse files Browse the repository at this point in the history
This is... Fun...

Signed-off-by: Siuolplex <lmeitrodt@gmail.com>
  • Loading branch information
Siuolplex committed Jul 9, 2024
1 parent 5464f85 commit c92c540
Show file tree
Hide file tree
Showing 56 changed files with 164 additions and 316 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Set;
import java.util.function.BooleanSupplier;

import net.minecraft.advancements.AdvancementHolder;
import org.violetmoon.zeta.Zeta;
import org.violetmoon.zeta.advancement.modifier.ASeedyPlaceModifier;
import org.violetmoon.zeta.advancement.modifier.AdventuringTimeModifier;
Expand Down Expand Up @@ -50,7 +51,7 @@ public AdvancementModifierRegistry(Zeta zeta) {
public ManualTrigger registerManualTrigger(String resloc) {
ResourceLocation id = zeta.registry.newResourceLocation(resloc);
ManualTrigger trigger = new ManualTrigger(id);
CriteriaTriggers.register(trigger);
CriteriaTriggers.register(id.toString(), trigger);
return trigger;
}

Expand Down Expand Up @@ -85,21 +86,21 @@ public IAdvancementModifierDelegate getDelegate() {

private void onAdvancementsLoaded(ServerAdvancementManager manager) {
for(ResourceLocation res : modifiers.keySet()) {
Advancement adv = manager.getAdvancement(res);
AdvancementHolder advHolder = manager.get(res);

if(adv != null) {
if(advHolder != null) {
Collection<IAdvancementModifier> found = modifiers.get(res);

if(!found.isEmpty()) {
int modifications = 0;
MutableAdvancement mutable = new MutableAdvancement(adv);
MutableAdvancement mutable = new MutableAdvancement(advHolder.value());

for(IAdvancementModifier mod : found)
if(mod.isActive() && mod.apply(res, mutable))
modifications++;

if(modifications > 0) {
zeta.log.info("Modified advancement {} with {} patches", adv.getId(), modifications);
zeta.log.info("Modified advancement {} with {} patches", advHolder.id(), modifications);
mutable.commit();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void mutabilize() {
}

public void commit() {
advancement.criteria = ImmutableMap.copyOf(criteria);
advancement.criteria() = ImmutableMap.copyOf(criteria);

List<String[]> requirementArrays = new ArrayList<>();
for(List<String> list : requirements) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class ASeedyPlaceModifier extends AdvancementModifier {

private static final ResourceLocation TARGET = new ResourceLocation("husbandry/plant_seed");
private static final ResourceLocation TARGET = ResourceLocation.withDefaultNamespace("husbandry/plant_seed");

final Set<Block> seeds;

Expand All @@ -34,7 +34,7 @@ public Set<ResourceLocation> getTargets() {
@Override
public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
for(var block : seeds) {
Criterion criterion = new Criterion(EnterBlockTrigger.TriggerInstance.entersBlock(block));
Criterion criterion = EnterBlockTrigger.TriggerInstance.entersBlock(block);

String name = BuiltInRegistries.BLOCK.getKey(block).toString();
adv.addOrCriterion(name, criterion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class AdventuringTimeModifier extends AdvancementModifier {

private static final ResourceLocation TARGET = new ResourceLocation("adventure/adventuring_time");
private static final ResourceLocation TARGET = ResourceLocation.withDefaultNamespace("adventure/adventuring_time");

private final Set<ResourceKey<Biome>> locations;

Expand All @@ -37,7 +37,7 @@ public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
String name = key.location().toString();

Criterion criterion = new Criterion(PlayerTrigger.TriggerInstance.located(
LocationPredicate.inBiome(key)));
LocationPredicate.inBiome(key))); //todo: I dunno how to do codec
adv.addRequiredCriterion(name, criterion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@

public class BalancedDietModifier extends AdvancementModifier {

private static final ResourceLocation TARGET = new ResourceLocation("husbandry/balanced_diet");
private static final ResourceLocation TARGET = ResourceLocation.withDefaultNamespace("husbandry/balanced_diet");

private final Set<ItemLike> items;

public BalancedDietModifier(ZetaModule module, Set<ItemLike> items) {
super(module);
this.items = items;
Preconditions.checkArgument(!items.isEmpty(), "Advancement modifier list cant be empty");

}

@Override
Expand All @@ -37,14 +36,9 @@ public Set<ResourceLocation> getTargets() {
@Override
public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
ItemLike[] array = items.toArray(ItemLike[]::new);

Criterion criterion = new Criterion(ConsumeItemTrigger.TriggerInstance.usedItem(
ItemPredicate.Builder.item().of(array).build()));

Criterion criterion = ConsumeItemTrigger.TriggerInstance.usedItem(ItemPredicate.Builder.item().of(array));
String name = BuiltInRegistries.ITEM.getKey(array[0].asItem()).toString();

adv.addRequiredCriterion(name, criterion);

return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.violetmoon.zeta.advancement.modifier;

import java.util.Optional;
import java.util.Set;

import org.violetmoon.zeta.advancement.AdvancementModifier;
Expand All @@ -19,7 +20,7 @@

public class FishyBusinessModifier extends AdvancementModifier {

private static final ResourceLocation TARGET = new ResourceLocation("husbandry/fishy_business");
private static final ResourceLocation TARGET = ResourceLocation.withDefaultNamespace("husbandry/fishy_business");

final Set<ItemLike> fishes;

Expand All @@ -38,11 +39,9 @@ public Set<ResourceLocation> getTargets() {
public boolean apply(ResourceLocation res, IMutableAdvancement adv) {

ItemLike[] array = fishes.toArray(ItemLike[]::new);
Criterion criterion = new Criterion(FishingRodHookedTrigger.
Criterion criterion = FishingRodHookedTrigger.
TriggerInstance.fishedItem(
ItemPredicate.ANY,
EntityPredicate.ANY,
ItemPredicate.Builder.item().of(array).build()));
Optional.empty(), Optional.empty(), Optional.of(ItemPredicate.Builder.item().of(array).build()));

String name = BuiltInRegistries.ITEM.getKey(array[0].asItem()).toString();
adv.addOrCriterion(name, criterion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

public class FuriousCocktailModifier extends AdvancementModifier {

private static final ResourceLocation TARGET_AP = new ResourceLocation("nether/all_potions");
private static final ResourceLocation TARGET_AE = new ResourceLocation("nether/all_effects");
private static final ResourceLocation TARGET_AP = ResourceLocation.withDefaultNamespace("nether/all_potions");
private static final ResourceLocation TARGET_AE = ResourceLocation.withDefaultNamespace("nether/all_effects");

final BooleanSupplier isPotion;
final Set<MobEffect> effects;
Expand All @@ -40,9 +40,11 @@ public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
return false;

Criterion crit = adv.getCriterion("all_effects");
if(crit != null && crit.getTrigger() instanceof EffectsChangedTrigger.TriggerInstance ect) {
if(crit != null && crit.triggerInstance() instanceof EffectsChangedTrigger.TriggerInstance ect) {

for(MobEffect e : effects)
ect.effects.and(e);
ect.effects().and(e);


return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class GlowAndBeholdModifier extends AdvancementModifier {

private static final ResourceLocation TARGET = new ResourceLocation("husbandry/make_a_sign_glow");
private static final ResourceLocation TARGET = ResourceLocation.withDefaultNamespace("husbandry/make_a_sign_glow");

final Set<Block> blocks;

Expand All @@ -40,12 +40,11 @@ public Set<ResourceLocation> getTargets() {
public boolean apply(ResourceLocation res, IMutableAdvancement adv) {

Block[] array = blocks.toArray(Block[]::new);
Criterion criterion = new Criterion(ItemUsedOnLocationTrigger.
TriggerInstance.itemUsedOnBlock(
LocationPredicate.Builder.location().setBlock(
BlockPredicate.Builder.block()
.of(array).build()),
ItemPredicate.Builder.item().of(Items.GLOW_INK_SAC)));
Criterion criterion = ItemUsedOnLocationTrigger.TriggerInstance.itemUsedOnBlock(
LocationPredicate.Builder.location().setBlock(
BlockPredicate.Builder.block()
.of(array)),
ItemPredicate.Builder.item().of(Items.GLOW_INK_SAC));

String name = BuiltInRegistries.BLOCK.getKey(array[0]).toString();
adv.addOrCriterion(name, criterion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

public class MonsterHunterModifier extends AdvancementModifier {

private static final ResourceLocation TARGET_ONE = new ResourceLocation("adventure/kill_a_mob");
private static final ResourceLocation TARGET_ALL = new ResourceLocation("adventure/kill_all_mobs");
private static final ResourceLocation TARGET_ONE = ResourceLocation.withDefaultNamespace("adventure/kill_a_mob");
private static final ResourceLocation TARGET_ALL = ResourceLocation.withDefaultNamespace("adventure/kill_all_mobs");

final Set<EntityType<?>> entityTypes;

Expand All @@ -39,7 +39,7 @@ public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
boolean all = res.equals(TARGET_ALL);

for(EntityType<?> type : entityTypes) {
Criterion criterion = new Criterion(KilledTrigger.TriggerInstance.playerKilledEntity(EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(type))));
Criterion criterion = KilledTrigger.TriggerInstance.playerKilledEntity(EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(type)));

String name = BuiltInRegistries.ENTITY_TYPE.getKey(type).toString();
if(all)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class TacticalFishingModifier extends AdvancementModifier {

private static final ResourceLocation TARGET = new ResourceLocation("husbandry/tactical_fishing");
private static final ResourceLocation TARGET = ResourceLocation.withDefaultNamespace("husbandry/tactical_fishing");

final Set<BucketItem> bucketItems;

Expand All @@ -38,9 +38,8 @@ public Set<ResourceLocation> getTargets() {
public boolean apply(ResourceLocation res, IMutableAdvancement adv) {

ItemLike[] array = bucketItems.toArray(ItemLike[]::new);
Criterion criterion = new Criterion(FilledBucketTrigger.
TriggerInstance.filledBucket(ItemPredicate.Builder.item()
.of(array).build()));
Criterion<FilledBucketTrigger.TriggerInstance> criterion = FilledBucketTrigger.TriggerInstance.filledBucket(
ItemPredicate.Builder.item().of(array));

String name = BuiltInRegistries.ITEM.getKey(array[0].asItem()).toString();
adv.addOrCriterion(name, criterion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class TwoByTwoModifier extends AdvancementModifier {

private static final ResourceLocation TARGET = new ResourceLocation("husbandry/bred_all_animals");
private static final ResourceLocation TARGET = ResourceLocation.withDefaultNamespace("husbandry/bred_all_animals");

final Set<EntityType<?>> entityTypes;

Expand All @@ -39,8 +39,8 @@ public Set<ResourceLocation> getTargets() {
@Override
public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
for(EntityType<?> type : entityTypes) {
Criterion criterion = new Criterion(BredAnimalsTrigger.TriggerInstance
.bredAnimals(EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(type))));
Criterion criterion = BredAnimalsTrigger.TriggerInstance
.bredAnimals(EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(type)));

String name = BuiltInRegistries.ENTITY_TYPE.getKey(type).toString();
adv.addRequiredCriterion(name, criterion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

public class WaxModifier extends AdvancementModifier {

private static final ResourceLocation TARGET_ON = new ResourceLocation("husbandry/wax_on");
private static final ResourceLocation TARGET_OFF = new ResourceLocation("husbandry/wax_off");
private static final ResourceLocation TARGET_ON = ResourceLocation.withDefaultNamespace("husbandry/wax_on");
private static final ResourceLocation TARGET_OFF = ResourceLocation.withDefaultNamespace("husbandry/wax_off");

private final Set<Block> unwaxed;
private final Set<Block> waxed;
Expand All @@ -46,20 +46,20 @@ public Set<ResourceLocation> getTargets() {
public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
String title = res.getPath().replaceAll(".+/", "");
Criterion criterion = adv.getCriterion(title);
if(criterion != null && criterion.getTrigger() instanceof ItemUsedOnLocationTrigger.TriggerInstance iib) {
if(criterion != null && criterion.triggerInstance() instanceof ItemUsedOnLocationTrigger.TriggerInstance iib) {
// Yes I know its wordy, yes I know this is stupid. Please forgive me I couldnt make it better.
iib.location.compositePredicates = (res.equals(TARGET_ON)) ? iib.location.compositePredicates
iib.location().get().compositePredicates = (res.equals(TARGET_ON)) ? iib.location().get().compositePredicates //todo: AccessWidener
.or(ItemUsedOnLocationTrigger.TriggerInstance.itemUsedOnBlock(
LocationPredicate.Builder.location().setBlock(
BlockPredicate.Builder.block().of(unwaxed).build()),
BlockPredicate.Builder.block().of(unwaxed)),
ItemPredicate.Builder.item().of(Items.HONEYCOMB))
.location.compositePredicates
) : iib.location.compositePredicates
.triggerInstance().location().get().compositePredicates
) : iib.location().get().compositePredicates
.or(ItemUsedOnLocationTrigger.TriggerInstance.itemUsedOnBlock(
LocationPredicate.Builder.location().setBlock(
BlockPredicate.Builder.block().of(waxed).build()),
BlockPredicate.Builder.block().of(waxed)),
ItemPredicate.Builder.item().of(ItemTags.AXES))
.location.compositePredicates);
.triggerInstance().location().get().compositePredicates);
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/violetmoon/zeta/block/ZetaButtonBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public abstract class ZetaButtonBlock extends ButtonBlock implements IZetaBlock
private final @Nullable ZetaModule module;
private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE;

public ZetaButtonBlock(BlockSetType setType, int ticksToStayPressed, boolean arrowsCanPress, String regname, @Nullable ZetaModule module, Properties properties) {
super(properties, setType, ticksToStayPressed, arrowsCanPress);
public ZetaButtonBlock(BlockSetType setType, int ticksToStayPressed, String regname, @Nullable ZetaModule module, Properties properties) {
super(setType, ticksToStayPressed, properties);
this.module = module;

if(module == null) //auto registration below this line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ public ZetaInheritedPaneBlock(IZetaBlock parent, Block.Properties properties) {
}

public ZetaInheritedPaneBlock(IZetaBlock parent) {
this(parent, Block.Properties.copy(parent.getBlock()));
this(parent, Block.Properties.ofFullCopy(parent.getBlock()));
}

@Override
public boolean isEnabled() {
return super.isEnabled() && parent.isEnabled();
}

@Nullable
@Override
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
public Integer 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class ZetaPressurePlateBlock extends PressurePlateBlock implements IZetaB
private final @Nullable ZetaModule module;
private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE;

public ZetaPressurePlateBlock(Sensitivity sensitivity, String regname, @Nullable ZetaModule module, Properties properties, BlockSetType blockSetType) {
super(sensitivity, properties, blockSetType);
public ZetaPressurePlateBlock(String regname, @Nullable ZetaModule module, BlockSetType blockSetType, Properties properties) {
super(blockSetType, properties);
this.module = module;

if(module == null) //auto registration below this line
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/violetmoon/zeta/block/ZetaSlabBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ public boolean doesConditionApply() {
return enabledSupplier.getAsBoolean();
}

@Nullable
@Override
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
public Integer 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);
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/violetmoon/zeta/block/ZetaStairsBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ZetaStairsBlock extends StairBlock implements IZetaBlock, IZetaBloc
private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE;

public ZetaStairsBlock(IZetaBlock parent, @Nullable ResourceKey<CreativeModeTab> tab) {
super(parent.getBlock()::defaultBlockState, VariantRegistry.realStateCopy(parent));
super(parent.getBlock().defaultBlockState(), VariantRegistry.realStateCopy(parent));

this.parent = parent;

Expand Down Expand Up @@ -68,9 +68,8 @@ public boolean doesConditionApply() {
return enabledSupplier.getAsBoolean();
}

@Nullable
@Override
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
public Integer 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ZetaStandingSignBlock extends StandingSignBlock implements IZetaBlo
private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE;

public ZetaStandingSignBlock(String regname, @Nullable ZetaModule module, WoodType type, Properties properties) {
super(properties, type);
super(type, properties);
this.module = module;

if(module == null) //auto registration below this line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ZetaTrapdoorBlock extends TrapDoorBlock implements IZetaBlock {
private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE;

public ZetaTrapdoorBlock(BlockSetType setType, String regname, ZetaModule module, Properties properties) {
super(properties, setType);
super(setType, properties);
this.module = module;

if(module == null) //auto registration below this line
Expand Down
Loading

0 comments on commit c92c540

Please sign in to comment.