Skip to content

Commit

Permalink
0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
augustresende committed Aug 16, 2020
1 parent da0057c commit 540b68c
Show file tree
Hide file tree
Showing 49 changed files with 458 additions and 489 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ curseforge {
releaseType = 'release'
addGameVersion '1.16'
addGameVersion '1.16.1'
addGameVersion '1.16.2'
addGameVersion 'Java 8'
addGameVersion 'Java 9'
addGameVersion 'Java 10'
Expand All @@ -43,7 +44,6 @@ curseforge {
mainArtifact(new File(new File(buildDir, "libs"), "$archivesBaseName-${version}.jar")) {
displayName = "$archivesBaseName-$version"
relations {
optionalDependency 'mixinbootstrap'
requiredDependency 'fabric-api'
}
}
Expand Down
4 changes: 2 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This version adds Fishing unpatch (you can use your afk fishing farms without any trouble), adds some advancements and fixes some bugs.
And now the jar is 30% smaller, and Fabric loads faster.
This version (0.2.0) adds configuration (you can disable everything that you don't want) and support for 1.16.2
Still works on 1.16.1, Forge & Fabric (tested).
15 changes: 15 additions & 0 deletions common/src/main/java/com/vanilla/experience/CommonUtils.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package com.vanilla.experience;

import java.io.File;

public class CommonUtils {

public static int zeroTickVersionPatch = 2524;
public static int witherRosesVersionPatch = 2554;
public static int protectionVersionPatch = 1965;
public static int fishingVersionPatch = 2520;
public static int zeroTickAbstractChange = 2569;
public static String modId = "vanillaexperience";

private static int worldVersion;
private static final File configFilePath = new File("./config/"+ modId +".json");
private static Config.ConfigBean currentConfig = new Config.ConfigBean();

public CommonUtils(int version) {
worldVersion = version;

currentConfig = new Config(configFilePath).get();
}

public static boolean isZeroTickPatched() {
Expand All @@ -29,4 +36,12 @@ public static boolean isProtectionPatched() {
public static boolean isFishingPatched() {
return worldVersion >= CommonUtils.fishingVersionPatch;
}

public static boolean isZeroTickAbstractChanged() {
return worldVersion >= zeroTickAbstractChange;
}

public static Config.ConfigBean getConfig() {
return currentConfig;
}
}
89 changes: 89 additions & 0 deletions common/src/main/java/com/vanilla/experience/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.vanilla.experience;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Config {
private File configFilePath;

private static final Logger LOGGER = LogManager.getLogger();

public Config(File configFilePath) {
this.configFilePath = configFilePath;
}

public static class ConfigBean {
public boolean isDataPackEnabled = true;
public boolean isEnhancedBerriesEnabled = true;
public boolean isEnhancedBoneMealEnabled = true;
public boolean isEnhancedBurningEnabled = true;
public boolean isEnhancedIceEnabled = true;
public boolean isEnhancedKelpEnabled = true;
public boolean isEnhancedSeedsEnabled = true;
public boolean isEnhancedTotemEnabled = true;
public boolean isFishingUnpatchEnabled = true;
public boolean isProtectionUnpatchEnabled = true;
public boolean isSlimeSuperFlatPatchEnabled = true;
public boolean isWitherRosesUnpatchEnabled = true;
public boolean isZeroTickUnpatchEnabled = true;

public int currentFileVersionPleaseNeverChangeThisModInternalUsageOnly = 1;
}

private ConfigBean currentConfig = null;

public ConfigBean get() {
if(currentConfig != null) return currentConfig;

if(configFilePath.exists()) currentConfig = this.load();

if(currentConfig != null) return currentConfig;

currentConfig = new ConfigBean();

this.writeConfigFile(currentConfig);
return currentConfig;
}

private ConfigBean load() {
ConfigBean currentConfig = this.readConfigFile(configFilePath);
if (currentConfig != null) {
if(currentConfig.currentFileVersionPleaseNeverChangeThisModInternalUsageOnly == 1) return currentConfig;
// UPGRADE CONFIG ROUTINES
}
return null;
}

public ConfigBean readConfigFile(File path) {
try (FileReader file = new FileReader(path)) {
Gson gson = new Gson();
return gson.fromJson(file, ConfigBean.class);
}
catch (IOException e) {
LOGGER.error("Failed to read from config.");
return null;
}
}

public void writeConfigFile(ConfigBean config) {
if (!configFilePath.getParentFile().exists() && !configFilePath.getParentFile().mkdirs()) {
LOGGER.error("Failed to write the config.");
return;
}
try (FileWriter file = new FileWriter(configFilePath)) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
file.write(gson.toJson(config));
file.flush();
}
catch (IOException e) {
LOGGER.error("Failed to write the config.");
}
}
}

This file was deleted.

This file was deleted.

9 changes: 4 additions & 5 deletions fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ mod_id=vanillaexperience

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.1
yarn_mappings=1.16.1+build.21
loader_version=0.8.8+build.203
minecraft_version=1.16.2
yarn_mappings=1.16.2+build.19
loader_version=0.9.1+build.205

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.14.1+build.372-1.16
fabric_asm_version=v2.0
fabric_version=0.18.0+build.397-1.16
Empty file added fabric/logs/latest.log
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.vanilla.experience.fabric;

import com.vanilla.experience.Config;
import com.vanilla.experience.fabric.datapack.DataPackDisabler;
import com.vanilla.experience.fabric.enhancedbonemeal.EnhancedBoneMeal;
import com.vanilla.experience.fabric.enhancedbonemeal.EnhancedBoneMealDispenserBehaviour;
import com.vanilla.experience.fabric.enhancedburning.FlintAndSteelAttack;
Expand All @@ -8,23 +10,34 @@
import com.vanilla.experience.fabric.enhancedseeds.EnhancedSeeds;
import com.vanilla.experience.fabric.enhancedseeds.EnhancedSeedsDispenserBehaviour;
import com.vanilla.experience.HelloMessage;
import com.vanilla.experience.fabric.utils.VexUtils;
import net.fabricmc.api.ModInitializer;
import net.minecraft.block.SpawnerBlock;
import net.minecraft.block.entity.MobSpawnerBlockEntity;

public class VanillaExperience implements ModInitializer {

@Override
public void onInitialize() {
Config.ConfigBean config = VexUtils.getConfig();

new HelloMessage();
new EnhancedBoneMeal();
new EnhancedSeeds();
new EnhancedKelp();
new EnhancedBoneMealDispenserBehaviour();
new EnhancedSeedsDispenserBehaviour();
new EnhancedKelpDispenserBehaviour();
new FlintAndSteelAttack();
ZombieEntity
if(config.isEnhancedBoneMealEnabled) {
new EnhancedBoneMeal();
new EnhancedBoneMealDispenserBehaviour();
}
if(config.isEnhancedSeedsEnabled) {
new EnhancedSeeds();
new EnhancedSeedsDispenserBehaviour();
}
if(config.isEnhancedKelpEnabled) {
new EnhancedKelp();
new EnhancedKelpDispenserBehaviour();
}
if(!config.isDataPackEnabled) {
new DataPackDisabler();
}
if(config.isEnhancedBurningEnabled) {
new FlintAndSteelAttack();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.vanilla.experience.fabric.datapack;

import com.vanilla.experience.fabric.utils.VexUtils;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents.ServerStarted;
import net.minecraft.server.MinecraftServer;

public class DataPackDisabler implements ServerStarted {

public DataPackDisabler() {
ServerLifecycleEvents.SERVER_STARTED.register(this);
}

@Override
public void onServerStarted(MinecraftServer server) {
server.getCommandManager().execute(server.getCommandSource().withLevel(2), "datapack disable \"fabric/" + VexUtils.getModId() + "\"");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Property;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.util.math.BlockPos;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.vanilla.experience.fabric.enhancedburning;

import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.vanilla.experience.fabric.enhancedburning.mixin;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.world.World;
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;

@Mixin(LivingEntity.class)
public abstract class FirePatchMixin extends Entity {

public FirePatchMixin(EntityType<?> type, World world) {
super(type, world);
}

@Shadow public abstract boolean hasStatusEffect(StatusEffect effect);

@Inject(method = "onDeath", at = @At("HEAD"))
private void onDeath(DamageSource source, CallbackInfo info) {
if(source.isFire()) {
if(!this.isOnFire()) {
this.setOnFireFor(1);
}
}
}

@Inject(method = "baseTick", at = @At("HEAD"))
private void baseTick(CallbackInfo info) {
if(this.hasStatusEffect(StatusEffects.FIRE_RESISTANCE)) {
this.extinguish();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.block.*;
import net.minecraft.block.dispenser.FallibleItemDispenserBehavior;
import net.minecraft.item.BoneMealItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.world.ServerWorld;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.stat.Stats;
import org.apache.logging.log4j.core.jmx.Server;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand Down
Loading

0 comments on commit 540b68c

Please sign in to comment.