Skip to content

Commit

Permalink
Yeah but cool
Browse files Browse the repository at this point in the history
  • Loading branch information
Siuolplex committed Nov 24, 2023
1 parent db9aac4 commit 2c3bbbd
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.util.Mth;
import net.minecraft.world.entity.vehicle.Boat;
import org.jetbrains.annotations.NotNull;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.client.handler.ModelHandler;
Expand Down Expand Up @@ -66,7 +67,7 @@ public void render(Boat boat, float yaw, float partialTicks, PoseStack matrix, @

float f2 = boat.getBubbleAngle(partialTicks);
if (!Mth.equal(f2, 0.0F)) {
matrix.mulPose(new Quaternion(new Vector3f(1.0F, 0.0F, 1.0F), boat.getBubbleAngle(partialTicks), true));
matrix.mulPose(new Quaternionf(1.0F, 0.0F, 1.0F, boat.getBubbleAngle(partialTicks) * ((float)Math.PI / 180F)));
}

BoatModelTuple tuple = getModelWithLocation(boat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected ItemStack execute(BlockSource source, @NotNull ItemStack stack) {
JukeboxBlockEntity jukebox = (JukeboxBlockEntity) world.getBlockEntity(pos);
if (jukebox != null) {
ItemStack currentRecord = jukebox.getItem(0);
((JukeboxBlock) state.getBlock()).setRecord(null, world, pos, state, stack);
((JukeboxBlock) (state.getBlock())).setRecord(null, world, pos, state, stack);
world.levelEvent(null, LevelEvent.SOUND_PLAY_JUKEBOX_SONG, pos, Item.getId(stack.getItem()));

return currentRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.client.render.GenericChestBERenderer;
import org.violetmoon.quark.content.building.module.VariantChestsModule.IChestTextureProvider;
import org.violetmoon.zeta.client.event.load.ZPreTextureStitch;

public class VariantChestRenderer extends GenericChestBERenderer<ChestBlockEntity> {

Expand All @@ -38,31 +37,6 @@ public Material getMaterial(ChestBlockEntity t, ChestType type) {
};
}

public static void accept(ZPreTextureStitch event, Block chest) {
ResourceLocation atlas = event.getAtlas().location();

if(chest instanceof IChestTextureProvider prov) {

String path = prov.getChestTexturePath();
if (prov.isTrap())
add(event, atlas, chest, path, "trap", "trap_left", "trap_right");
else
add(event, atlas, chest, path, "normal", "left", "right");
}
}

private static void add(ZPreTextureStitch event, ResourceLocation atlas, Block chest, String path, String normal, String left, String right) {
ResourceLocation resNormal = new ResourceLocation(Quark.MOD_ID, path + normal);
ResourceLocation resLeft = new ResourceLocation(Quark.MOD_ID, path + left);
ResourceLocation resRight = new ResourceLocation(Quark.MOD_ID, path + right);

ChestTextureBatch batch = new ChestTextureBatch(atlas, resNormal, resLeft, resRight);
chestTextures.put(chest, batch);

event.addSprite(resNormal);
event.addSprite(resLeft);
event.addSprite(resRight);
}

private static class ChestTextureBatch {
public final Material normal, left, right;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.violetmoon.quark.mixin.accessor.AccessorAbstractChestedHorse;
import org.violetmoon.zeta.client.SimpleWithoutLevelRenderer;
import org.violetmoon.zeta.client.event.load.ZClientSetup;
import org.violetmoon.zeta.client.event.load.ZPreTextureStitch;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.bus.PlayEvent;
import org.violetmoon.zeta.event.load.ZConfigChanged;
Expand Down Expand Up @@ -333,14 +332,5 @@ public final void clientSetup(ZClientSetup event) {
QuarkClient.ZETA_CLIENT.setBlockEntityWithoutLevelRenderer(b.asItem(), new SimpleWithoutLevelRenderer(trappedChestTEType, b.defaultBlockState()));
}

@LoadEvent
public void textureStitch(ZPreTextureStitch event) {
if (event.getAtlas().location().toString().equals("minecraft:textures/atlas/chest.png")) {
for (Block b : allChests)
VariantChestRenderer.accept(event, b);
ILootrIntegration.INSTANCE.stitch(event);
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public boolean click() {
lastShareTimestamp = mc.level.getGameTime();
} else return false;

if (mc.player instanceof AccessorLocalPlayer accessorLocalPlayer) {
/*if (mc.player instanceof AccessorLocalPlayer accessorLocalPlayer) {
Component itemComp = stack.getDisplayName();
String rawMessage = SharedConstants.filterText(itemComp.getString());
Expand All @@ -93,7 +93,7 @@ public boolean click() {
return true;
}
}
}*/
}
}
}
Expand All @@ -107,7 +107,7 @@ public static void shareItem(ServerPlayer player, String message, ItemStack stac

Component itemComp = stack.getDisplayName();

((AccessorServerGamePacketListenerImpl) player.connection).quark$chatPreviewCache().set(message, itemComp);
//((AccessorServerGamePacketListenerImpl) player.connection).quark$chatPreviewCache().set(message, itemComp);

player.connection.handleChat(new ServerboundChatPacket(message, timeStamp, salt, signature, lastSeenMessages));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public CustomEmoteDescriptor(String name, String regName, int index) {

public static ResourceLocation getSprite(String name) {
ResourceLocation customRes = new ResourceLocation(EmoteHandler.CUSTOM_EMOTE_NAMESPACE, name);
if(EmotesModule.Client.resourcePack.hasResource(PackType.CLIENT_RESOURCES, customRes))
//if(EmotesModule.Client.resourcePack.hasResource(PackType.CLIENT_RESOURCES, customRes))
if(EmotesModule.Client.resourcePack.hasResource(name))
return customRes;

return new ResourceLocation("quark", "textures/emote/custom.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -32,37 +34,63 @@ public class CustomEmoteIconResourcePack extends AbstractPackResources {
private final List<String> existingNames = new ArrayList<>();

public CustomEmoteIconResourcePack() {
super(EmotesModule.emotesDir);
super("quark-emote-pack", true);
//super(EmotesModule.emotesDir);
}

@NotNull
@Nullable
@Override
public Set<String> getNamespaces(@NotNull PackType type) {
if (type == PackType.CLIENT_RESOURCES)
return ImmutableSet.of(EmoteHandler.CUSTOM_EMOTE_NAMESPACE);
return ImmutableSet.of();
public IoSupplier<InputStream> getRootResource(String... p_252049_) {
return null;
}

@NotNull
//Todo: Dawg this shit is probably broken as hell - Siuol
@Nullable
@Override
protected InputStream getResource(@NotNull String name) throws IOException {
if(name.equals("pack.mcmeta"))
return Quark.class.getResourceAsStream("/proxypack.mcmeta");
public IoSupplier<InputStream> getResource(PackType packType, ResourceLocation name) {
if(name.getPath().equals("pack.mcmeta")) {
try {
return IoSupplier.create(Path.of(Quark.class.getResource("/proxypack.mcmeta").toURI()));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}

if(name.equals("pack.png"))
return Quark.class.getResourceAsStream("/proxypack.png");
if(name.getPath().equals("pack.png")) {
try {
return IoSupplier.create(Path.of(Quark.class.getResource("/proxypack.png").toURI()));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}

File file = getFile(name);
File file = getFile(name.getPath());
if(!file.exists())
throw new FileNotFoundException(name);
try {
throw new FileNotFoundException(name.getPath());
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}

return IoSupplier.create(file.toPath());
}

@Override
public void listResources(PackType p_10289_, String p_251379_, String p_251932_, ResourceOutput p_249347_) {

return new FileInputStream(file);
}

@NotNull
@Override
public Set<String> getNamespaces(@NotNull PackType type) {
if (type == PackType.CLIENT_RESOURCES)
return ImmutableSet.of(EmoteHandler.CUSTOM_EMOTE_NAMESPACE);
return ImmutableSet.of();
}

@NotNull
public Collection<ResourceLocation> getResources(@NotNull PackType type, @NotNull String pathIn, @NotNull String idk, @NotNull Predicate<ResourceLocation> filter) {
File rootPath = new File(this.file, type.getDirectory());
File rootPath = new File(this.getFile(idk), type.getDirectory());
List<ResourceLocation> allResources = Lists.newArrayList();

for (String namespace : this.getNamespaces(type))
Expand Down Expand Up @@ -94,7 +122,6 @@ public void close() {
// NO-OP
}

@Override
protected boolean hasResource(@NotNull String name) {
if(!verifiedNames.contains(name)) {
File file = getFile(name);
Expand All @@ -118,10 +145,10 @@ public boolean isHidden() {
return true;
}

@NotNull
/*@NotNull
@Override
public String getName() {
return "quark-emote-pack";
}
}*/

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public void onReady(ZModulesReady e) {
if(!emotesDir.exists())
emotesDir.mkdirs();

//todo: Fixme or something idk - Siuolplex
/*
mc.getResourcePackRepository().addPackFinder(new RepositorySource() {
@Override
public void loadPacks(@NotNull Consumer<Pack> packConsumer, @NotNull Pack.PackConstructor packInfoFactory) {
Expand All @@ -120,7 +122,7 @@ public void loadPacks(@NotNull Consumer<Pack> packConsumer, @NotNull Pack.PackCo
Pack t = Pack.create(name, true, () -> Client.resourcePack, packInfoFactory, Pack.Position.TOP, tx->tx);
packConsumer.accept(t);
}
});
});*/
}

@LoadEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static Biome makeBiome() {

settings.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, ORE_LAPIS_EXTRA);

Music music = Musics.createGameMusic(QuarkSounds.MUSIC_GLIMMERING_WEALD);
Music music = Musics.createGameMusic(Holder.direct(QuarkSounds.MUSIC_GLIMMERING_WEALD));
Biome biome = OverworldBiomes.biome(Biome.Precipitation.RAIN, 0.8F, 0.4F, mobs, settings, music);

return biome;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import org.jetbrains.annotations.Nullable;

import org.violetmoon.zeta.client.event.load.ZPreTextureStitch;

/**
* @author WireSegal
* Created at 11:40 AM on 7/3/23.
Expand Down Expand Up @@ -52,9 +50,4 @@ default void loadComplete() {
default void clientSetup() {
// NO-OP
}

@OnlyIn(Dist.CLIENT)
default void stitch(ZPreTextureStitch event) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.violetmoon.quark.content.building.module.VariantChestsModule;
import org.violetmoon.quark.integration.lootr.client.LootrVariantChestRenderer;
import org.violetmoon.zeta.client.SimpleWithoutLevelRenderer;
import org.violetmoon.zeta.client.event.load.ZPreTextureStitch;

import java.util.HashMap;
import java.util.LinkedList;
Expand Down Expand Up @@ -72,11 +71,6 @@ public void postRegister() {
Quark.ZETA.registry.register(trappedChestTEType, "lootr_variant_trapped_chest", Registries.BLOCK_ENTITY_TYPE);
}

@Override
public void loadComplete() {
ModBlocks.getSpecialLootChests().addAll(allChests);
}

@Override
@OnlyIn(Dist.CLIENT)
public void clientSetup() {
Expand All @@ -88,11 +82,4 @@ public void clientSetup() {
for(Block b : trappedChests)
QuarkClient.ZETA_CLIENT.setBlockEntityWithoutLevelRenderer(b.asItem(), new SimpleWithoutLevelRenderer(trappedChestTEType, b.defaultBlockState()));
}

@Override
@OnlyIn(Dist.CLIENT)
public void stitch(ZPreTextureStitch event) {
for (Block b : allChests)
LootrVariantChestRenderer.accept(event, b);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.violetmoon.quark.base.client.render.GenericChestBERenderer;
import org.violetmoon.quark.content.building.module.VariantChestsModule;
import org.violetmoon.quark.integration.lootr.LootrVariantChestBlockEntity;
import org.violetmoon.zeta.client.event.load.ZPreTextureStitch;

public class LootrVariantChestRenderer<T extends LootrVariantChestBlockEntity> extends GenericChestBERenderer<T> {
private UUID playerId = null;
Expand Down Expand Up @@ -57,32 +56,6 @@ public Material getMaterial(T tile, ChestType type) {
}
}

public static void accept(ZPreTextureStitch event, Block chest) {
ResourceLocation atlas = event.getAtlas().location();

if(chest instanceof VariantChestsModule.IChestTextureProvider prov) {

String path = prov.getChestTexturePath();
if (prov.isTrap())
add(event, atlas, chest, path, "trap", "lootr_trap", "lootr_trap_opened");
else
add(event, atlas, chest, path, "normal", "lootr_normal", "lootr_opened");
}
}

private static void add(ZPreTextureStitch event, ResourceLocation atlas, Block chest, String path, String baseSuffix, String unopenedSuffix, String openedSuffix) {
ResourceLocation resBase = new ResourceLocation(Quark.MOD_ID, path + baseSuffix);
ResourceLocation resUnopened = new ResourceLocation(Quark.MOD_ID, path + unopenedSuffix);
ResourceLocation resOpened = new ResourceLocation(Quark.MOD_ID, path + openedSuffix);

ChestTextureBatch batch = new ChestTextureBatch(atlas, resBase, resUnopened, resOpened);
chestTextures.put(chest, batch);

// No need to register base texture, it will have been handled in VariantChestRenderer
event.addSprite(resUnopened);
event.addSprite(resOpened);
}


private static class ChestTextureBatch {
public final Material base, unopened, opened;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Set;

import net.minecraft.advancements.critereon.ItemUsedOnLocationTrigger;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import org.violetmoon.zeta.api.IMutableAdvancement;
import org.violetmoon.zeta.advancement.AdvancementModifier;
import org.violetmoon.zeta.module.ZetaModule;
Expand Down Expand Up @@ -43,7 +44,7 @@ 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) {
Set<Block> blockSet = iib.location.block.blocks;
Set<Block> blockSet = iib.location;
if(blockSet != null) {
Set<Block> ourSet = res.equals(TARGET_ON) ? unwaxed : waxed;

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,6 @@ public net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase f_283
protected net.minecraft.world.level.block.CropBlock m_7959_()Lnet/minecraft/world/level/block/state/properties/IntegerProperty; # getAgeProperty TODO fix me beautiful
public net.minecraft.data.worldgen.biome.OverworldBiomes m_264144_(ZFFLnet/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-f net.minecraft.advancements.critereon.ItemUsedOnLocationTrigger$TriggerInstance f_285570_ # location
public-f net.minecraft.advancements.critereon.ContextAwarePredicate f_285622_ # conditions
public-f net.minecraft.advancements.critereon.ContextAwarePredicate f_285559_ # compositePredicates

Loading

0 comments on commit 2c3bbbd

Please sign in to comment.