Skip to content

Commit

Permalink
Fix Coffee Trees & Bump Java
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeblank committed Jun 9, 2021
1 parent bbda856 commit 01e47a3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 26 deletions.
15 changes: 4 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
version = project.mod_version
version = "${project.minecraft_version}-v${project.mod_version}"
group = project.maven_group

repositories {
Expand Down Expand Up @@ -68,12 +64,9 @@ tasks.withType(JavaCompile).configureEach {
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
def targetVersion = 16
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
it.options.release = targetVersion
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=1.16.5+build.6
loader_version=0.11.3

# Mod Properties
mod_version = 0.3.4
mod_version = 0.3.5
maven_group = dev.elexi.hugeblank
archives_base_name = bagels_baking

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Mon Jan 11 22:28:44 PST 2021
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,41 @@
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.tree.CocoaBeansTreeDecorator;
import net.minecraft.world.gen.tree.TreeDecorator;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;

@Mixin(CocoaBeansTreeDecorator.class)
public abstract class CoffeeBeansTreeDecorator extends TreeDecorator {

@Inject(at = @At(value = "INVOKE", target = "Ljava/util/Random;nextFloat()F"), method = "method_23466(Ljava/util/Random;Lnet/minecraft/world/StructureWorldAccess;Ljava/util/Set;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/BlockPos;)V", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
public void generate(Random random, StructureWorldAccess world, Set<BlockPos> placedStates, BlockBox box, BlockPos pos, CallbackInfo ci, Iterator var6, Direction direction) {
if (random.nextFloat() <= 0.25F) {
Direction direction2 = direction.getOpposite();
BlockPos blockPos = pos.add(direction2.getOffsetX(), 0, direction2.getOffsetZ());
if (Feature.isAir(world, blockPos)) {
BlockState blockState = Baking.COFFEE.getDefaultState().with(CocoaBlock.AGE, random.nextInt(3)).with(CocoaBlock.FACING, direction);
this.setBlockStateAndEncompassPosition(world, blockPos, blockState, placedStates, box);
}
@Shadow
@Final
private float probability;

@Inject(at = @At("HEAD"), method = "generate(Lnet/minecraft/world/StructureWorldAccess;Ljava/util/Random;Ljava/util/List;Ljava/util/List;Ljava/util/Set;Lnet/minecraft/util/math/BlockBox;)V", cancellable = true)
public void generate(StructureWorldAccess world, Random random, List<BlockPos> logPositions, List<BlockPos> leavesPositions, Set<BlockPos> placedStates, BlockBox box, CallbackInfo ci) {
if (!(random.nextFloat() >= this.probability/2)) {
int i = logPositions.get(0).getY();
logPositions.stream().filter((pos) -> pos.getY() - i <= 2).forEach((pos) -> {
for (Direction direction : Direction.Type.HORIZONTAL) {
if (random.nextFloat() <= 0.25F) {
Direction direction2 = direction.getOpposite();
BlockPos blockPos = pos.add(direction2.getOffsetX(), 0, direction2.getOffsetZ());
if (Feature.isAir(world, blockPos)) {
BlockState blockState = Baking.COFFEE.getDefaultState().with(CocoaBlock.AGE, random.nextInt(3)).with(CocoaBlock.FACING, direction);
this.setBlockStateAndEncompassPosition(world, blockPos, blockState, placedStates, box);
}
}
}
});
ci.cancel();
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/bagels_baking.accesswidener
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
accessWidener v1 named
accessible method net/minecraft/recipe/CuttingRecipe$Serializer <init> (Lnet/minecraft/recipe/CuttingRecipe$Serializer$RecipeFactory;)V
accessible class net/minecraft/recipe/CuttingRecipe$Serializer$RecipeFactory
accessible method net/minecraft/entity/damage/DamageSource <init> (Ljava/lang/String;)V
accessible method net/minecraft/entity/damage/DamageSource <init> (Ljava/lang/String;)V
mutable field net/minecraft/item/Item maxCount I
2 changes: 1 addition & 1 deletion src/main/resources/bagels_baking.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "dev.elexi.hugeblank.bagels_baking.mixin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_16",
"mixins": [
"Splashes",
"brewing.BrewingRecipeRegistryInvoker",
Expand Down

0 comments on commit 01e47a3

Please sign in to comment.