Skip to content

Commit

Permalink
Fixed some classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bukachy committed Feb 2, 2025
1 parent 60cd2c7 commit 7dbed7b
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void renderExtra(PoseStack ms, ClientLevel world, float partialTic
tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX).addVertex(mat, scale, 100, -scale).setUv(1.0F, 0.0F);
tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX).addVertex(mat, scale, 100, scale).setUv(1.0F, 1.0F);
tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX).addVertex(mat, -scale, 100, scale).setUv(0.0F, 1.0F);
tessellator.end();
tessellator.clear();

switch (p) {
case 0 -> {
Expand Down Expand Up @@ -147,7 +147,7 @@ public static void renderExtra(PoseStack ms, ClientLevel world, float partialTic
}

}
tessellator.end();
tessellator.clear();

switch (p) {
case 0 -> {
Expand Down Expand Up @@ -209,7 +209,7 @@ public static void renderExtra(PoseStack ms, ClientLevel world, float partialTic
}

}
tessellator.end();
tessellator.clear();
ms.popPose();
RenderSystem.setShaderColor(1F, 1F, 1F, 1F - insideVoid);
GlStateManager._blendFuncSeparate(770, 1, 1, 0);
Expand Down
12 changes: 8 additions & 4 deletions Xplat/src/main/java/vazkii/botania/common/loot/LootHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
*/
package vazkii.botania.common.loot;

import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer;
import net.minecraft.world.level.storage.loot.entries.NestedLootTable;
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
Expand Down Expand Up @@ -50,7 +53,8 @@ public static void lootLoad(ResourceLocation id, Consumer<LootPool.Builder> addP
}
} else if (XplatAbstractions.INSTANCE.gogLoaded()
&& (Blocks.SHORT_GRASS.getLootTable().equals(id) || Blocks.TALL_GRASS.getLootTable().equals(id))) {
addPool.accept(LootPool.lootPool().add(NestedLootTable.lootTableReference(GOG_SEEDS_TABLE)));
ResourceKey<LootTable> gogSeedsKey = ResourceKey.create(Registries.LOOT_TABLE, GOG_SEEDS_TABLE);
addPool.accept(LootPool.lootPool().add(NestedLootTable.lootTableReference(gogSeedsKey)));
}
}

Expand All @@ -62,8 +66,8 @@ private static LootPool.Builder getInjectPool(String entryName) {

private static LootPoolEntryContainer.Builder<?> getInjectEntry(String name, int weight) {
ResourceLocation table = botaniaRL("inject/" + name);
return NestedLootTable.lootTableReference(table)
ResourceKey<LootTable> tableKey = ResourceKey.create(Registries.LOOT_TABLE, table);
return NestedLootTable.lootTableReference(tableKey)
.setWeight(weight);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class NaturalSpawnerMixin {
* Adds the naturally-spawned tag to slimes
*/
@ModifyArg(
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"),
method = "spawnCategoryForPosition(Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/NaturalSpawner$SpawnPredicate;Lnet/minecraft/world/level/NaturalSpawner$AfterSpawnCallback;)V"
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"),
method = "spawnCategoryForPosition(Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/NaturalSpawner$SpawnPredicate;Lnet/minecraft/world/level/NaturalSpawner$AfterSpawnCallback;)V"
)
private static Entity onSpawned(Entity entity) {
NarslimmusBlockEntity.onSpawn(entity);
Expand All @@ -48,8 +48,8 @@ private static void emptiness(ServerLevel world, Mob entity, double squaredDista
}

// Jump over entity.checkSpawnRules(pos, reason) and entity.checkSpawnObstruction(pos) under Bloodlust
@Inject(at = @At(value = "RETURN", ordinal = 1), cancellable = true, method = "isValidPositionForMob")
private static void bloodthirstOverride(ServerLevel world, Mob entity, double p_234974_2_, CallbackInfoReturnable<Boolean> cir) {
@Inject(at = @At("RETURN"), cancellable = true, method = "isValidPositionForMob")
private static void bloodthirstOverride(ServerLevel world, Mob entity, double distance, CallbackInfoReturnable<Boolean> cir) {
if (BloodthirstMobEffect.overrideSpawn(world, entity.blockPosition(), entity.getType().getCategory())) {
cir.setReturnValue(true);
}
Expand Down
15 changes: 6 additions & 9 deletions Xplat/src/main/java/vazkii/botania/mixin/PlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import vazkii.botania.common.PlayerAccess;
import vazkii.botania.common.item.ResoluteIvyItem;
import vazkii.botania.common.item.equipment.armor.terrasteel.TerrasteelHelmItem;
Expand All @@ -34,8 +31,8 @@ protected PlayerMixin(EntityType<? extends LivingEntity> type, Level level) {

// Perform damage source modifications and apply the potion effects.
@ModifyArg(
method = "attack",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z")
method = "attack",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z")
)
private DamageSource onDamageTarget(DamageSource source, float amount) {
if (this.terraWillCritTarget != null) {
Expand All @@ -48,16 +45,16 @@ private DamageSource onDamageTarget(DamageSource source, float amount) {

// Clear the entity on any return after the capture.
@Inject(
at = @At(value = "RETURN"), method = "attack",
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/EnchantmentHelper;getKnockbackBonus(Lnet/minecraft/world/entity/LivingEntity;)I"))
at = @At(value = "RETURN"),
method = "attack"
)
private void clearCritTarget(CallbackInfo ci) {
this.terraWillCritTarget = null;
}

@Inject(
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;dropAll()V"),
method = "dropEquipment"
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;dropAll()V"),
method = "dropEquipment"
)
private void captureIvyDrops(CallbackInfo ci) {
ResoluteIvyItem.keepDropsOnDeath((Player) (Object) this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package vazkii.botania.mixin;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;

import net.minecraft.world.level.storage.loot.LootTable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(RandomizableContainerBlockEntity.class)
public interface RandomizableContainerBlockEntityAccessor {
@Accessor
ResourceLocation getLootTable();
ResourceKey<LootTable> getLootTable();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.mojang.blaze3d.vertex.VertexBuffer;

import net.minecraft.client.Camera;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.GameRenderer;
Expand Down Expand Up @@ -70,40 +71,42 @@ private static boolean isGogSky() {
* Render planets and other extras, after the first invoke to ms.rotate(Y) after getRainLevel is called
*/
@Inject(
method = "renderSky",
slice = @Slice(
from = @At(
ordinal = 0, value = "INVOKE",
target = "Lnet/minecraft/client/multiplayer/ClientLevel;getRainLevel(F)F"
)
),
at = @At(
shift = At.Shift.AFTER,
ordinal = 0,
value = "INVOKE",
target = "Lcom/mojang/blaze3d/vertex/PoseStack;mulPose(Lorg/joml/Quaternionf;)V"
),
require = 0
method = "renderSky",
slice = @Slice(
from = @At(
ordinal = 0, value = "INVOKE",
target = "Lnet/minecraft/client/multiplayer/ClientLevel;getRainLevel(F)F"
)
),
at = @At(
shift = At.Shift.AFTER,
ordinal = 0,
value = "INVOKE",
target = "Lcom/mojang/blaze3d/vertex/PoseStack;mulPose(Lorg/joml/Quaternionf;)V"
),
require = 0
)
private void renderExtras(PoseStack ms, Matrix4f projMat, float partialTicks, Camera camera,
boolean foggy, Runnable resetFog, CallbackInfo ci) {
private void renderExtras(Matrix4f frustumMatrix, Matrix4f projectionMatrix, float partialTick, Camera camera,
boolean isFoggy, Runnable skyFogSetup, CallbackInfo ci) {
if (isGogSky()) {
SkyblockSkyRenderer.renderExtra(ms, Minecraft.getInstance().level, partialTicks, 0);
PoseStack poseStack = new PoseStack();
poseStack.mulPose(frustumMatrix);
SkyblockSkyRenderer.renderExtra(poseStack, Minecraft.getInstance().level, partialTick, 0);
}
}

/**
* Make the sun bigger by scaling it to double size
*/
@ModifyVariable(
method = "renderSky",
slice = @Slice(
from = @At(ordinal = 1, value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getTimeOfDay(F)F"),
to = @At(ordinal = 0, value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V")
),
at = @At(value = "CONSTANT", args = "floatValue=30.0"),
ordinal = 1,
require = 0
method = "renderSky",
slice = @Slice(
from = @At(ordinal = 1, value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getTimeOfDay(F)F"),
to = @At(ordinal = 0, value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V")
),
at = @At(value = "CONSTANT", args = "floatValue=30.0"),
ordinal = 1,
require = 0
)
private Matrix4f makeSunBigger(Matrix4f matrix) {
if (isGogSky()) {
Expand All @@ -118,14 +121,14 @@ private Matrix4f makeSunBigger(Matrix4f matrix) {
* Make the moon bigger by scaling it to triple size (the matrix is already scaled on the call above)
*/
@ModifyVariable(
method = "renderSky",
slice = @Slice(
from = @At(ordinal = 0, value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V"),
to = @At(ordinal = 1, value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V")
),
at = @At(value = "CONSTANT", args = "floatValue=20.0"),
ordinal = 1,
require = 0
method = "renderSky",
slice = @Slice(
from = @At(ordinal = 0, value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V"),
to = @At(ordinal = 1, value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V")
),
at = @At(value = "CONSTANT", args = "floatValue=20.0"),
ordinal = 1,
require = 0
)
private Matrix4f makeMoonBigger(Matrix4f matrix) {
if (isGogSky()) {
Expand All @@ -138,31 +141,34 @@ private Matrix4f makeMoonBigger(Matrix4f matrix) {
* Render lots of extra stars
*/
@Inject(
method = "renderSky",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getStarBrightness(F)F"),
require = 0
method = "renderSky",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getStarBrightness(F)F"),
require = 0
)
private void renderExtraStars(PoseStack ms, Matrix4f projMat, float partialTicks, Camera camera,
boolean foggy, Runnable resetFog, CallbackInfo ci) {
private void renderExtraStars(Matrix4f frustumMatrix, Matrix4f projectionMatrix, float partialTick, Camera camera,
boolean isFoggy, Runnable skyFogSetup, CallbackInfo ci) {
if (isGogSky()) {
SkyblockSkyRenderer.renderStars(starBuffer, ms, projMat, partialTicks, resetFog);
PoseStack poseStack = new PoseStack();
poseStack.mulPose(frustumMatrix);
SkyblockSkyRenderer.renderStars(starBuffer, poseStack, projectionMatrix, partialTick, skyFogSetup);
}
}

@SuppressWarnings("mapping") // applyModelViewMatrix is unobfuscated - not mapped on Fabric, mapped on Forge
@Inject(
method = "renderLevel",
at = @At(
shift = At.Shift.AFTER,
value = "INVOKE",
target = "Lcom/mojang/blaze3d/systems/RenderSystem;applyModelViewMatrix()V",
ordinal = 0 // after debugRenderer, before a long sequence of endBatch calls
)
method = "renderLevel",
at = @At(
shift = At.Shift.AFTER,
value = "INVOKE",
target = "Lcom/mojang/blaze3d/systems/RenderSystem;applyModelViewMatrix()V",
ordinal = 0 // after debugRenderer, before a long sequence of endBatch calls
)
)
private void renderOverlays(PoseStack ps, float partialTicks, long unknown, boolean drawBlockOutline,
Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projMat, CallbackInfo ci) {
private void renderOverlays(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera,
GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f frustumMatrix, Matrix4f projectionMatrix, CallbackInfo ci) {
// Called from our own mixin instead of e.g. Forge's render world last event,
// because that event is too late for Fabulous mode
WorldOverlays.renderWorldLast(camera, partialTicks, ps, renderBuffers, level);
PoseStack poseStack = new PoseStack();
WorldOverlays.renderWorldLast(camera, deltaTracker.getGameTimeDeltaPartialTick(false), poseStack, renderBuffers, level);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.client.renderer.blockentity.SkullBlockRenderer;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.component.ResolvableProfile;
import net.minecraft.world.level.block.SkullBlock;

import org.spongepowered.asm.mixin.Final;
Expand All @@ -40,20 +41,20 @@ public abstract class SkullBlockRendererMixin {
private static Map<SkullBlock.Type, ResourceLocation> SKIN_BY_TYPE;

@Inject(
method = "createSkullRenderers",
at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableMap$Builder;build()Lcom/google/common/collect/ImmutableMap;", remap = false),
locals = LocalCapture.CAPTURE_FAILSOFT
method = "createSkullRenderers",
at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableMap$Builder;build()Lcom/google/common/collect/ImmutableMap;", remap = false),
locals = LocalCapture.CAPTURE_FAILSOFT
)
private static void registerModel(EntityModelSet entityModelSet, CallbackInfoReturnable<Map<SkullBlock.Type, SkullModelBase>> cir,
ImmutableMap.Builder<SkullBlock.Type, SkullModelBase> builder) {
ImmutableMap.Builder<SkullBlock.Type, SkullModelBase> builder) {
builder.put(GaiaHeadBlock.GAIA_TYPE, new GaiaHeadModel());

// placeholder to avoid crash
SKIN_BY_TYPE.put(GaiaHeadBlock.GAIA_TYPE, DefaultPlayerSkin.getDefaultTexture());
}

@Inject(at = @At("HEAD"), method = "getRenderType", cancellable = true)
private static void hookGetRenderType(SkullBlock.Type type, GameProfile gameProfile, CallbackInfoReturnable<RenderType> cir) {
private static void hookGetRenderType(SkullBlock.Type type, ResolvableProfile profile, CallbackInfoReturnable<RenderType> cir) {
if (type == GaiaHeadBlock.GAIA_TYPE) {
GaiaHeadBlockEntityRenderer.hookGetRenderType(cir);
}
Expand Down

0 comments on commit 7dbed7b

Please sign in to comment.