Skip to content

Commit

Permalink
Merge branch 'FabricMC:1.20.1' into 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Phoupraw authored Oct 20, 2023
2 parents fd64636 + 16a9bc7 commit 369c140
Show file tree
Hide file tree
Showing 84 changed files with 1,356 additions and 420 deletions.
4 changes: 4 additions & 0 deletions deprecated/fabric-rendering-data-attachment-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
archivesBaseName = "fabric-rendering-data-attachment-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, ['fabric-block-view-api-v2'])
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,21 @@
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.rendering.data.attachment.client;
package net.fabricmc.fabric.mixin.rendering.data.client;

import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import org.spongepowered.asm.mixin.Mixin;

import net.minecraft.client.render.chunk.ChunkRendererRegion;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldView;

import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView;
import net.fabricmc.fabric.impl.rendering.data.attachment.RenderDataObjectConsumer;

/**
* Since {@link RenderAttachedBlockView} is only automatically implemented on {@link WorldView} instances and
* {@link ChunkRendererRegion} does not implement {@link WorldView}, this mixin manually implements
* {@link RenderAttachedBlockView} on {@link ChunkRendererRegion}. The BlockView API v2 implementation ensures
* that all default method implementations of {@link RenderAttachedBlockView} work here automatically.
*/
@Mixin(ChunkRendererRegion.class)
public abstract class ChunkRendererRegionMixin implements RenderAttachedBlockView, RenderDataObjectConsumer {
private Long2ObjectOpenHashMap<Object> fabric_renderDataObjects;

@Override
public Object getBlockEntityRenderAttachment(BlockPos pos) {
return fabric_renderDataObjects == null ? null : fabric_renderDataObjects.get(pos.asLong());
}

// Called in MixinChunkRendererRegionBuilder
@Override
public void fabric_acceptRenderDataObjects(Long2ObjectOpenHashMap<Object> renderDataObjects) {
this.fabric_renderDataObjects = renderDataObjects;
}
public abstract class ChunkRendererRegionMixin implements RenderAttachedBlockView {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"required": true,
"package": "net.fabricmc.fabric.mixin.rendering.data.client",
"compatibilityLevel": "JAVA_17",
"client": [
"ChunkRendererRegionMixin"
],
"injectors": {
"defaultRequire": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.api.rendering.data.v1;

import org.jetbrains.annotations.Nullable;

import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.WorldView;

import net.fabricmc.fabric.api.blockview.v2.FabricBlockView;

/**
* This interface is guaranteed to be implemented on all {@link WorldView} instances.
* It is likely to be implemented on any given {@link BlockRenderView} instance, but
* this is not guaranteed.
*
* @deprecated Use {@link FabricBlockView} instead.
*/
@Deprecated
public interface RenderAttachedBlockView extends BlockRenderView {
/**
* This method will call {@link FabricBlockView#getBlockEntityRenderData(BlockPos)} by default.
*
* @deprecated Use {@link FabricBlockView#getBlockEntityRenderData(BlockPos)} instead.
*/
@Deprecated
@Nullable
default Object getBlockEntityRenderAttachment(BlockPos pos) {
return getBlockEntityRenderData(pos);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.api.rendering.data.v1;

import org.jetbrains.annotations.Nullable;

import net.minecraft.block.entity.BlockEntity;

import net.fabricmc.fabric.api.blockview.v2.RenderDataBlockEntity;

/**
* This interface is guaranteed to be implemented on all {@link BlockEntity} instances.
*
* @deprecated Use {@link RenderDataBlockEntity} instead.
*/
@Deprecated
@FunctionalInterface
public interface RenderAttachmentBlockEntity {
/**
* This method will be automatically called if {@link RenderDataBlockEntity#getRenderData()} is not overridden.
*
* @deprecated Use {@link RenderDataBlockEntity#getRenderData()} instead.
*/
@Deprecated
@Nullable
Object getRenderAttachmentData();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.rendering.data;

import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;

import net.minecraft.block.entity.BlockEntity;

import net.fabricmc.fabric.api.blockview.v2.RenderDataBlockEntity;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;

@Mixin(BlockEntity.class)
public class BlockEntityMixin implements RenderAttachmentBlockEntity, RenderDataBlockEntity {
@Override
@Nullable
public Object getRenderAttachmentData() {
return null;
}

/**
* Instead of returning null by default in v2, proxy to v1 method instead.
*/
@Override
@Nullable
public Object getRenderData() {
return getRenderAttachmentData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.rendering.data.attachment;
package net.fabricmc.fabric.mixin.rendering.data;

import org.spongepowered.asm.mixin.Mixin;

import net.minecraft.world.BlockRenderView;
import net.minecraft.world.WorldView;

import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView;

/** Make {@link BlockRenderView} implement {@link RenderAttachedBlockView}. */
@Mixin(WorldView.class)
public interface WorldViewMixin extends RenderAttachedBlockView { }
public interface WorldViewMixin extends RenderAttachedBlockView {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": true,
"package": "net.fabricmc.fabric.mixin.rendering.data.attachment",
"compatibilityLevel": "JAVA_16",
"package": "net.fabricmc.fabric.mixin.rendering.data",
"compatibilityLevel": "JAVA_17",
"mixins": [
"BlockEntityMixin",
"WorldViewMixin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"depends": {
"fabricloader": ">=0.4.0",
"fabric-api-base": "*"
"fabric-block-view-api-v2": "*"
},
"description": "Thread-safe hooks for block entity data use during terrain rendering.",
"mixins": [
Expand All @@ -28,7 +28,6 @@
}
],
"custom": {
"fabric-api:module-lifecycle": "stable"
},
"accessWidener": "fabric-rendering-data-attachment-v1.accesswidener"
"fabric-api:module-lifecycle": "deprecated"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import net.fabricmc.fabric.impl.biome.modification.BiomeModificationImpl;

/**
* <b>Experimental feature</b>, may be removed or changed without further notice.
* Provides methods for modifying biomes. To create an instance, call
* {@link BiomeModifications#create(Identifier)}.
*
* @see BiomeModifications
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@

/**
* Allows {@link Biome} properties to be modified.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public interface BiomeModificationContext {
/**
Expand All @@ -66,8 +64,8 @@ public interface BiomeModificationContext {

interface WeatherContext {
/**
* @see Biome#getPrecipitation()
* @see Biome.Builder#precipitation(Biome.Precipitation)
* @see Biome#hasPrecipitation()
* @see Biome.Builder#precipitation(boolean)
*/
void setPrecipitation(boolean hasPrecipitation);

Expand All @@ -83,7 +81,7 @@ interface WeatherContext {
void setTemperatureModifier(Biome.TemperatureModifier temperatureModifier);

/**
* @see Biome#getDownfall()
* @see Biome.Weather#downfall()
* @see Biome.Builder#downfall(float)
*/
void setDownfall(float downfall);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
/**
* Provides an API to modify Biomes after they have been loaded and before they are used in the World.
*
* <p>Any modifications made to biomes will not be available for use in server.properties (as of 1.16.1),
* or the demo level.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
* <p>Any modifications made to biomes will not be available for use in the demo level.
*/
public final class BiomeModifications {
private BiomeModifications() {
Expand Down Expand Up @@ -87,7 +84,7 @@ public static void addSpawn(Predicate<BiomeSelectionContext> biomeSelector,
}

/**
* Create a new biome modification which will be applied whenever biomes are loaded from data packs.
* Creates a new biome modification which will be applied whenever biomes are loaded from data packs.
*
* @param id An identifier for the new set of biome modifications that is returned. Is used for
* guaranteeing consistent ordering between the biome modifications added by different mods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

/**
* Provides several convenient biome selectors that can be used with {@link BiomeModifications}.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public final class BiomeSelectors {
private BiomeSelectors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* <li>Replacements (removal + add) in biomes</li>
* <li>Generic post-processing of biomes</li>
* </ol>
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public enum ModificationPhase {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

/**
* API that exposes the internals of Minecraft's nether biome code.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public final class NetherBiomes {
private NetherBiomes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
/**
* API that exposes some internals of the minecraft default biome source for The End.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
* Because of the volatility of world generation in Minecraft 1.16, this API is marked experimental
* since it is likely to change in future Minecraft versions.
*/
public final class TheEndBiomes {
private TheEndBiomes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package net.fabricmc.fabric.mixin.biome;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Supplier;

Expand All @@ -33,11 +31,10 @@
public class BiomeSourceMixin {
@Redirect(method = "getBiomes", at = @At(value = "INVOKE", target = "Ljava/util/function/Supplier;get()Ljava/lang/Object;"))
private Object getBiomes(Supplier<Set<RegistryEntry<Biome>>> instance) {
var biomes = new HashSet<>(instance.get());
fabric_modifyBiomeSet(biomes);
return Collections.unmodifiableSet(biomes);
return fabric_modifyBiomeSet(instance.get());
}

protected void fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
protected Set<RegistryEntry<Biome>> fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
return biomes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package net.fabricmc.fabric.mixin.biome;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.function.Supplier;

Expand Down Expand Up @@ -108,14 +110,18 @@ private void getWeightedEndBiome(int biomeX, int biomeY, int biomeZ, MultiNoiseU
}

@Override
protected void fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
protected Set<RegistryEntry<Biome>> fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
if (!hasCheckedForModifiedSet) {
hasCheckedForModifiedSet = true;
biomeSetModified = !overrides.get().customBiomes.isEmpty();
}

if (biomeSetModified) {
biomes.addAll(overrides.get().customBiomes);
var modifiedBiomes = new LinkedHashSet<>(biomes);
modifiedBiomes.addAll(overrides.get().customBiomes);
return Collections.unmodifiableSet(modifiedBiomes);
}

return biomes;
}
}
2 changes: 1 addition & 1 deletion fabric-biome-api-v1/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
],
"accessWidener" : "fabric-biome-api-v1.accesswidener",
"custom": {
"fabric-api:module-lifecycle": "experimental"
"fabric-api:module-lifecycle": "stable"
}
}
Loading

0 comments on commit 369c140

Please sign in to comment.