Skip to content

Commit

Permalink
backported some features from /1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Apr 3, 2024
1 parent 1d5b6fa commit 3510b65
Show file tree
Hide file tree
Showing 34 changed files with 344 additions and 75 deletions.
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ dependencies {
runtimeOnly fg.deobf("vazkii.botania:Botania:${botania_version}")

// optional dependencies & mods for testing compat

/*
implementation fg.deobf("curse.maven:mantle-74924:3482897")
implementation fg.deobf("curse.maven:tinkers-construct-74072:3482903")
implementation fg.deobf("curse.maven:cucumber-272335:3507886")
implementation fg.deobf("curse.maven:mystical-agriculture-246640:3562127")
implementation fg.deobf("curse.maven:chunknogobyebye-332695:3195333")


implementation fg.deobf("curse.maven:yungs-api-421850:3494919")
implementation fg.deobf("curse.maven:yungs-better-strongholds-465575:3412586")
implementation fg.deobf("curse.maven:v-tweaks-238048:3675562")
*/
// To use any mod in /libs/ folder, place it in and set the mod and version to match jar filename
// runtimeOnly fg.deobf("libs:SimpleStorageNetwork:1.16.4-1.3.1")
// runtimeOnly fg.deobf("libs:refinedstorage:1.16.4-1.9.11")
Expand Down
10 changes: 10 additions & 0 deletions examples/scripts/durability.zs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


// change max damage aka durability aka number of tool uses like this

val glove = <item:cyclic:glove_climb>;
glove.maxDamage = 64;


val wand = <item:cyclic:elevation_wand>;
wand.maxDamage = 16;
14 changes: 14 additions & 0 deletions examples/scripts/generator_fluid.zs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://docs.blamejared.com/
// https://www.curseforge.com/minecraft/mc-mods/crafttweaker
// use /ct dump fluids to see all fluid IDs

var generator = <recipetype:cyclic:generator_fluid>;

generator.removeRecipe("cyclic:generator/generate_xp");
generator.removeRecipe("cyclic:generator/generate_lava");



generator.addRecipe("zoldo", <fluid:minecraft:water>*250, 5, 10);

generator.addRecipe("lava_tag", "minecraft:lava", 1000, 200, 500);
12 changes: 12 additions & 0 deletions examples/scripts/generator_item.zs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// https://docs.blamejared.com/
// https://www.curseforge.com/minecraft/mc-mods/crafttweaker
// use /ct dump fluids to see all fluid IDs

var generator = <recipetype:cyclic:generator_item>;

// recipe IDS, not item ids
generator.removeRecipe("cyclic:generator/generate_redstone");
generator.removeRecipe("cyclic:generator/generate_star");

// ID, input, output, RF per tick, ticks, bonus, percentage of bonus
generator.addRecipe("zelda", <item:minecraft:diamond_block>, 500, 120);
41 changes: 25 additions & 16 deletions src/main/java/com/lothrazar/cyclic/block/breaker/TileBreaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;

public class TileBreaker extends TileEntityBase implements INamedContainerProvider, ITickableTileEntity {

Expand Down Expand Up @@ -41,25 +43,32 @@ public void tick() {
return;
}
BlockPos target = pos.offset(this.getCurrentFacing());
BlockState state = world.getBlockState(target);
if (state.getBlock() != Blocks.AIR &&
state.getBlockHardness(world, target) >= 0) {
if (this.isValid(target)) {
this.world.destroyBlock(target, true);
// int cost = POWERCONF.get();
// ModCyclic.LOGGER.info("cost" + cost + " have " + energy.getEnergyStored());
// if (cost > 0) {
// energy.extractEnergy(cost, false);
// }
}
//else unbreakable
}
// @Override
// public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
// if (cap == CapabilityEnergy.ENERGY && POWERCONF.get() > 0) {
// return energyCap.cast();
// }
// return super.getCapability(cap, side);
// }

/**
* Avoid mining source liquid blocks and unbreakable
*/
private boolean isValid(BlockPos target) {
World level = world;
BlockState state = level.getBlockState(target);
if (state.getBlock() == Blocks.AIR) {
return false;
}
if (state.getBlockHardness(level, target) < 0) {
return false;
}
if (state.getFluidState() != null && state.getFluidState().isEmpty() == false) {
//am i a solid waterlogged state block?
if (state.hasProperty(BlockStateProperties.WATERLOGGED) == false) {
//pure liquid. but this will make canHarvestBlock go true
return false;
}
}
return true;
}

@Override
public ITextComponent getDisplayName() {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/lothrazar/cyclic/compat/CompatConstants.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
package com.lothrazar.cyclic.compat;

import net.minecraft.util.ResourceLocation;

public class CompatConstants {

public static final String RESYNTH_GROWTH_STAGE = "growth_stage";
public static final String RESYNTH = "resynth";
public static final String CRAFTTWEAKER = "crafttweaker";
public static final String CURIOS = "curios";
public static final String TCONSTRUCT = "tconstruct";
//
//compat with Repurposed Structures Mod see #1517
public static final String RS_MODID = "repurposed_structures";
public static final String RS_STRONGHOLD_ID = "stronghold_stonebrick";
public static final String RS_NETHER_STRONGHOLD_ID = "stronghold_nether";
public static final String YUSTRONG_MODID = "betterstrongholds"; // https://github.com/yungnickyoung/YUNGs-Better-Strongholds
public static final ResourceLocation RS_RESOURCE_LOCATION = new ResourceLocation(RS_MODID, RS_STRONGHOLD_ID);
public static final ResourceLocation RS_NETHER_RESOURCE_LOCATION = new ResourceLocation(RS_MODID, RS_NETHER_STRONGHOLD_ID);
public static final ResourceLocation YUNG_STRONGHOLD_LOCATION = new ResourceLocation(YUSTRONG_MODID, "stronghold");
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@

public class BotaniaWrapper {

/**
* If the botania mod is loaded, use the botania-api to check for hasSolegnoliaAround(entity); otherwise return false
*
* @param entity
* @return true if botania has found a solegnolia around the entity
*/
public static boolean hasSolegnoliaAround(LivingEntity entity) {
try {
return ModList.get().isLoaded("botania") && vazkii.botania.api.BotaniaAPI.instance().hasSolegnoliaAround(entity);
if (ModList.get().isLoaded("botania")) {
return vazkii.botania.api.BotaniaAPI.instance().hasSolegnoliaAround(entity);
}
}
catch (Exception e) {
//ive never seen an exception here yet, just being safe
}
//either botania does not exist or an error was thrown
catch (Exception e) {}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.lothrazar.cyclic.compat.crafttweaker;

import com.blamejared.crafttweaker.api.CraftTweakerAPI;
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import com.blamejared.crafttweaker.api.fluid.IFluidStack;
import com.blamejared.crafttweaker.api.managers.IRecipeManager;
import com.blamejared.crafttweaker.impl.actions.recipes.ActionAddRecipe;
import com.lothrazar.cyclic.block.generatorfluid.RecipeGeneratorFluid;
import com.lothrazar.cyclic.compat.CompatConstants;
import com.lothrazar.cyclic.recipe.CyclicRecipeType;
import com.lothrazar.cyclic.recipe.FluidTagIngredient;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openzen.zencode.java.ZenCodeType;

@ZenRegister
@ZenCodeType.Name("mods.cyclic.generator_fluid")
public class EnergyFluidZen implements IRecipeManager {

private final Logger logger = LogManager.getLogger();

@Override
public IRecipeType<?> getRecipeType() {
return CyclicRecipeType.GENERATOR_FLUID;
}

@SuppressWarnings("rawtypes")
@ZenCodeType.Method
public void addRecipe(String name, IFluidStack fluid, int rfPertick, int ticks) {
name = fixRecipeName(name);
RecipeGeneratorFluid m = new RecipeGeneratorFluid(new ResourceLocation(CompatConstants.CRAFTTWEAKER, name),
new FluidTagIngredient(new FluidStack(fluid.getFluid(), 1), "", fluid.getAmount()),
ticks, rfPertick);
CraftTweakerAPI.apply(new ActionAddRecipe(this, m, ""));
logger.debug("Recipe loaded " + m.getId().toString());
}

@SuppressWarnings("rawtypes")
@ZenCodeType.Method
public void addRecipe(String name, String fluidTag, int amount, int rfPertick, int ticks) {
name = fixRecipeName(name);
RecipeGeneratorFluid m = new RecipeGeneratorFluid(new ResourceLocation(CompatConstants.CRAFTTWEAKER, name),
new FluidTagIngredient(null, fluidTag, amount),
ticks, rfPertick);
CraftTweakerAPI.apply(new ActionAddRecipe(this, m, ""));
logger.debug("Recipe (tag %s) loaded " + m.getId().toString(), fluidTag);
}

@ZenCodeType.Method
public void removeRecipe(String names) {
removeByName(names);
logger.debug("Recipe removed " + names);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.lothrazar.cyclic.compat.crafttweaker;

import com.blamejared.crafttweaker.api.CraftTweakerAPI;
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import com.blamejared.crafttweaker.api.item.IIngredient;
import com.blamejared.crafttweaker.api.managers.IRecipeManager;
import com.blamejared.crafttweaker.impl.actions.recipes.ActionAddRecipe;
import com.lothrazar.cyclic.block.generatoritem.RecipeGeneratorItem;
import com.lothrazar.cyclic.compat.CompatConstants;
import com.lothrazar.cyclic.recipe.CyclicRecipeType;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.util.ResourceLocation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openzen.zencode.java.ZenCodeType;

@ZenRegister
@ZenCodeType.Name("mods.cyclic.generator_item")
public class EnergyItemZen implements IRecipeManager {

private final Logger logger = LogManager.getLogger();

@Override
public IRecipeType<?> getRecipeType() {
return CyclicRecipeType.GENERATOR_ITEM;
}

@SuppressWarnings("rawtypes")
@ZenCodeType.Method
public void addRecipe(String name, IIngredient input, int rfPertick, int ticks) {
name = fixRecipeName(name);
RecipeGeneratorItem m = new RecipeGeneratorItem(new ResourceLocation(CompatConstants.CRAFTTWEAKER, name), input.asVanillaIngredient(), ticks, rfPertick);
CraftTweakerAPI.apply(new ActionAddRecipe(this, m, ""));
logger.debug("Recipe loaded " + m.getId().toString());
}

@ZenCodeType.Method
public void removeRecipe(String names) {
removeByName(names);
logger.debug("Recipe removed " + names);
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/lothrazar/cyclic/config/ConfigRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ private static void initConfig() {
.defineInRange("generator_food.rf_per_tick", 60, 1, 6400);
TileGeneratorFood.TICKS_PER_FOOD = CFG.comment("This [factor * (item.food + item.saturation) = ticks] results in the number of ticks food will burn at. IE Bread has (5 + 0.6) with factor 100, will burn for 560 ticks.")
.defineInRange("generator_food.ticks_per_food", 100, 1, 6400);
CFG.comment(WALL, "Energy cost for various machines, either per use of an action or per tick (twenty ticks per second).", WALL)
CFG.comment(WALL, "Energy cost for various machines, either per use of an action or per tick (twenty ticks per second). Setting as zero (0) lets machine run for free", WALL)
.push("cost");
TilePackager.POWERCONF = CFG.comment("Power per recipe in the packager").defineInRange("packager", 50, 0, 64000);
TileDisenchant.POWERCONF = CFG.comment("Power per use disenchanter").defineInRange("disenchanter", 2500, 0, 64000);
TileUser.POWERCONF = CFG.comment("Power per use user").defineInRange("user", 50, 0, 64000);
TileUser.POWERCONF = CFG.comment("Power per use user").defineInRange("user", 0, 0, 64000);
TileAnvilAuto.POWERCONF = CFG.comment("Power per repair anvil").defineInRange("anvil", 250, 0, 64000);
TileMelter.POWERCONF = CFG.comment("Power per recipe melter").defineInRange("melter", 5000, 0, 64000);
TileSolidifier.POWERCONF = CFG.comment("Power per recipe solidifier").defineInRange("solidifier", 5000, 0, 64000);
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/lothrazar/cyclic/event/EventRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public static void drawStack(ItemStack stack) {
// }

///////////////////// asdfasdf TODO REFACTOR THIS
@SuppressWarnings("deprecation")
@SubscribeEvent
public void renderOverlay(RenderWorldLastEvent event) {
PlayerEntity player = Minecraft.getInstance().player;
Expand Down Expand Up @@ -159,7 +160,13 @@ public void renderOverlay(RenderWorldLastEvent event) {
}
List<BlockPos> coords = RandomizerItem.getPlaces(lookingAt.getPos(), lookingAt.getFace());
for (BlockPos e : coords) {
renderCubes.put(e, RandomizerItem.canMove(player.world.getBlockState(e), player.world, e) ? ClientConfigCyclic.getColor(stack) : Color.RED);
BlockState stHere = player.world.getBlockState(e);
if (!RandomizerItem.canMove(stHere, world, e) && !stHere.isAir()) {
renderCubes.put(e, ClientConfigCyclic.getColor(stack));
}
else if (!stHere.isAir()) {
UtilRender.createBox(event.getMatrixStack(), e); // see: RenderBlockUtils and event.getPoseStack()
}
}
}
stack = OreProspector.getIfHeld(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ private void tickFlying(PlayerEntity player, CyclicFile datFile) {
}
if (datFile.flyTicks > DISABLE_OFFSET) {
player.abilities.allowFlying = true;
ModCyclic.LOGGER.info("allowFlying");
}
else if (datFile.flyTicks <= DISABLE_OFFSET) {
player.abilities.allowFlying = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EdibleFlightItem extends ItemBase {
public static IntValue TICKS;

public EdibleFlightItem(Properties properties) {
super(properties.rarity(Rarity.RARE).food(new Food.Builder().hunger(3).saturation(0).setAlwaysEdible().build()));
super(properties.rarity(Rarity.RARE).food(new Food.Builder().hunger(1).saturation(0).setAlwaysEdible().build()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EdibleSpecItem extends ItemBase {
public static IntValue TICKS;

public EdibleSpecItem(Properties properties) {
super(properties.rarity(Rarity.EPIC).food(new Food.Builder().hunger(3).saturation(0).setAlwaysEdible().build()));
super(properties.rarity(Rarity.EPIC).food(new Food.Builder().hunger(1).saturation(0).setAlwaysEdible().build()));
}

@Override
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/lothrazar/cyclic/item/apple/AppleBuffs.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.List;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.text.ITextComponent;
Expand Down Expand Up @@ -40,10 +39,6 @@ public void addInformation(ItemStack stack, World worldIn, List<ITextComponent>

@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
if (entityLiving instanceof PlayerEntity) {
// TOOD
((PlayerEntity) entityLiving).getCooldownTracker().setCooldown(this, 30);
}
return super.onItemUseFinish(stack, worldIn, entityLiving);
}
}
Loading

0 comments on commit 3510b65

Please sign in to comment.