update to 24w33a

This commit is contained in:
gnembon committed 2024-08-18 19:10:40 +02:00
1 parent 9940feb7d3
commit d11586fdaf
58 files changed
+379 -875

No files matched your search

@@ -23,7 +23,7 @@ public class BiomeInfo
{
public static final Map<String, BiFunction<ServerLevel, Biome, Value>> biomeFeatures = new HashMap<>()
{{
put("tags", (w, b) -> ListValue.wrap(w.registryAccess().registryOrThrow(Registries.BIOME).getTags().filter(p -> p.getSecond().stream().anyMatch(h -> h.value() == b)).map(p -> p.getFirst().location()).map(ValueConversions::of)));
put("tags", (w, b) -> ListValue.wrap(w.registryAccess().registryOrThrow(Registries.BIOME).getTags().filter(p -> p.stream().anyMatch(h -> h.value() == b)).map(ValueConversions::of)));
put("temperature", (w, b) -> NumericValue.of(b.getBaseTemperature()));
put("fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFogColor()));
put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFoliageColorOverride().orElse(4764952))); // client Biome.getDefaultFoliageColor
@@ -31,7 +31,7 @@ public class BiomeInfo
put("water_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterColor()));
put("water_fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterFogColor()));
put("humidity", (w, b) -> NumericValue.of(Vanilla.Biome_getClimateSettings(b).downfall()));
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0)).name().toLowerCase(Locale.ROOT)));
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0), w.getSeaLevel()).name().toLowerCase(Locale.ROOT)));
put("features", (w, b) -> {
Registry<ConfiguredFeature<?, ?>> registry = w.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
return ListValue.wrap(
@@ -304,8 +304,7 @@ public class FeatureGenerator
return spawnCustomStructure(
new JigsawStructure(new Structure.StructureSettings(
l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
new JigsawStructure(new Structure.StructureSettings(l.registryAccess().lookup(Registries.BIOME).orElseThrow().getOrThrow(BiomeTags.HAS_BASTION_REMNANT),
Map.of(),
GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE
@@ -334,7 +333,7 @@ public class FeatureGenerator
return spawnCustomStructure(
new JigsawStructure(new Structure.StructureSettings(
l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
l.registryAccess().lookup(Registries.BIOME).orElseThrow().getOrThrow(BiomeTags.HAS_BASTION_REMNANT),
Map.of(),
GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE
@@ -363,7 +362,7 @@ public class FeatureGenerator
return spawnCustomStructure(
new JigsawStructure(new Structure.StructureSettings(
l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
l.registryAccess().lookup(Registries.BIOME).orElseThrow().getOrThrow(BiomeTags.HAS_BASTION_REMNANT),
Map.of(),
GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE
@@ -392,7 +391,7 @@ public class FeatureGenerator
return spawnCustomStructure(
new JigsawStructure(new Structure.StructureSettings(
l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
l.registryAccess().lookup(Registries.BIOME).orElseThrow().getOrThrow(BiomeTags.HAS_BASTION_REMNANT),
Map.of(),
GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE
@@ -2,7 +2,6 @@ package carpet.script.utils;
import carpet.script.CarpetScriptServer;
import carpet.script.external.Carpet;
import carpet.script.external.VanillaClient;
import carpet.script.utils.shapes.ShapeDirection;
import com.mojang.blaze3d.systems.RenderSystem;
@@ -12,7 +11,6 @@ import com.mojang.blaze3d.vertex.ByteBufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat.Mode;
import com.mojang.math.Axis;
@@ -26,34 +24,27 @@ import java.util.function.BiFunction;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.model.ShulkerModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.resources.model.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.Mth;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.ShulkerBoxBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.joml.Matrix4f;
@@ -160,7 +151,6 @@ public class ShapesRenderer
Matrix4fStack matrixStack = RenderSystem.getModelViewStack();
matrixStack.pushMatrix();
matrixStack.mul(matrices.last().pose());
RenderSystem.applyModelViewMatrix();
// lines
RenderSystem.lineWidth(0.5F);
@@ -180,7 +170,6 @@ public class ShapesRenderer
});
RenderSystem.lineWidth(1.0F);
matrixStack.popMatrix();
RenderSystem.applyModelViewMatrix();
}
if (!labels.isEmpty())
@@ -439,15 +428,8 @@ public class ShapesRenderer
}
}
}
if (BlockEntity instanceof ShulkerBoxBlockEntity sbBlockEntity)
if (BlockEntity != null)
{
sbrender(sbBlockEntity, partialTick,
matrices, immediate, light, OverlayTexture.NO_OVERLAY);
}
else
{
if (BlockEntity != null)
{
BlockEntityRenderer<BlockEntity> blockEntityRenderer = client.getBlockEntityRenderDispatcher().getRenderer(BlockEntity);
if (blockEntityRenderer != null)
{
@@ -455,7 +437,6 @@ public class ShapesRenderer
matrices, immediate, light, OverlayTexture.NO_OVERLAY);
}
}
}
}
else
@@ -480,44 +461,6 @@ public class ShapesRenderer
{
return true;
}
// copy and modifiy a bit from net.minecraft.client.renderer.blockentity.ShulkerBoxRenderer.render
public void sbrender(ShulkerBoxBlockEntity shulkerBoxBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j)
{
Direction direction = Direction.UP;
if (shulkerBoxBlockEntity.hasLevel())
{
BlockState blockState = shulkerBoxBlockEntity.getBlockState();
if (blockState.getBlock() instanceof ShulkerBoxBlock)
{
direction = blockState.getValue(ShulkerBoxBlock.FACING);
}
}
DyeColor dyeColor = shulkerBoxBlockEntity.getColor();
Material material;
if (dyeColor == null)
{
material = Sheets.DEFAULT_SHULKER_TEXTURE_LOCATION;
}
else
{
material = Sheets.SHULKER_TEXTURE_LOCATION.get(dyeColor.getId());
}
poseStack.pushPose();
poseStack.translate(0.5, 0.5, 0.5);
poseStack.scale(0.9995F, 0.9995F, 0.9995F);
poseStack.mulPose(direction.getRotation());
poseStack.scale(1.0F, -1.0F, -1.0F);
poseStack.translate(0.0, -1.0, 0.0);
ShulkerModel<?> model = VanillaClient.ShulkerBoxRenderer_model(client.getBlockEntityRenderDispatcher().getRenderer(shulkerBoxBlockEntity));
ModelPart modelPart = model.getLid();
modelPart.setPos(0.0F, 24.0F - shulkerBoxBlockEntity.getProgress(f) * 0.5F * 16.0F, 0.0F);
modelPart.yRot = 270.0F * shulkerBoxBlockEntity.getProgress(f) * (float) (Math.PI / 180.0);
VertexConsumer vertexConsumer = material.buffer(multiBufferSource, RenderType::entityCutoutNoCull);
model.renderToBuffer(poseStack, vertexConsumer, i, j, 0xffffffff);
poseStack.popPose();
}
}
@@ -165,7 +165,7 @@ public class SystemInfo
put("world_gamerules", c -> {
Map<Value, Value> rules = new HashMap<>();
GameRules gameRules = c.level().getGameRules();
GameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor()
gameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor()
{
@Override
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type)