Port to 1.18-pre2 without worldgen

This commit is contained in:
modmuss50 2021-11-16 22:38:31 +00:00
parent f5c3b85773
commit 4a2e81550f
38 changed files with 132 additions and 158 deletions

View file

@ -145,10 +145,10 @@ public class RenderUtil {
float l = (endColor >> 8 & 0xFF) / 255.0F; float l = (endColor >> 8 & 0xFF) / 255.0F;
float m = (endColor & 0xFF) / 255.0F; float m = (endColor & 0xFF) / 255.0F;
bufferBuilder.vertex(matrices.peek().getModel(), right, top, zLevel).color(g, h, i, f).next(); bufferBuilder.vertex(matrices.peek().getPositionMatrix(), right, top, zLevel).color(g, h, i, f).next();
bufferBuilder.vertex(matrices.peek().getModel(), left, top, zLevel).color(g, h, i, f).next(); bufferBuilder.vertex(matrices.peek().getPositionMatrix(), left, top, zLevel).color(g, h, i, f).next();
bufferBuilder.vertex(matrices.peek().getModel(), left, bottom, zLevel).color(k, l, m, j).next(); bufferBuilder.vertex(matrices.peek().getPositionMatrix(), left, bottom, zLevel).color(k, l, m, j).next();
bufferBuilder.vertex(matrices.peek().getModel(), right, bottom, zLevel).color(k, l, m, j).next(); bufferBuilder.vertex(matrices.peek().getPositionMatrix(), right, bottom, zLevel).color(k, l, m, j).next();
tessellator.draw(); tessellator.draw();
RenderSystem.disableBlend(); RenderSystem.disableBlend();

View file

@ -50,7 +50,7 @@ public abstract class BaseBlockEntityProvider extends Block implements BlockEnti
return Optional.empty(); return Optional.empty();
} }
ItemStack newStack = stack.copy(); ItemStack newStack = stack.copy();
NbtCompound blockEntityData = blockEntity.writeNbt(new NbtCompound()); NbtCompound blockEntityData = blockEntity.createNbt();
stripLocationData(blockEntityData); stripLocationData(blockEntityData);
if (!newStack.hasNbt()) { if (!newStack.hasNbt()) {
newStack.setNbt(new NbtCompound()); newStack.setNbt(new NbtCompound());

View file

@ -126,12 +126,13 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
@Nullable @Nullable
@Override @Override
public BlockEntityUpdateS2CPacket toUpdatePacket() { public BlockEntityUpdateS2CPacket toUpdatePacket() {
return new BlockEntityUpdateS2CPacket(getPos(), 0, toInitialChunkDataNbt()); return BlockEntityUpdateS2CPacket.create(this);
} }
@Override @Override
public NbtCompound toInitialChunkDataNbt() { public NbtCompound toInitialChunkDataNbt() {
NbtCompound compound = super.writeNbt(new NbtCompound()); NbtCompound compound = new NbtCompound();
super.writeNbt(compound);
writeNbt(compound); writeNbt(compound);
return compound; return compound;
} }
@ -257,7 +258,7 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tagCompound) { public void writeNbt(NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
if (getOptionalInventory().isPresent()) { if (getOptionalInventory().isPresent()) {
getOptionalInventory().get().write(tagCompound); getOptionalInventory().get().write(tagCompound);
@ -273,7 +274,6 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
} }
upgradeInventory.write(tagCompound, "Upgrades"); upgradeInventory.write(tagCompound, "Upgrades");
tagCompound.put("redstoneConfig", redstoneConfiguration.write()); tagCompound.put("redstoneConfig", redstoneConfiguration.write());
return tagCompound;
} }
private boolean isItemValidForSlot(int index, ItemStack stack) { private boolean isItemValidForSlot(int index, ItemStack stack) {

View file

@ -125,7 +125,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound data) { public void writeNbt(NbtCompound data) {
super.writeNbt(data); super.writeNbt(data);
if (isMultiblockSaveDelegate() && isConnected()) { if (isMultiblockSaveDelegate() && isConnected()) {
@ -133,7 +133,6 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
this.controller.write(multiblockData); this.controller.write(multiblockData);
data.put("multiblockData", multiblockData); data.put("multiblockData", multiblockData);
} }
return data;
} }
@Override @Override
@ -175,7 +174,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
public BlockEntityUpdateS2CPacket toUpdatePacket() { public BlockEntityUpdateS2CPacket toUpdatePacket() {
NbtCompound packetData = new NbtCompound(); NbtCompound packetData = new NbtCompound();
encodeDescriptionPacket(packetData); encodeDescriptionPacket(packetData);
return new BlockEntityUpdateS2CPacket(getPos(), 0, packetData); return BlockEntityUpdateS2CPacket.create(this);
} }
// /// Things to override in most implementations (IMultiblockPart) // /// Things to override in most implementations (IMultiblockPart)

View file

@ -556,7 +556,7 @@ public abstract class MultiblockControllerBase {
// Ensure that we save our data, even if the our save // Ensure that we save our data, even if the our save
// delegate is in has no TEs. // delegate is in has no TEs.
WorldChunk chunkToSave = this.worldObj.getChunk(x, z); WorldChunk chunkToSave = this.worldObj.getChunk(x, z);
chunkToSave.markDirty(); chunkToSave.needsSaving();
} }
} }
} }

View file

@ -39,7 +39,7 @@ import java.util.List;
public class ClientBoundPackets { public class ClientBoundPackets {
public static IdentifiedPacket createCustomDescriptionPacket(BlockEntity blockEntity) { public static IdentifiedPacket createCustomDescriptionPacket(BlockEntity blockEntity) {
return createCustomDescriptionPacket(blockEntity.getPos(), blockEntity.writeNbt(new NbtCompound())); return createCustomDescriptionPacket(blockEntity.getPos(), blockEntity.createNbt());
} }
public static IdentifiedPacket createCustomDescriptionPacket(BlockPos blockPos, NbtCompound nbt) { public static IdentifiedPacket createCustomDescriptionPacket(BlockPos blockPos, NbtCompound nbt) {

View file

@ -352,12 +352,11 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tag) { public void writeNbt(NbtCompound tag) {
super.writeNbt(tag); super.writeNbt(tag);
NbtCompound data = new NbtCompound(); NbtCompound data = new NbtCompound();
data.putLong("energy", getStored()); data.putLong("energy", getStored());
tag.put("PowerAcceptor", data); tag.put("PowerAcceptor", data);
return tag;
} }
@Override @Override

View file

@ -79,8 +79,8 @@ allprojects {
apply plugin: "fabric-loom" apply plugin: "fabric-loom"
apply plugin: "maven-publish" apply plugin: "maven-publish"
sourceCompatibility = JavaVersion.VERSION_16 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_16 targetCompatibility = JavaVersion.VERSION_17
// Shared deps between TR and RC // Shared deps between TR and RC
dependencies { dependencies {
@ -91,7 +91,9 @@ allprojects {
//Fabric api //Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fapi_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fapi_version}"
include(modApi("teamreborn:energy:${project.energy_version}")) include(modApi("teamreborn:energy:${project.energy_version}")) {
transitive = false
}
} }
processResources { processResources {
@ -104,7 +106,7 @@ allprojects {
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8" it.options.encoding = "UTF-8"
it.options.release = 16 it.options.release = 17
} }
java { java {
@ -149,7 +151,7 @@ dependencies {
api project(path: ":RebornCore", configuration: "namedElements") api project(path: ":RebornCore", configuration: "namedElements")
include project(":RebornCore") include project(":RebornCore")
optionalDependency "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" disabledOptionalDependency "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}"
disabledOptionalDependency "com.github.emilyploszaj:trinkets:${project.trinkets_version}" disabledOptionalDependency "com.github.emilyploszaj:trinkets:${project.trinkets_version}"
disabledOptionalDependency "com.github.dexman545:autoswitch-api:${project.autoswitch_version}" disabledOptionalDependency "com.github.dexman545:autoswitch-api:${project.autoswitch_version}"
disabledOptionalDependency "net.oskarstrom:DashLoader:${project.dashloader_version}" disabledOptionalDependency "net.oskarstrom:DashLoader:${project.dashloader_version}"

View file

@ -6,10 +6,10 @@ org.gradle.jvmargs=-Xmx2G
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=1.17.1 minecraft_version=1.18-pre2
yarn_version=1.17.1+build.63:v2 yarn_version=1.18-pre2+build.1:v2
loader_version=0.12.5 loader_version=0.12.5
fapi_version=0.42.1+1.17 fapi_version=0.42.4+1.18
# Dependencies # Dependencies
energy_version=2.0.0-beta1 energy_version=2.0.0-beta1

View file

@ -32,7 +32,7 @@ import techreborn.test.TRGameTest
import techreborn.test.TRTestContext import techreborn.test.TRTestContext
class GrinderTest extends TRGameTest { class GrinderTest extends TRGameTest {
@GameTest(structureName = EMPTY_STRUCTURE, tickLimit = 150) @GameTest(structureName = "fabric-gametest-api-v1:empty", tickLimit = 150)
def testGrind2OCs(TRTestContext context) { def testGrind2OCs(TRTestContext context) {
/** /**
* Test that grinder with 2 overclocker upgrades grinds coal into coal dust in 116 ticks * Test that grinder with 2 overclocker upgrades grinds coal into coal dust in 116 ticks

View file

@ -85,7 +85,7 @@ public class TechReborn implements ModInitializer {
RecipeCrafter.soundHanlder = new ModSounds.SoundHandler(); RecipeCrafter.soundHanlder = new ModSounds.SoundHandler();
} }
ModLoot.init(); ModLoot.init();
WorldGenerator.initWorldGen(); // WorldGenerator.initWorldGen();
FluidGeneratorRecipes.init(); FluidGeneratorRecipes.init();
//Force loads the block entities at the right time //Force loads the block entities at the right time
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored

View file

@ -199,14 +199,14 @@ public class CableBlockEntity extends BlockEntity
// BlockEntity // BlockEntity
@Override @Override
public NbtCompound toInitialChunkDataNbt() { public NbtCompound toInitialChunkDataNbt() {
return writeNbt(new NbtCompound()); return createNbt();
} }
@Override @Override
public BlockEntityUpdateS2CPacket toUpdatePacket() { public BlockEntityUpdateS2CPacket toUpdatePacket() {
NbtCompound nbtTag = new NbtCompound(); NbtCompound nbtTag = new NbtCompound();
writeNbt(nbtTag); writeNbt(nbtTag);
return new BlockEntityUpdateS2CPacket(getPos(), 1, nbtTag); return BlockEntityUpdateS2CPacket.create(this);
} }
@Override @Override
@ -223,13 +223,12 @@ public class CableBlockEntity extends BlockEntity
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound compound) { public void writeNbt(NbtCompound compound) {
super.writeNbt(compound); super.writeNbt(compound);
compound.putLong("energy", energyContainer.amount); compound.putLong("energy", energyContainer.amount);
if (cover != null) { if (cover != null) {
compound.put("cover", NbtHelper.fromBlockState(cover)); compound.put("cover", NbtHelper.fromBlockState(cover));
} }
return compound;
} }
public void neighborUpdate() { public void neighborUpdate() {

View file

@ -75,7 +75,7 @@ class CableTickManager {
// Make sure we only gather and tick each cable once per tick. // Make sure we only gather and tick each cable once per tick.
if (current.lastTick == tickCounter) return false; if (current.lastTick == tickCounter) return false;
// Make sure we ignore cables in non-ticking chunks. // Make sure we ignore cables in non-ticking chunks.
if (!(current.getWorld() instanceof ServerWorld sw) || !sw.method_37117(current.getPos())) return false; if (!(current.getWorld() instanceof ServerWorld sw) || !sw.isChunkLoaded(current.getPos())) return false;
return true; return true;
} }

View file

@ -173,10 +173,9 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tagCompound) { public void writeNbt(NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound;
} }
@Override @Override

View file

@ -159,11 +159,10 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tag) { public void writeNbt(NbtCompound tag) {
super.writeNbt(tag); super.writeNbt(tag);
tag.putInt("BurnTime", burnTime); tag.putInt("BurnTime", burnTime);
tag.putInt("TotalBurnTime", totalBurnTime); tag.putInt("TotalBurnTime", totalBurnTime);
return tag;
} }
// MachineBaseBlockEntity // MachineBaseBlockEntity

View file

@ -141,12 +141,11 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound compoundTag) { public void writeNbt(NbtCompound compoundTag) {
super.writeNbt(compoundTag); super.writeNbt(compoundTag);
compoundTag.putInt("BurnTime", burnTime); compoundTag.putInt("BurnTime", burnTime);
compoundTag.putInt("TotalBurnTime", totalBurnTime); compoundTag.putInt("TotalBurnTime", totalBurnTime);
compoundTag.putInt("Progress", progress); compoundTag.putInt("Progress", progress);
return compoundTag;
} }
@Override @Override

View file

@ -149,10 +149,9 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound compoundTag) { public void writeNbt(NbtCompound compoundTag) {
super.writeNbt(compoundTag); super.writeNbt(compoundTag);
compoundTag.putFloat("Experience", experience); compoundTag.putFloat("Experience", experience);
return compoundTag;
} }
// IContainerProvider // IContainerProvider

View file

@ -68,12 +68,11 @@ public class AlarmBlockEntity extends BlockEntity
// BlockEntity // BlockEntity
@Override @Override
public NbtCompound writeNbt(NbtCompound compound) { public void writeNbt(NbtCompound compound) {
if (compound == null) { if (compound == null) {
compound = new NbtCompound(); compound = new NbtCompound();
} }
compound.putInt("selectedSound", this.selectedSound); compound.putInt("selectedSound", this.selectedSound);
return super.writeNbt(compound);
} }
@Override @Override

View file

@ -107,10 +107,9 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
} }
@Override @Override
public NbtCompound writeNbt(final NbtCompound tagCompound) { public void writeNbt(final NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound;
} }
private static IInventoryAccess<FluidReplicatorBlockEntity> getInventoryAccess() { private static IInventoryAccess<FluidReplicatorBlockEntity> getInventoryAccess() {

View file

@ -371,14 +371,13 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
} }
@Override @Override
public NbtCompound writeNbt(final NbtCompound tagCompound) { public void writeNbt(final NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tagCompound.putInt("craftingTickTime", this.craftingTickTime); tagCompound.putInt("craftingTickTime", this.craftingTickTime);
tagCompound.putInt("neededPower", this.neededPower); tagCompound.putInt("neededPower", this.neededPower);
tagCompound.putBoolean("hasStartedCrafting", this.hasStartedCrafting); tagCompound.putBoolean("hasStartedCrafting", this.hasStartedCrafting);
tagCompound.putBoolean("hasActiveRecipe", this.currentRecipe != null); tagCompound.putBoolean("hasActiveRecipe", this.currentRecipe != null);
tagCompound.putInt("size", size); tagCompound.putInt("size", size);
return tagCompound;
} }
//MachineBaseBlockEntity //MachineBaseBlockEntity

View file

@ -101,10 +101,9 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
} }
@Override @Override
public NbtCompound writeNbt(final NbtCompound tagCompound) { public void writeNbt(final NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound;
} }
// TileMachineBase // TileMachineBase

View file

@ -102,10 +102,9 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
} }
@Override @Override
public NbtCompound writeNbt(final NbtCompound tagCompound) { public void writeNbt(final NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound;
} }
// TileMachineBase // TileMachineBase

View file

@ -407,9 +407,8 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tag) { public void writeNbt(NbtCompound tag) {
tag.putBoolean("locked", locked); tag.putBoolean("locked", locked);
return super.writeNbt(tag);
} }
@Override @Override

View file

@ -141,11 +141,10 @@ public class PlayerDetectorBlockEntity extends PowerAcceptorBlockEntity implemen
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tag) { public void writeNbt(NbtCompound tag) {
super.writeNbt(tag); super.writeNbt(tag);
tag.putString("ownerID", ownerUdid); tag.putString("ownerID", ownerUdid);
tag.putInt("radius", radius); tag.putInt("radius", radius);
return tag;
} }
// MachineBaseBlockEntity // MachineBaseBlockEntity

View file

@ -148,10 +148,8 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tagCompound) { public void writeNbt(NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
return tagCompound;
} }
@Override @Override

View file

@ -354,12 +354,11 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
} }
@Override @Override
public NbtCompound writeNbt(final NbtCompound tagCompound) { public void writeNbt(final NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tagCompound.putBoolean("isRunning", this.isRunning); tagCompound.putBoolean("isRunning", this.isRunning);
tagCompound.putInt("tickTime", this.tickTime); tagCompound.putInt("tickTime", this.tickTime);
tagCompound.putBoolean("locked", locked); tagCompound.putBoolean("locked", locked);
return tagCompound;
} }
@Override @Override

View file

@ -123,14 +123,13 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tagCompound) { public void writeNbt(NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tagCompound.putInt("radius", radius); tagCompound.putInt("radius", radius);
if (ownerUdid != null && !ownerUdid.isEmpty()){ if (ownerUdid != null && !ownerUdid.isEmpty()){
tagCompound.putString("ownerUdid", ownerUdid); tagCompound.putString("ownerUdid", ownerUdid);
} }
inventory.write(tagCompound); inventory.write(tagCompound);
return tagCompound;
} }
@Override @Override

View file

@ -141,10 +141,9 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tagCompound) { public void writeNbt(NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tagCompound.putInt("output", OUTPUT); tagCompound.putInt("output", OUTPUT);
return tagCompound;
} }
@Override @Override

View file

@ -129,13 +129,12 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound nbttagcompound) { public void writeNbt(NbtCompound nbttagcompound) {
super.writeNbt(nbttagcompound); super.writeNbt(nbttagcompound);
if (ownerUdid == null || StringUtils.isEmpty(ownerUdid)) { if (ownerUdid == null || StringUtils.isEmpty(ownerUdid)) {
return nbttagcompound; return;
} }
nbttagcompound.putString("ownerUdid", this.ownerUdid); nbttagcompound.putString("ownerUdid", this.ownerUdid);
return nbttagcompound;
} }
@Override @Override

View file

@ -128,11 +128,10 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
} }
@Override @Override
public NbtCompound writeNbt(final NbtCompound tagCompound) { public void writeNbt(final NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tagCompound.putString("unitType", this.type.name()); tagCompound.putString("unitType", this.type.name());
tank.write(tagCompound); tank.write(tagCompound);
return tagCompound;
} }
@Override @Override

View file

@ -318,7 +318,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
} }
@Override @Override
public NbtCompound writeNbt(NbtCompound tagCompound) { public void writeNbt(NbtCompound tagCompound) {
super.writeNbt(tagCompound); super.writeNbt(tagCompound);
tagCompound.putString("unitType", this.type.name()); tagCompound.putString("unitType", this.type.name());
@ -342,7 +342,6 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
} }
inventory.write(tagCompound); inventory.write(tagCompound);
return tagCompound;
} }
@Override @Override

View file

@ -179,7 +179,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
public BlockState getStateForNeighborUpdate(BlockState ourState, Direction direction, BlockState otherState, public BlockState getStateForNeighborUpdate(BlockState ourState, Direction direction, BlockState otherState,
WorldAccess worldIn, BlockPos ourPos, BlockPos otherPos) { WorldAccess worldIn, BlockPos ourPos, BlockPos otherPos) {
if (ourState.get(WATERLOGGED)) { if (ourState.get(WATERLOGGED)) {
worldIn.getFluidTickScheduler().schedule(ourPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn)); worldIn.createAndScheduleFluidTick(ourPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
} }
return ourState; return ourState;
} }

View file

@ -89,12 +89,12 @@ public class StorageUnitRenderer implements BlockEntityRenderer<StorageUnitBaseB
// Render item count // Render item count
String count = String.valueOf(storage.storedAmount); String count = String.valueOf(storage.storedAmount);
xPosition = (float) (-textRenderer.getWidth(count) / 2); xPosition = (float) (-textRenderer.getWidth(count) / 2);
textRenderer.draw(count, xPosition, -4f + 40, 0, false, matrices.peek().getModel(), vertexConsumers, false, 0, light); textRenderer.draw(count, xPosition, -4f + 40, 0, false, matrices.peek().getPositionMatrix(), vertexConsumers, false, 0, light);
// Render name // Render name
String item = stack.getName().asTruncatedString(18); String item = stack.getName().asTruncatedString(18);
xPosition = (float) (-textRenderer.getWidth(item) / 2); xPosition = (float) (-textRenderer.getWidth(item) / 2);
textRenderer.draw(item, xPosition, -4f - 40, 0, false, matrices.peek().getModel(), vertexConsumers, false, 0, light); textRenderer.draw(item, xPosition, -4f - 40, 0, false, matrices.peek().getPositionMatrix(), vertexConsumers, false, 0, light);
matrices.pop(); matrices.pop();
} }

View file

@ -49,26 +49,27 @@ import java.util.function.Predicate;
public class DataDrivenFeature { public class DataDrivenFeature {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
private final Predicate<BiomeSelectionContext> biomeSelector; private Predicate<BiomeSelectionContext> biomeSelector;
private final ConfiguredFeature<?, ?> configuredFeature; private ConfiguredFeature<?, ?> configuredFeature;
private final GenerationStep.Feature generationStep; private GenerationStep.Feature generationStep;
private final Identifier identifier; private Identifier identifier;
public DataDrivenFeature(Identifier identifier, Predicate<BiomeSelectionContext> biomeSelector, ConfiguredFeature<?, ?> configuredFeature, GenerationStep.Feature generationStep) { // public DataDrivenFeature(Identifier identifier, Predicate<BiomeSelectionContext> biomeSelector, ConfiguredFeature<?, ?> configuredFeature, GenerationStep.Feature generationStep) {
this.identifier = identifier; // this.identifier = identifier;
this.biomeSelector = biomeSelector; // this.biomeSelector = biomeSelector;
this.configuredFeature = configuredFeature; // this.configuredFeature = configuredFeature;
this.generationStep = generationStep; // this.generationStep = generationStep;
} // }
@Deprecated @Deprecated
public DataDrivenFeature(Identifier identifier, Predicate<BiomeSelectionContext> biomeSelector, RuleTest ruleTest, BlockState blockState, int maxY, int veinSize, int veinCount) { public DataDrivenFeature(Identifier identifier, Predicate<BiomeSelectionContext> biomeSelector, RuleTest ruleTest, BlockState blockState, int maxY, int veinSize, int veinCount) {
this(identifier, biomeSelector, Feature.ORE.configure( // this(identifier, biomeSelector, Feature.ORE.configure(
new OreFeatureConfig(ruleTest, blockState, veinSize) // new OreFeatureConfig(ruleTest, blockState, veinSize)
) // ));
.uniformRange(YOffset.getBottom(), YOffset.fixed(maxY)) // TODO 1.18
.spreadHorizontally() // .uniformRange(YOffset.getBottom(), YOffset.fixed(maxY))
.repeat(veinCount), GenerationStep.Feature.UNDERGROUND_ORES); // .spreadHorizontally()
// .repeat(veinCount), GenerationStep.Feature.UNDERGROUND_ORES);
} }
public static DataDrivenFeature deserialise(Identifier identifier, JsonObject jsonObject) { public static DataDrivenFeature deserialise(Identifier identifier, JsonObject jsonObject) {
@ -97,7 +98,8 @@ public class DataDrivenFeature {
throw new JsonParseException(s); throw new JsonParseException(s);
}).getFeature(); }).getFeature();
return new DataDrivenFeature(identifier, biomeSelector, configuredFeature, generationStep); return null;
// return new DataDrivenFeature(identifier, biomeSelector, configuredFeature, generationStep);
} }
public JsonObject serialise() { public JsonObject serialise() {

View file

@ -34,19 +34,13 @@ import net.minecraft.structure.rule.RuleTest;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DataPool; import net.minecraft.util.collection.DataPool;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.ChanceDecoratorConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraft.world.gen.feature.OreConfiguredFeatures;
import net.minecraft.world.gen.feature.TreeFeatureConfig;
import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize;
import net.minecraft.world.gen.stateprovider.BlockStateProvider; import net.minecraft.world.gen.stateprovider.BlockStateProvider;
import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider;
import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider; import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider;
import net.minecraft.world.gen.trunk.StraightTrunkPlacer;
import org.apache.logging.log4j.util.TriConsumer; import org.apache.logging.log4j.util.TriConsumer;
import techreborn.blocks.misc.BlockRubberLog; import techreborn.blocks.misc.BlockRubberLog;
import techreborn.init.TRContent; import techreborn.init.TRContent;
@ -79,19 +73,21 @@ public class DefaultWorldGen {
BlockStateProvider logProvider = new WeightedBlockStateProvider(logPoolBuilder.build()); BlockStateProvider logProvider = new WeightedBlockStateProvider(logPoolBuilder.build());
TreeFeatureConfig treeFeatureConfig = new TreeFeatureConfig.Builder( // TreeFeatureConfig treeFeatureConfig = new TreeFeatureConfig.Builder(
logProvider, // logProvider,
new StraightTrunkPlacer(6, 3, 0), // new StraightTrunkPlacer(6, 3, 0),
new SimpleBlockStateProvider(TRContent.RUBBER_LEAVES.getDefaultState()), // BlockStateProvider.of(TRContent.RUBBER_LEAVES.getDefaultState()),
new SimpleBlockStateProvider(TRContent.RUBBER_SAPLING.getDefaultState()), // BlockStateProvider.of(TRContent.RUBBER_SAPLING.getDefaultState()),
new RubberTreeFeature.FoliagePlacer(ConstantIntProvider.create(2), ConstantIntProvider.create(0), 3, 3, TRContent.RUBBER_LEAVES.getDefaultState()), // new RubberTreeFeature.FoliagePlacer(ConstantIntProvider.create(2), ConstantIntProvider.create(0), 3, 3, TRContent.RUBBER_LEAVES.getDefaultState()),
new TwoLayersFeatureSize(1, 0, 1) // new TwoLayersFeatureSize(1, 0, 1)
).build(); // ).build();
return WorldGenerator.RUBBER_TREE_FEATURE.configure(treeFeatureConfig) return null; // TODO 1.18
.decorate(WorldGenerator.RUBBER_TREE_DECORATOR
.configure(new ChanceDecoratorConfig(50) // return WorldGenerator.RUBBER_TREE_FEATURE.configure(treeFeatureConfig)
)); // .decorate(WorldGenerator.RUBBER_TREE_DECORATOR
// .configure(new ChanceDecoratorConfig(50)
// ));
} }
public static List<DataDrivenFeature> getDefaultFeatures() { public static List<DataDrivenFeature> getDefaultFeatures() {
@ -99,31 +95,31 @@ public class DefaultWorldGen {
TriConsumer<Predicate<BiomeSelectionContext>, RuleTest, TRContent.Ores> addOre = (worldTargetType, ruleTest, ore) -> TriConsumer<Predicate<BiomeSelectionContext>, RuleTest, TRContent.Ores> addOre = (worldTargetType, ruleTest, ore) ->
features.add(ore.asNewOres(new Identifier("techreborn", Registry.BLOCK.getId(ore.block).getPath()), worldTargetType, ruleTest)); features.add(ore.asNewOres(new Identifier("techreborn", Registry.BLOCK.getId(ore.block).getPath()), worldTargetType, ruleTest));
addOre.accept(BiomeSelectors.foundInTheNether(), OreFeatureConfig.Rules.BASE_STONE_NETHER, TRContent.Ores.CINNABAR); addOre.accept(BiomeSelectors.foundInTheNether(), OreConfiguredFeatures.BASE_STONE_NETHER, TRContent.Ores.CINNABAR);
addOre.accept(BiomeSelectors.foundInTheNether(), OreFeatureConfig.Rules.BASE_STONE_NETHER, TRContent.Ores.PYRITE); addOre.accept(BiomeSelectors.foundInTheNether(), OreConfiguredFeatures.BASE_STONE_NETHER, TRContent.Ores.PYRITE);
addOre.accept(BiomeSelectors.foundInTheNether(), OreFeatureConfig.Rules.BASE_STONE_NETHER, TRContent.Ores.SPHALERITE); addOre.accept(BiomeSelectors.foundInTheNether(), OreConfiguredFeatures.BASE_STONE_NETHER, TRContent.Ores.SPHALERITE);
addOre.accept(BiomeSelectors.foundInTheEnd(), END_STONE, TRContent.Ores.PERIDOT); addOre.accept(BiomeSelectors.foundInTheEnd(), END_STONE, TRContent.Ores.PERIDOT);
addOre.accept(BiomeSelectors.foundInTheEnd(), END_STONE, TRContent.Ores.SHELDONITE); addOre.accept(BiomeSelectors.foundInTheEnd(), END_STONE, TRContent.Ores.SHELDONITE);
addOre.accept(BiomeSelectors.foundInTheEnd(), END_STONE, TRContent.Ores.SODALITE); addOre.accept(BiomeSelectors.foundInTheEnd(), END_STONE, TRContent.Ores.SODALITE);
addOre.accept(BiomeSelectors.foundInTheEnd(), END_STONE, TRContent.Ores.TUNGSTEN); addOre.accept(BiomeSelectors.foundInTheEnd(), END_STONE, TRContent.Ores.TUNGSTEN);
addOre.accept(BiomeSelectors.foundInOverworld(), OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, TRContent.Ores.BAUXITE); addOre.accept(BiomeSelectors.foundInOverworld(), OreConfiguredFeatures.BASE_STONE_OVERWORLD, TRContent.Ores.BAUXITE);
addOre.accept(BiomeSelectors.foundInOverworld(), OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, TRContent.Ores.GALENA); addOre.accept(BiomeSelectors.foundInOverworld(), OreConfiguredFeatures.BASE_STONE_OVERWORLD, TRContent.Ores.GALENA);
addOre.accept(BiomeSelectors.foundInOverworld(), OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, TRContent.Ores.IRIDIUM); addOre.accept(BiomeSelectors.foundInOverworld(), OreConfiguredFeatures.BASE_STONE_OVERWORLD, TRContent.Ores.IRIDIUM);
addOre.accept(BiomeSelectors.foundInOverworld(), OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, TRContent.Ores.LEAD); addOre.accept(BiomeSelectors.foundInOverworld(), OreConfiguredFeatures.BASE_STONE_OVERWORLD, TRContent.Ores.LEAD);
addOre.accept(BiomeSelectors.foundInOverworld(), OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, TRContent.Ores.RUBY); addOre.accept(BiomeSelectors.foundInOverworld(), OreConfiguredFeatures.BASE_STONE_OVERWORLD, TRContent.Ores.RUBY);
addOre.accept(BiomeSelectors.foundInOverworld(), OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, TRContent.Ores.SAPPHIRE); addOre.accept(BiomeSelectors.foundInOverworld(), OreConfiguredFeatures.BASE_STONE_OVERWORLD, TRContent.Ores.SAPPHIRE);
addOre.accept(BiomeSelectors.foundInOverworld(), OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, TRContent.Ores.SILVER); addOre.accept(BiomeSelectors.foundInOverworld(), OreConfiguredFeatures.BASE_STONE_OVERWORLD, TRContent.Ores.SILVER);
addOre.accept(BiomeSelectors.foundInOverworld(), OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, TRContent.Ores.TIN); addOre.accept(BiomeSelectors.foundInOverworld(), OreConfiguredFeatures.BASE_STONE_OVERWORLD, TRContent.Ores.TIN);
//
features.add(new DataDrivenFeature( // features.add(new DataDrivenFeature(
RubberSaplingGenerator.IDENTIFIER, // RubberSaplingGenerator.IDENTIFIER,
BiomeSelectors.categories(Biome.Category.FOREST, Biome.Category.TAIGA, Biome.Category.SWAMP), // BiomeSelectors.categories(Biome.Category.FOREST, Biome.Category.TAIGA, Biome.Category.SWAMP),
getRubberTree(), // getRubberTree(),
GenerationStep.Feature.VEGETAL_DECORATION // GenerationStep.Feature.VEGETAL_DECORATION
)); // ));
return features; return features;
} }

View file

@ -27,24 +27,21 @@ package techreborn.world;
import net.minecraft.block.sapling.SaplingGenerator; import net.minecraft.block.sapling.SaplingGenerator;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.MutableRegistry;
import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.DecoratedFeatureConfig;
import net.minecraft.world.gen.feature.TreeFeatureConfig; import net.minecraft.world.gen.feature.TreeFeatureConfig;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Random; import java.util.Random;
import static techreborn.TechReborn.LOGGER;
public class RubberSaplingGenerator extends SaplingGenerator { public class RubberSaplingGenerator extends SaplingGenerator {
public static final Identifier IDENTIFIER = new Identifier("techreborn", "techreborn/features/rubber_tree.json"); public static final Identifier IDENTIFIER = new Identifier("techreborn", "techreborn/features/rubber_tree.json");
@Nullable @Nullable
@Override @Override
protected ConfiguredFeature<TreeFeatureConfig, ?> getTreeFeature(Random random, boolean bl) { protected ConfiguredFeature<TreeFeatureConfig, ?> getTreeFeature(Random random, boolean bl) {
DecoratedFeatureConfig decoratedFeatureConfig = (DecoratedFeatureConfig) BuiltinRegistries.CONFIGURED_FEATURE.get(IDENTIFIER).getConfig(); // DecoratedFeatureConfig decoratedFeatureConfig = (DecoratedFeatureConfig) BuiltinRegistries.CONFIGURED_FEATURE.get(IDENTIFIER).getConfig();
//noinspection unchecked // //noinspection unchecked
return (ConfiguredFeature<TreeFeatureConfig, ?>) decoratedFeatureConfig.feature.get(); // return (ConfiguredFeature<TreeFeatureConfig, ?>) decoratedFeatureConfig.feature.get();
return null; // TODO 1.18
} }
} }

View file

@ -24,11 +24,8 @@
package techreborn.world; package techreborn.world;
import com.mojang.serialization.Codec;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Heightmap; import net.minecraft.world.Heightmap;
import net.minecraft.world.gen.decorator.ChanceDecoratorConfig;
import net.minecraft.world.gen.decorator.Decorator;
import net.minecraft.world.gen.decorator.DecoratorContext; import net.minecraft.world.gen.decorator.DecoratorContext;
import java.util.Random; import java.util.Random;
@ -36,25 +33,27 @@ import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
// Big thanks to SuperCoder7979 for this // Big thanks to SuperCoder7979 for this
public class RubberTreeDecorator extends Decorator<ChanceDecoratorConfig> { public class RubberTreeDecorator { // extends Decorator<ChanceDecoratorConfig> {
public RubberTreeDecorator(Codec<ChanceDecoratorConfig> codec) { // TODO 1.18
super(codec);
}
@Override // public RubberTreeDecorator(Codec<ChanceDecoratorConfig> codec) {
public Stream<BlockPos> getPositions(DecoratorContext context, Random random, ChanceDecoratorConfig config, BlockPos pos) { // super(codec);
// Generate tree clusters randomly // }
if (random.nextInt(config.chance) == 0) { //
// Generate 4 - 8 trees // @Override
int treeCount = 4 + random.nextInt(5); // public Stream<BlockPos> getPositions(DecoratorContext context, Random random, ChanceDecoratorConfig config, BlockPos pos) {
return IntStream.range(0, treeCount).mapToObj((i) -> { // // Generate tree clusters randomly
int x = random.nextInt(16) + pos.getX(); // if (random.nextInt(config.chance) == 0) {
int z = random.nextInt(16) + pos.getZ(); // // Generate 4 - 8 trees
int y = context.getTopY(Heightmap.Type.MOTION_BLOCKING, x, z); // int treeCount = 4 + random.nextInt(5);
return new BlockPos(x, y, z); // return IntStream.range(0, treeCount).mapToObj((i) -> {
}); // int x = random.nextInt(16) + pos.getX();
} // int z = random.nextInt(16) + pos.getZ();
return Stream.empty(); // int y = context.getTopY(Heightmap.Type.MOTION_BLOCKING, x, z);
} // return new BlockPos(x, y, z);
// });
// }
// return Stream.empty();
// }
} }

View file

@ -30,7 +30,6 @@ import net.fabricmc.fabric.api.biome.v1.ModificationPhase;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.gen.decorator.ChanceDecoratorConfig;
import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.TreeFeatureConfig; import net.minecraft.world.gen.feature.TreeFeatureConfig;
import net.minecraft.world.gen.foliage.FoliagePlacerType; import net.minecraft.world.gen.foliage.FoliagePlacerType;
@ -38,6 +37,7 @@ import reborncore.mixin.common.AccessorFoliagePlacerType;
import java.util.List; import java.util.List;
// TODO 1.18
public class WorldGenerator { public class WorldGenerator {
public static Feature<TreeFeatureConfig> RUBBER_TREE_FEATURE; public static Feature<TreeFeatureConfig> RUBBER_TREE_FEATURE;
public static RubberTreeDecorator RUBBER_TREE_DECORATOR; public static RubberTreeDecorator RUBBER_TREE_DECORATOR;
@ -57,7 +57,7 @@ public class WorldGenerator {
(biomeSelectionContext, biomeModificationContext) -> { (biomeSelectionContext, biomeModificationContext) -> {
for (DataDrivenFeature feature : features) { for (DataDrivenFeature feature : features) {
if (feature.getBiomeSelector().test(biomeSelectionContext)) { if (feature.getBiomeSelector().test(biomeSelectionContext)) {
biomeModificationContext.getGenerationSettings().addFeature(feature.getGenerationStep(), feature.getRegistryKey()); // biomeModificationContext.getGenerationSettings().addFeature(feature.getGenerationStep(), feature.getRegistryKey());
} }
} }
}); });
@ -65,7 +65,7 @@ public class WorldGenerator {
private static void registerTreeDecorators() { private static void registerTreeDecorators() {
RUBBER_TREE_FEATURE = Registry.register(Registry.FEATURE, new Identifier("techreborn:rubber_tree"), new RubberTreeFeature(TreeFeatureConfig.CODEC)); RUBBER_TREE_FEATURE = Registry.register(Registry.FEATURE, new Identifier("techreborn:rubber_tree"), new RubberTreeFeature(TreeFeatureConfig.CODEC));
RUBBER_TREE_DECORATOR = Registry.register(Registry.DECORATOR, new Identifier("techreborn:rubber_tree"), new RubberTreeDecorator(ChanceDecoratorConfig.CODEC)); // RUBBER_TREE_DECORATOR = Registry.register(Registry.DECORATOR, new Identifier("techreborn:rubber_tree"), new RubberTreeDecorator(ChanceDecoratorConfig.CODEC));
RUBBER_TREE_FOLIAGE_PLACER_TYPE = AccessorFoliagePlacerType.register("techreborn:rubber_tree", RubberTreeFeature.FoliagePlacer.CODEC); RUBBER_TREE_FOLIAGE_PLACER_TYPE = AccessorFoliagePlacerType.register("techreborn:rubber_tree", RubberTreeFeature.FoliagePlacer.CODEC);
} }
} }