Skip to content

Commit

Permalink
Merge branch 'master' into add-zh_cn
Browse files Browse the repository at this point in the history
  • Loading branch information
InfinityRaider committed May 29, 2023
2 parents d844d15 + 75e82b7 commit b75609c
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 37 deletions.
67 changes: 36 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ buildscript {
plugins {
id 'eclipse'
id 'maven-publish'
id 'jacoco'
id 'jacoco'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}


Expand Down Expand Up @@ -197,36 +198,34 @@ repositories {
url 'https://maven.blakesmods.com'
}

maven { // Registrate
url "https://maven.tterrag.com/"
}

// For AgriCore dependencies
mavenCentral()
}


// Add "embedded" configuration
configurations {
embed
implementation.extendsFrom(embed)
}

// To make sure Forge does not ignore the embedded projects
// See: https://gist.github.com/SizableShrimp/66b22f1b24c255e1491c8d98d3f11f83
minecraft.runs.all {
lazyToken('minecraft_classpath') {
configurations.embed.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
}
shade
implementation.extendsFrom shade
}

// List Deps.
dependencies {
// Minecraft
minecraft 'net.minecraftforge:forge:1.18.2-40.1.51'//"net.minecraftforge:forge:${config.version_minecraft}-${config.version_forge}"
minecraft 'net.minecraftforge:forge:1.18.2-40.2.2'//"net.minecraftforge:forge:${config.version_minecraft}-${config.version_forge}"

// Apply Mixin AP
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

// AgriCore
embed project(':AgriCore')

minecraftLibrary project(':AgriCore')
shade project(':AgriCore')
shade 'org.reflections:reflections:0.10.2'

// InfinityLib
implementation project(":InfinityLib")

Expand All @@ -239,18 +238,19 @@ dependencies {
//runtimeOnly fg.deobf("vazkii.botania:Botania:1.18.2-430")

//Create
compileOnly fg.deobf("curse.maven:create-328085:3872145")
compileOnly fg.deobf("curse.maven:flywheel-486392:3871082") // create dependency v1.16.5-0.1.1
//runtimeOnly fg.deobf("curse.maven:create-328085:3872145")
//runtimeOnly fg.deobf("curse.maven:flywheel-486392:3871082") // create dependency
compileOnly fg.deobf("curse.maven:create-328085:4341477") // 1.18.2-0.5.0h
compileOnly fg.deobf("curse.maven:flywheel-486392:4341461") // 1.18.2-0.6.8.a
compileOnly fg.deobf("com.tterrag.registrate:Registrate:MC1.18.2-1.1.3")
runtimeOnly fg.deobf("curse.maven:create-328085:4341477")
runtimeOnly fg.deobf("curse.maven:flywheel-486392:4341461")

//Cyclic
compileOnly fg.deobf("curse.maven:cyclic-239286:3708026")
//runtimeOnly fg.deobf("curse.maven:cyclic-239286:3708026")

//Immersive Engineering
compileOnly fg.deobf("blusunrize.immersiveengineering:ImmersiveEngineering:1.18.2-8.0.0-146.7")
runtimeOnly fg.deobf("blusunrize.immersiveengineering:ImmersiveEngineering:1.18.2-8.0.0-146.7")
// runtimeOnly fg.deobf("blusunrize.immersiveengineering:ImmersiveEngineering:1.18.2-8.0.0-146.7")

//Industrial Foregoing
compileOnly fg.deobf("curse.maven:industrial_foregoing-266515:3817385")
Expand All @@ -269,8 +269,8 @@ dependencies {
//Quark
compileOnly fg.deobf("vazkii.quark:Quark:3.2-358.2422")
compileOnly fg.deobf("vazkii.autoreglib:AutoRegLib:1.7-53.111")
runtimeOnly fg.deobf("vazkii.quark:Quark:3.2-358.2422")
runtimeOnly fg.deobf("vazkii.autoreglib:AutoRegLib:1.7-53.111")
// runtimeOnly fg.deobf("vazkii.quark:Quark:3.2-358.2422")
// runtimeOnly fg.deobf("vazkii.autoreglib:AutoRegLib:1.7-53.111")


//Serene Seasons
Expand Down Expand Up @@ -301,6 +301,7 @@ processResources {
}

jar {
archiveClassifier = 'slim'
// Manifest
manifest {
attributes([
Expand All @@ -313,16 +314,20 @@ jar {
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
// Fix Shading
configurations.embed.each { dep ->
from(project.zipTree(dep)){
exclude 'META-INF', 'META-INF/**'
exclude 'com/google', 'com/google/**'
exclude 'net/jcip', 'net/jcip/**'
exclude 'edu/umd', 'edu/umd/**'
exclude 'javax/annotation', 'javax/annotation/**'
}
}
}

shadowJar {
archiveClassifier = ''
configurations = [project.configurations.shade]
relocate 'org.reflections', "com.infinityraider.agricraft.relocated.reflections"
exclude 'org/slf4j', 'org/slf4j/**'
exclude 'com/google', 'com/google/**'
finalizedBy 'reobfShadowJar'
}
assemble.dependsOn shadowJar

reobf {
shadowJar {}
}

// Example configuration to allow publishing using the maven-publish task
Expand Down
2 changes: 1 addition & 1 deletion lib/AgriPlants
4 changes: 2 additions & 2 deletions mod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ version_patch = 4

# Core
version_minecraft = 1.18.2
version_forge = 40.1.51
version_forge = 40.2.2
mapping_channel = parchment
mapping_version = 2022.03.13-1.18.2
mapping_version = 2022.11.06-1.18.2

# Reference
mod_class = AgriCraft.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,10 @@ public ItemStack getSeedStack(BlockGetter world, BlockPos pos) {
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder context) {
List<ItemStack> drops = Lists.newArrayList();
BlockEntity tile = context.getParameter(LootContextParams.BLOCK_ENTITY);
BlockEntity tile = context.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
if (tile == null) {
return drops;
}
CropState cropState = STATE.fetch(state);
CropStickVariant stickType = VARIANT.fetch(state);
// add crop sticks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ protected boolean runPlantingConversion(Level world, BlockPos pos, ItemStack sta
if(cropSticks) {
return consumed.getValue();
}
// there is a block, do not place the seed
if (!world.getBlockState(pos).isAir()) {
return false;
}
// no crop sticks, try planting as a plant
BlockCrop blockCrop = AgriBlockRegistry.getInstance().getCropBlock();
BlockState newState = blockCrop.adaptStateForPlacement(blockCrop.blockStatePlant(), world, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class CreateCompat {
* Until Create exposes harvesting logic in an API or via IMC, we must do it this way, unfortunately.
*/
static void injectAgriHarvesterMovementBehaviour() {
AllMovementBehaviours.registerBehaviour(AllBlocks.MECHANICAL_HARVESTER.get().delegate, new AgriHarvesterMovementBehaviour());
AllMovementBehaviours.registerBehaviour(AllBlocks.MECHANICAL_HARVESTER.getId(), new AgriHarvesterMovementBehaviour());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.infinityraider.agricraft.plugins.minecraft;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.infinityraider.agricraft.AgriCraft;
import com.infinityraider.agricraft.api.v1.crop.IAgriCrop;
import com.infinityraider.agricraft.api.v1.plant.IJsonPlantCallback;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FungusBlock;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

public class JsonPlantCallBackSummon implements IJsonPlantCallback {

public static final String ID = AgriCraft.instance.getModId() + ":" + "summon";
public static final String ENTITY = "entity";

private final EntityType<?> entityType;

private static final IJsonPlantCallback.Factory FACTORY = new IJsonPlantCallback.Factory() {
@Override
public String getId() {
return ID;
}

@Override
public IJsonPlantCallback makeCallBack(JsonElement json) throws JsonParseException {
if (json instanceof JsonObject) {
JsonObject obj = json.getAsJsonObject();
if (obj.has(ENTITY)) {
EntityType<?> entityType = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(obj.get(ENTITY).getAsString()));
if (entityType != null) {
return new JsonPlantCallBackSummon(entityType);
}
throw new JsonParseException("Invalid entity id.");
}
throw new JsonParseException("Json object does not contain a \"" + ENTITY + "\" field.");
}
throw new JsonParseException("Not a json object.");
}
};

private JsonPlantCallBackSummon(EntityType<?> entityType) {
this.entityType = entityType;
}


public static IJsonPlantCallback.Factory getFactory() {
return FACTORY;
}


@Override
public void onHarvest(@NotNull IAgriCrop crop, @Nullable LivingEntity entity) {
Level world = crop.world();
if (world instanceof ServerLevel serverLevel) {
Player player = null;
if (entity instanceof Player) {
player = (Player) entity;
}
if (entityType.spawn(serverLevel, null, player, crop.getPosition(), MobSpawnType.MOB_SUMMONED, true, false) != null) {
serverLevel.gameEvent(player, GameEvent.ENTITY_PLACE, crop.getPosition());
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class MinecraftPlugin implements IAgriPlugin {
public final IJsonPlantCallback.Factory tree;
public final IJsonPlantCallback.Factory poisoning;
public final IJsonPlantCallback.Factory redstone;
public final IJsonPlantCallback.Factory summon;
public final IJsonPlantCallback.Factory thorns;
public final IJsonPlantCallback.Factory withering;

Expand All @@ -42,6 +43,7 @@ public MinecraftPlugin() {
this.poisoning = JsonPlantCallBackPoisoning.getFactory();
this.redstone = JsonPlantCallBackRedstone.getFactory();
this.thorns = JsonPlantCallBackThorns.getFactory();
this.summon = JsonPlantCallBackSummon.getFactory();
this.withering = JsonPlantCallBackWithering.getFactory();
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ itemIcon="agricraft:debugger"
[[dependencies.agricraft]]
modId="forge"
mandatory=true
versionRange="[40.1,)"
versionRange="[40.2,)"
ordering="AFTER"
side="BOTH"

Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Changelog
---------
3.1.5 (unreleased)
- ADDED: Summon entity json plant callback
- CHANGED: Forge minimum version is 40.2
- FIXED: Farmer's delight rice and tomatoes texture errors
- FIXED: Create compatibility crash
- FIXED: Multiple mutations with the same output register only one mutation (LordPINE)
- FIXED: Planting crops replaces non-full blocks

3.1.4
- FIXED: Tooltip showing twice with Jade
- FIXED: Compatibility with latest Create
Expand Down

0 comments on commit b75609c

Please sign in to comment.