Skip to content

Commit

Permalink
game boots :O
Browse files Browse the repository at this point in the history
  • Loading branch information
MehVahdJukaar committed Jul 31, 2024
1 parent a506c21 commit e7cd5e7
Show file tree
Hide file tree
Showing 22 changed files with 268 additions and 479 deletions.
5 changes: 1 addition & 4 deletions src/main/java/org/violetmoon/zeta/Zeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ public EntitySpawnHandler createEntitySpawnHandler() {

public abstract ZetaNetworkHandler createNetworkHandler(int protocolVersion);

// event bus
public abstract <E, T extends E> T fireExternalEvent(T impl);

// ummmmmm why is this here
// ummmmmm why is this here??
public abstract boolean fireRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult bhr);

// Let's Jump
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.violetmoon.zeta.api.IAdvancementModifier;
import org.violetmoon.zeta.api.IAdvancementModifierDelegate;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.bus.PlayEvent;
import org.violetmoon.zeta.event.load.ZAddReloadListener;
import org.violetmoon.zeta.event.load.ZGatherAdvancementModifiers;

Expand All @@ -36,7 +37,10 @@
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import org.violetmoon.zetaimplforge.api.ForgeZGatherAdvancementModifiers;
import org.violetmoon.zetaimplforge.client.event.play.ForgeZEarlyRender;

//TODO: make this zeta-independent
public class AdvancementModifierRegistry {
protected final Zeta zeta;
protected final Multimap<ResourceLocation, IAdvancementModifier> modifiers = HashMultimap.create();
Expand All @@ -59,11 +63,11 @@ public void addModifier(IAdvancementModifier mod) {
modifiers.put(r, mod);
}

@LoadEvent
@PlayEvent
public void addListeners(ZAddReloadListener event) {
if(!gatheredAddons) {
IAdvancementModifierDelegate delegateImpl = new DelegateImpl();
zeta.loadBus.fireExternal(new ZGatherAdvancementModifiers() {
zeta.playBus.fire(new ZGatherAdvancementModifiers() {
@Override
public void register(IAdvancementModifier modifier) {
addModifier(modifier);
Expand All @@ -73,7 +77,7 @@ public void register(IAdvancementModifier modifier) {
public IAdvancementModifierDelegate getDelegate() {
return delegateImpl;
}
}, ZGatherAdvancementModifiers.class);
});

gatheredAddons = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.violetmoon.zeta.client.event.load.ZAddItemColorHandlers;
import org.violetmoon.zeta.client.event.load.ZClientSetup;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.load.ZLoadComplete;
import org.violetmoon.zeta.registry.DyeablesRegistry;
import org.violetmoon.zeta.registry.RenderLayerRegistry;
import org.violetmoon.zeta.registry.ZetaRegistry;
Expand Down Expand Up @@ -56,32 +57,16 @@ public void registerItemColorHandlers(ZAddItemColorHandlers event) {
}
}

//these are in Post events to give other listeners a chance to populate .registerNamed
@LoadEvent
public void registerBlockColorsPost(ZAddBlockColorHandlers.Post event) {
registry.finalizeBlockColors((block, name) -> {
Function<Block, BlockColor> blockColorCreator = event.getNamedBlockColors().get(name);
if(blockColorCreator == null)
z.log.error("Unknown block color creator {} used on block {}", name, block);
else
event.register(blockColorCreator.apply(block), block);
});
public void registerRenderLayers(ZClientSetup event) {
z.renderLayerRegistry.finalize(this::doSetRenderLayer);
}

@LoadEvent
public void registerItemColorsPost(ZAddItemColorHandlers.Post event) {
registry.finalizeItemColors((item, name) -> {
Function<Item, ItemColor> itemColorCreator = event.getNamedItemColors().get(name);
if(itemColorCreator == null)
z.log.error("Unknown item color creator {} used on item {}", name, item);
else
event.register(itemColorCreator.apply(item), item);
});
}

//I hope this won't run on dedicated servers
@LoadEvent
public void registerRenderLayers(ZClientSetup event) {
z.renderLayerRegistry.finalize(this::doSetRenderLayer);
public void onLoadComplete(ZLoadComplete event){
z.registry.validateColorsProviders();
}

protected abstract void doSetRenderLayer(Block block, RenderLayerRegistry.Layer layer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ public interface ZAddBlockColorHandlers extends IZetaLoadEvent {
void register(BlockColor c, Block... blocks);
void registerNamed(Function<Block, BlockColor> c, String... names);
BlockColors getBlockColors();

Post makePostEvent();
interface Post extends ZAddBlockColorHandlers {
Map<String, Function<Block, BlockColor>> getNamedBlockColors();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@ public interface ZAddItemColorHandlers extends IZetaLoadEvent {
void register(ItemColor c, ItemLike... items);
void registerNamed(Function<Item, ItemColor> c, String... names);
ItemColors getItemColors();

Post makePostEvent();
interface Post extends ZAddItemColorHandlers {
Map<String, Function<Item, ItemColor>> getNamedItemColors();
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/violetmoon/zeta/config/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public ConfigManager(Zeta z, Object rootPojo) {
}

//grab any extra flags
z.playBus.fire(new ForgeZGatherAdditionalFlags(cfm));
z.playBus.fire(() -> cfm,ZGatherAdditionalFlags.class);

//managing module enablement in one go
//adding this to the *start* of the list so modules are enabled before anything else runs
Expand All @@ -124,7 +124,7 @@ public ConfigManager(Zeta z, Object rootPojo) {
});

//update extra flags
z.playBus.fire(new ForgeZGatherAdditionalFlags(cfm));
z.playBus.fire(() -> cfm,ZGatherAdditionalFlags.class);
});

this.rootConfig = rootConfigBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,6 @@ private String logSpamSimpleName(Class<?> clazz) {
return split[split.length - 1];
}

public <T extends E> T fireExternal(@NotNull T event, Class<? super T> firedAs) {
event = fire(event, firedAs);

if(event instanceof Cancellable cancellable && cancellable.isCanceled())
return event;
else{
throw new RuntimeException();
//TODO: re add. this shuld be put in loader specific bus code
//return z.fireExternalEvent(event); // Interfaces with the platform-specific event bus utility
}

}

/**
* Picks out the "Foo" in "void handleFoo(Foo event)", and gets/creates the Listeners corresponding to that type.
*/
Expand Down
Loading

0 comments on commit e7cd5e7

Please sign in to comment.