Skip to content

Commit

Permalink
Merge branch 'feature/new-mappings' into 1.16
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
cech12 committed Jun 26, 2021
2 parents 6e184a7 + eea6a0b commit 7da70d5
Show file tree
Hide file tree
Showing 44 changed files with 1,047 additions and 236 deletions.
45 changes: 36 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
Expand All @@ -13,9 +12,9 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = "${mod_version}-${minecraft_version}"
version = "${minecraft_version}-${mod_version}"
group = 'cech12.ceramicbucket' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'ceramicbucket'
archivesBaseName = "${mod_id}"

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

Expand All @@ -26,7 +25,7 @@ minecraft {
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'snapshot', version: forge_mappings
mappings channel: 'official', version: minecraft_version
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
Expand All @@ -42,7 +41,7 @@ minecraft {
property 'ceramicbucket.developmentMode', 'true'

mods {
examplemod {
ceramicbucket {
source sourceSets.main
}
}
Expand All @@ -56,23 +55,47 @@ minecraft {
property 'ceramicbucket.developmentMode', 'true'

mods {
examplemod {
ceramicbucket {
source sourceSets.main
}
}
}

def testClasses = String.join(File.pathSeparator,
"${mod_id}%%${sourceSets.main.output.resourcesDir}",
"${mod_id}%%${sourceSets.main.output.classesDirs.asPath}",
"${mod_id}%%${sourceSets.test.output.resourcesDir}",
"${mod_id}%%${sourceSets.test.output.classesDirs.asPath}")

serverTest {
parent runs.server // This run config inherits settings from the server config
workingDirectory project.file('run')
main 'com.alcatrazescapee.mcjunitlib.DedicatedTestServerLauncher' // The main class which launches a customized server which then runs JUnit tests
ideaModule "${project.name}.test" // Tell IDEA to use the classpath of the test module
property 'forge.logging.console.level', 'unittest' // This logging level prevents any other server information messages and leaves only the test output
environment 'MOD_CLASSES', testClasses
environment 'target', 'fmltestserver' // This is a custom service used to launch with ModLauncher's transforming class loader
environment 'targetModId', "${mod_id}" // Pass the mod ID directly to mcjunitlib, to find integration test classes from the mod annotation scan data
arg '--crashOnFailedTests' // Optional. Recommended when running in an automated environment. Without it, the server will continue running (and can be connected to via localhost) to inspect why tests failed.
forceExit = false // Optional. Recommended when running in an automated environment, or via the console rather than run configurations. This will allow the task to pass successfully when all tests pass. Use if you see errors along the lines of 'Gradle daemon disappeared unexpectedly'.
mods {
ceramicbucket {
sources sourceSets.main, sourceSets.test
}
}
}

data {
workingDirectory project.file('run')

property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
property 'ceramicbucket.developmentMode', 'true'

args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')
args '--mod', 'ceramicbucket', '--all', '--output', file('src/generated/resources/')

mods {
examplemod {
ceramicbucket {
source sourceSets.main
}
}
Expand All @@ -91,19 +114,23 @@ repositories {
name = "ModMaven"
url = "https://modmaven.k-4u.nl"
}
//for mcjunitlib
maven { url 'https://jitpack.io' }
}

dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft "net.minecraftforge:forge:${project.forge_version}"
minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
implementation 'org.jetbrains:annotations:15.0'

// compile against the JEI API but do not include it at runtime
compileOnly fg.deobf("mezz.jei:jei-${project.jei_version}:api")
// at runtime, use the full JEI jar
runtimeOnly fg.deobf("mezz.jei:jei-${project.jei_version}")

testImplementation fg.deobf("com.github.alcatrazEscapee:mcjunitlib:${project.mcjunitlib_version}")
}

// Example for how to get properties into the manifest for reading by the runtime..
Expand Down
8 changes: 8 additions & 0 deletions config/fml.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Enable forge global version checking
versionCheck = true
# does the splashscreen run
splashscreen = true
defaultConfigPath = "defaultconfigs"
# max threads for parallel loading : -1 uses Runtime#availableProcessors
maxThreads = -1

3 changes: 3 additions & 0 deletions eula.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Mon Jun 14 20:01:56 CEST 2021
eula=true
13 changes: 7 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_version=2.6.4
minecraft_version=1.16.2+

forge_version=1.16.2-33.0.21
forge_mappings=20200916-1.16.2
mod_id=ceramicbucket
mod_version=2.7.0
minecraft_version=1.16.5
forge_version=36.1.0

# jei
jei_version=1.16.2:7.1.+
jei_version=1.16.5:7.6.1.75

# mcjunitlib
mcjunitlib_version=1.4.3-1.16.5
22 changes: 11 additions & 11 deletions src/main/java/cech12/ceramicbucket/CeramicBucketMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ private static void onEntityInteract(PlayerInteractEvent.EntityInteract event) {
if (entity == null) return;

PlayerEntity player = event.getPlayer();
ItemStack itemstack = player.getHeldItem(event.getHand());
ItemStack itemstack = player.getItemInHand(event.getHand());

if (ServerConfig.MILKING_ENABLED.get() && ModCompat.canEntityBeMilked(entity)) {
if (itemstack.getItem() == CeramicBucketItems.CERAMIC_BUCKET && !player.abilities.isCreativeMode) {
player.playSound(SoundEvents.ENTITY_COW_MILK, 1.0F, 1.0F);
if (!event.getWorld().isRemote()) {
if (itemstack.getItem() == CeramicBucketItems.CERAMIC_BUCKET && !player.abilities.instabuild) {
player.playSound(SoundEvents.COW_MILK, 1.0F, 1.0F);
if (!event.getWorld().isClientSide()) {
ItemStack milkBucket = ((CeramicMilkBucketItem)CeramicBucketItems.CERAMIC_MILK_BUCKET).getFilledInstance(itemstack);
itemstack.shrink(1);
if (itemstack.isEmpty()) {
player.setHeldItem(event.getHand(), milkBucket);
} else if (!player.inventory.addItemStackToInventory(milkBucket)) {
player.dropItem(milkBucket, false);
player.setItemInHand(event.getHand(), milkBucket);
} else if (!player.inventory.add(milkBucket)) {
player.drop(milkBucket, false);
}
}
event.setCanceled(true);
Expand All @@ -114,16 +114,16 @@ private static void onEntityInteract(PlayerInteractEvent.EntityInteract event) {
if (ModCompat.canEntityBeObtained(fluid, entity)) {
ItemStack filledBucket = ((CeramicEntityBucketItem)CeramicBucketItems.CERAMIC_ENTITY_BUCKET).getFilledInstance(fluid, entity, itemstack);
((CeramicEntityBucketItem) CeramicBucketItems.CERAMIC_ENTITY_BUCKET).playFillSound(player, filledBucket);
if (!event.getWorld().isRemote()) {
if (!event.getWorld().isClientSide()) {
itemstack.shrink(1);
if (player instanceof ServerPlayerEntity) {
CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayerEntity) player, filledBucket);
CeramicBucketUtils.grantAdvancement((ServerPlayerEntity) player, ModCompat.getEntityObtainingAdvancement(fluid, entity));
}
if (itemstack.isEmpty()) {
player.setHeldItem(event.getHand(), filledBucket);
} else if (!player.inventory.addItemStackToInventory(filledBucket)) {
player.dropItem(filledBucket, false);
player.setItemInHand(event.getHand(), filledBucket);
} else if (!player.inventory.add(filledBucket)) {
player.drop(filledBucket, false);
}
}
event.setCanceled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ public FilledCeramicBucketIngredient(ITag.INamedTag<Fluid> fluidTag) {
}

public FilledCeramicBucketIngredient(ResourceLocation resourceLocation) {
this(FluidTags.makeWrapperTag(resourceLocation.toString()));
this(FluidTags.bind(resourceLocation.toString()));
}

@Override
public boolean test(ItemStack itemStack) {
AtomicBoolean result = new AtomicBoolean(false);
if (itemStack != null && itemStack.getItem() == CeramicBucketItems.FILLED_CERAMIC_BUCKET) {
FluidUtil.getFluidContained(itemStack).ifPresent(fluidStack -> result.set(fluidStack.getFluid().isIn(fluidTag)));
FluidUtil.getFluidContained(itemStack).ifPresent(fluidStack -> result.set(fluidStack.getFluid().is(fluidTag)));
}
return result.get();
}

@Override
@Nonnull
public ItemStack[] getMatchingStacks() {
public ItemStack[] getItems() {
if (this.matchingStacks == null) {
FilledCeramicBucketItem bucketItem = (FilledCeramicBucketItem) CeramicBucketItems.FILLED_CERAMIC_BUCKET;
this.matchingStacks = this.fluidTag.getAllElements().stream()
this.matchingStacks = this.fluidTag.getValues().stream()
.map(fluid -> bucketItem.getFilledInstance(fluid, null))
.filter(this)
.toArray(ItemStack[]::new);
Expand All @@ -63,7 +63,7 @@ public ItemStack[] getMatchingStacks() {
}

@Override
public boolean hasNoMatchingItems() {
public boolean isEmpty() {
return false;
}

Expand All @@ -84,7 +84,7 @@ public IIngredientSerializer<? extends Ingredient> getSerializer() {
}

@Nonnull
public JsonElement serialize() {
public JsonElement toJson() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("type", Serializer.NAME.toString());
jsonObject.addProperty("tag", this.fluidTag.getName().toString());
Expand All @@ -105,13 +105,13 @@ public FilledCeramicBucketIngredient parse(PacketBuffer buffer) {

@Override
public FilledCeramicBucketIngredient parse(@Nonnull JsonObject json) {
String tag = JSONUtils.getString(json, "tag");
return new FilledCeramicBucketIngredient(FluidTags.makeWrapperTag(tag));
String tag = JSONUtils.getAsString(json, "tag");
return new FilledCeramicBucketIngredient(FluidTags.bind(tag));
}

@Override
public void write(PacketBuffer buffer, FilledCeramicBucketIngredient ingredient) {
buffer.writeString(ingredient.fluidTag.getName().toString());
buffer.writeUtf(ingredient.fluidTag.getName().toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,27 @@ public FluidIngredient(ITag.INamedTag<Fluid> fluidTag, int amount, boolean exact
}

public FluidIngredient(ResourceLocation resourceLocation, int amount, boolean exact) {
this(FluidTags.makeWrapperTag(resourceLocation.toString()), amount, exact);
this(FluidTags.bind(resourceLocation.toString()), amount, exact);
}

@Override
public boolean test(ItemStack itemStack) {
AtomicBoolean result = new AtomicBoolean(false);
if (itemStack != null) {
FluidUtil.getFluidContained(itemStack).ifPresent(fluidStack ->
result.set(fluidStack.getFluid().isIn(fluidTag) && ((this.exact) ? fluidStack.getAmount() == this.amount : fluidStack.getAmount() >= this.amount))
result.set(fluidStack.getFluid().is(fluidTag) && ((this.exact) ? fluidStack.getAmount() == this.amount : fluidStack.getAmount() >= this.amount))
);
}
return result.get();
}

@Override
@Nonnull
public ItemStack[] getMatchingStacks() {
public ItemStack[] getItems() {
if (this.matchingStacks == null) {
ArrayList<ItemStack> stacks = new ArrayList<>();
ArrayList<Fluid> addedFluids = new ArrayList<>();
this.fluidTag.getAllElements().forEach(fluid -> {
this.fluidTag.getValues().forEach(fluid -> {
//only fluid buckets which are obtainable
ItemStack bucket = FluidUtil.getFilledBucket(new FluidStack(fluid, amount));
Fluid bucketFluid = FluidUtil.getFluidContained(bucket).orElse(FluidStack.EMPTY).getFluid();
Expand All @@ -83,7 +83,7 @@ public ItemStack[] getMatchingStacks() {
}

@Override
public boolean hasNoMatchingItems() {
public boolean isEmpty() {
return false;
}

Expand All @@ -104,7 +104,7 @@ public IIngredientSerializer<? extends Ingredient> getSerializer() {
}

@Nonnull
public JsonElement serialize() {
public JsonElement toJson() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("type", Serializer.NAME.toString());
jsonObject.addProperty("tag", this.fluidTag.getName().toString());
Expand All @@ -129,18 +129,18 @@ public FluidIngredient parse(PacketBuffer buffer) {

@Override
public FluidIngredient parse(@Nonnull JsonObject json) {
String tag = JSONUtils.getString(json, "tag");
int amount = JSONUtils.getInt(json, "amount");
String tag = JSONUtils.getAsString(json, "tag");
int amount = JSONUtils.getAsInt(json, "amount");
boolean exact = false;
if (JSONUtils.hasField(json, "exact")) {
exact = JSONUtils.getBoolean(json, "exact");
if (JSONUtils.isValidNode(json, "exact")) {
exact = JSONUtils.getAsBoolean(json, "exact");
}
return new FluidIngredient(FluidTags.makeWrapperTag(tag), amount, exact);
return new FluidIngredient(FluidTags.bind(tag), amount, exact);
}

@Override
public void write(PacketBuffer buffer, FluidIngredient ingredient) {
buffer.writeString(ingredient.fluidTag.getName().toString());
buffer.writeUtf(ingredient.fluidTag.getName().toString());
buffer.writeInt(ingredient.amount);
buffer.writeBoolean(ingredient.exact);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean isCorrectFluid(Fluid fluid) {
}
}
for (ITag<Fluid> tag : this.fluidTags) {
if (fluid.isIn(tag)) {
if (fluid.is(tag)) {
return true;
}
}
Expand All @@ -81,8 +81,8 @@ public static class Builder {
private final List<Fluid> fluids = new ArrayList<>();
private final List<ITag<Fluid>> fluidTags = new ArrayList<>();
private Boolean cracksBucket = null;
private ResourceLocation emptySound = ForgeRegistries.SOUND_EVENTS.getKey(SoundEvents.ITEM_BUCKET_EMPTY_FISH);
private ResourceLocation fillSound = ForgeRegistries.SOUND_EVENTS.getKey(SoundEvents.ITEM_BUCKET_FILL_FISH);
private ResourceLocation emptySound = ForgeRegistries.SOUND_EVENTS.getKey(SoundEvents.BUCKET_EMPTY_FISH);
private ResourceLocation fillSound = ForgeRegistries.SOUND_EVENTS.getKey(SoundEvents.BUCKET_FILL_FISH);

public Builder(@Nonnull EntityType<?> entityType, Fluid fluid) {
this.entityType = ForgeRegistries.ENTITIES.getKey(entityType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void clientSetup(ModelRegistryEvent event) {

@SubscribeEvent
public static void onTextureStitch(TextureStitchEvent.Pre event){
if (event.getMap().getTextureLocation().equals(PlayerContainer.LOCATION_BLOCKS_TEXTURE)) { //AtlasTexture.LOCATION_BLOCKS_TEXTURE
if (event.getMap().location().equals(PlayerContainer.BLOCK_ATLAS)) { //AtlasTexture.LOCATION_BLOCKS_TEXTURE
for (ObtainableEntityType entityType : ModCompat.getObtainableEntityTypes()) {
ResourceLocation entityTypeKey = ForgeRegistries.ENTITIES.getKey(entityType.getEntityType());
if (entityTypeKey != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<
if (fluid != Fluids.EMPTY && fluid.getAttributes().isLighterThanAir())
{
modelTransform = new SimpleModelTransform(
modelTransform.getRotation().blockCornerToCenter().composeVanilla(
modelTransform.getRotation().blockCornerToCenter().compose(
new TransformationMatrix(null, new Quaternion(0, 0, 1, 0), null, null)).blockCenterToCorner());
}

Expand Down Expand Up @@ -201,9 +201,9 @@ private ContainedFluidOverrideHandler(ItemOverrideList nested, ModelBakery baker

@Nullable
@Override
public IBakedModel getOverrideModel(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
public IBakedModel resolve(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
{
IBakedModel overriden = nested.getOverrideModel(originalModel, stack, world, entity);
IBakedModel overriden = nested.resolve(originalModel, stack, world, entity);
if (overriden != originalModel) return overriden;
if (stack.getItem() instanceof AbstractCeramicBucketItem) {
AbstractCeramicBucketItem bucket = (AbstractCeramicBucketItem) stack.getItem();
Expand Down
Loading

0 comments on commit 7da70d5

Please sign in to comment.