Skip to content

Commit

Permalink
Merge pull request #38 from Hephaestus-Dev/1.1.1
Browse files Browse the repository at this point in the history
1.1.1
  • Loading branch information
Haven-King authored Nov 16, 2020
2 parents b4ef626 + 93d1b82 commit 5cb7d21
Show file tree
Hide file tree
Showing 19 changed files with 159 additions and 33 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ A collection of small tweaks for Minecraft.
## Plant Tweaks
* Easy Harvest Crops - Right clicking fully grown clops harvests and replants them
* Easy Harvest Sugarcane - Right clicking sugarcane harvests all sugarcane higher than the one you clicked. Preserves the bottom-most block
* Easy Harvest Item Drops - Causes Easy Harvest to drop items on the ground instead of inserting them directly into your inventory
* Auto Planting - Plants that fall on dirt or grass will automatically plant. Applies to saplings, wheat seeds, pumpkin seeds, melon seeds, beetroot seeds, carrots, and potatoes
* Grass Spreading - Grass and long grass spread naturally over time
* Rejuvenation - Grass and long grass spread naturally over time
* Plant Hitboxes - Removes hitboxes from long grass. Hitboxes are shown when using shears. Seeds can be gathered by using a hoe on the ground below them
* Passable Leaves - Removes collision from leaves
* Instant Leaf Decay - Leaves decay instantly when outside range of a log block
* Better Lily Pads - Allows boats to pass through lily pads without breaking them. Also allows entities to rise through the bottom of a lily pad
* Farmer Villager Automation - Farmer villagers will deposit excess items into a nearby chest

## Animal Tweaks
* Animals Eat off the Ground - Chickens, cows, horses, pigs, sheep, and wolves will eat off the ground
* Wild Wolves Breed - Wild wolves are able to be bred. Allows for some neat natural systems!

## Nether Tweaks
* Nether Rejuvenation - Allows nylium and roots to spread in the Nether like grass does in the Overworld
* Blue Soul Fire Effects - Entities ignited by soul fire will have blue fire effects instead of normal fire
* Soul Fire Does More Damage - Entities ignited by soul fire take twice as much damage as those ignited by regular fire

## Miscellaneous Tweaks
* Bubble Columns Flow - When set to On, bubble columns behave as they do in vanilla. When set to Off, bubble columns don't spread water to their surrounding blocks
* Burned Logs Drop Charcoal - When a log on fire burns, it drops a charcoal (Also makes charcoal fireproof)
Expand All @@ -25,6 +32,7 @@ A collection of small tweaks for Minecraft.
* Infinite Cauldrons - Right clicking a Cauldron with a Heart of the Sea creates an infinite water source
* Easy XP - All vanilla XP sources give their XP directly to the player that earns them (other than the Ender Dragon)
* Tinted Tipped Arrows - The heads of tipped arrows render the color of their status effect
* Mossy Things - Cobblestone and stone brick blocks, slabs, stairs, and walls will turn mossy when in rain or surrounded by water, and will dry out again when in sunlight

## Contact Me
I can be found hanging out on the Fabric Discord as Haven King#2790. Feel free to shoot me a message there if you have any questions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
org.gradle.jvmargs = -Xmx1G

#Fabric properties
minecraft_version = 1.16.3
yarn_mappings = 1.16.3+build.11
loader_version = 0.10.0+local
minecraft_version = 1.16.4
yarn_mappings = 1.16.4+build.7
loader_version = 0.10.8

#Mod properties
mod_version = 1.0.16
mod_version = 1.1.1
maven_group = dev.hephaestus
archives_base_name = tinytweaks

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/dev/hephaestus/tweaks/Tweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.tag.TagRegistry;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.Item;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.tag.BlockTags;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -26,6 +30,8 @@ public class Tweaks implements ModInitializer, ClientModInitializer {

public static TweaksConfig CONFIG = new TweaksConfig();

public static Tag<Item> SHOWS_GRASS_HITBOXES = TagRegistry.item(new Identifier(MOD_ID, "shows_grass_hitboxes"));

@Override
public void onInitialize() {
AutoConfig.register(TweaksConfig.class, GsonConfigSerializer::new);
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/dev/hephaestus/tweaks/TweaksConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public class TweaksConfig implements ConfigData {
@ConfigEntry.Gui.Tooltip(count = 2)
public boolean easyHarvestSugarcane = true;

@ConfigEntry.Category("plants")
@ConfigEntry.Gui.Tooltip(count = 2)
public boolean easyHarvestDropAsItems = false;

@ConfigEntry.Category("plants")
@ConfigEntry.Gui.CollapsibleObject
public AutoPlanting autoPlanting = new AutoPlanting();
Expand All @@ -32,6 +36,11 @@ public class TweaksConfig implements ConfigData {
@ConfigEntry.Gui.CollapsibleObject
public LeavesConfig leaves = new LeavesConfig();

@ConfigEntry.Category("plants")
@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 1, max = 100)
public int leafDecaySpeed = 1;

@ConfigEntry.Category("plants")
@ConfigEntry.Gui.Tooltip(count = 2)
public boolean betterLilyPads = true;
Expand Down Expand Up @@ -87,6 +96,7 @@ public class TweaksConfig implements ConfigData {
public boolean doubleDoors = true;

@ConfigEntry.Category("misc")
@ConfigEntry.Gui.Tooltip(count = 3)
public boolean bubbleColumnsFlow = false;

@ConfigEntry.Category("misc")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ private void makeInfinite(BlockState state, World world, BlockPos pos, PlayerEnt
(double) pos.getY() + 2.0D,
(double) pos.getZ() + 0.5D,
1,
(double) ((float) int_1 + random.nextFloat()) - 0.5D,
(float) int_3 - random.nextFloat() - 1.0F,
(double) ((float) int_2 + random.nextFloat()) - 0.5D,
0,0,0,
1);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.hephaestus.tweaks.mixin.block.easyharvest;

import dev.hephaestus.tweaks.Tweaks;
import dev.hephaestus.tweaks.TweaksConfig;
import net.minecraft.block.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Items;
Expand All @@ -27,14 +28,16 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
}

boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity)player).isDisconnected();
if (playerAvailable)
if (playerAvailable && !Tweaks.CONFIG.easyHarvestDropAsItems) {
player.inventory.offerOrDrop(world, stack);
else
} else {
Block.dropStack(world, pos, stack);
}
});

world.setBlockState(pos, state.with(CocoaBlock.AGE, 0));
}

return ActionResult.SUCCESS;
} else {
return ActionResult.PASS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
}

boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity)player).isDisconnected();
if (playerAvailable)
if (playerAvailable && !Tweaks.CONFIG.easyHarvestDropAsItems) {
player.inventory.offerOrDrop(world, stack);
else
} else {
Block.dropStack(world, pos, stack);
}
});

world.setBlockState(pos, this.withAge(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
}

boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity)player).isDisconnected();
if (playerAvailable)
if (playerAvailable && !Tweaks.CONFIG.easyHarvestDropAsItems) {
player.inventory.offerOrDrop(world, stack);
else
} else {
Block.dropStack(world, pos, stack);
}
});

world.setBlockState(pos, state.with(NetherWartBlock.AGE, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ private boolean tryBreakSugarcane(World world, BlockPos pos, PlayerEntity player

if (n > 0) {
boolean playerAvailable = player.isAlive() || player instanceof ServerPlayerEntity && !((ServerPlayerEntity) player).isDisconnected();
if (playerAvailable)
if (playerAvailable && !Tweaks.CONFIG.easyHarvestDropAsItems) {
player.inventory.offerOrDrop(world, new ItemStack(Items.SUGAR_CANE, n));
else
} else {
Block.dropStack(world, pos, new ItemStack(Items.SUGAR_CANE, n));
}
}

return n > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.block.BlockState;
import net.minecraft.fluid.Fluids;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -21,18 +22,22 @@ private void doTick(BlockState state, ServerWorld world, BlockPos pos, Random ra
if (Tweaks.CONFIG.mossyThings && Moistener.canMoisten(state.getBlock())) {
boolean isSkyVisible = false;
boolean isWaterNearby = false;
for (BlockPos adjacent : BlockPos.iterate(pos.up().north().west(), pos.down().south().east())) {
if (world.isSkyVisible(adjacent)) isSkyVisible = true;
if (world.getFluidState(adjacent).getFluid() == Fluids.WATER) isWaterNearby = true;

if (state.getBlock().getStateManager().getProperties().contains(Properties.WATERLOGGED)) {
isWaterNearby = state.get(Properties.WATERLOGGED);
}

if (isSkyVisible) {
if (world.isRaining() && world.getBiome(pos).getDownfall() > 0) {
world.setBlockState(pos, Moistener.moisten(state));
} else if (world.isDay() && !isWaterNearby) {
world.setBlockState(pos, Moistener.dry(state));
}
for (BlockPos adjacent : BlockPos.iterate(pos.up().north().west(), pos.down().south().east())) {
if (!isSkyVisible && world.isSkyVisible(adjacent)) isSkyVisible = true;
if (!isWaterNearby && world.getFluidState(adjacent).getFluid() == Fluids.WATER) isWaterNearby = true;
if (isSkyVisible && isWaterNearby) break;
}

if ((isSkyVisible && world.isRaining() && world.getBiome(pos).getDownfall() > 0)
|| (isWaterNearby)) {
world.setBlockState(pos, Moistener.moisten(state));
} else if (isSkyVisible && world.isDay()) {
world.setBlockState(pos, Moistener.dry(state));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.hephaestus.tweaks.mixin.block.planthitboxes;

import dev.hephaestus.tweaks.Tweaks;
import dev.hephaestus.tweaks.util.ItemEntityShapeContext;
import net.minecraft.block.*;
import net.minecraft.item.Items;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
Expand All @@ -21,9 +21,10 @@ protected FernBlocks(Settings settings) {

@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
if (!Tweaks.CONFIG.plantHitboxes && !context.isHolding(Items.SHEARS))
if (!Tweaks.CONFIG.plantHitboxes && !(context instanceof ItemEntityShapeContext && ((ItemEntityShapeContext) context).getItem().isIn(Tweaks.SHOWS_GRASS_HITBOXES))) {
return VoxelShapes.empty();
else
} else {
return SHAPE;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dev.hephaestus.tweaks.mixin.block.planthitboxes;

import dev.hephaestus.tweaks.Tweaks;
import dev.hephaestus.tweaks.util.ItemEntityShapeContext;
import net.minecraft.block.BlockState;
import net.minecraft.block.PlantBlock;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.TallPlantBlock;
import net.minecraft.item.Items;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
Expand All @@ -19,9 +19,10 @@ protected TallPlants(Settings settings) {
}

public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
if (!Tweaks.CONFIG.plantHitboxes && !context.isHolding(Items.SHEARS))
if (!Tweaks.CONFIG.plantHitboxes && !(context instanceof ItemEntityShapeContext && ((ItemEntityShapeContext) context).getItem().isIn(Tweaks.SHOWS_GRASS_HITBOXES))) {
return VoxelShapes.empty();
else
} else {
return super.getOutlineShape(state, view, pos, context);
}
}
}
18 changes: 18 additions & 0 deletions src/main/java/dev/hephaestus/tweaks/mixin/entity/GetHeldItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dev.hephaestus.tweaks.mixin.entity;

import dev.hephaestus.tweaks.util.ItemEntityShapeContext;
import net.minecraft.block.EntityShapeContext;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(EntityShapeContext.class)
public class GetHeldItem implements ItemEntityShapeContext {
@Shadow @Final private Item heldItem;

@Override
public Item getItem() {
return this.heldItem;
}
}
49 changes: 49 additions & 0 deletions src/main/java/dev/hephaestus/tweaks/mixin/world/TickMore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package dev.hephaestus.tweaks.mixin.world;

import dev.hephaestus.tweaks.Tweaks;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.FluidState;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.MutableWorldProperties;
import net.minecraft.world.World;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Mixin;
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.function.Supplier;

@Mixin(ServerWorld.class)
public abstract class TickMore extends World {
protected TickMore(MutableWorldProperties properties, RegistryKey<World> registryRef, DimensionType dimensionType, Supplier<Profiler> profiler, boolean isClient, boolean debugWorld, long seed) {
super(properties, registryRef, dimensionType, profiler, isClient, debugWorld, seed);
}

@Inject(method = "tickChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/ChunkSection;getYOffset()I", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
private void tickMore(WorldChunk chunk, int randomTickSpeed, CallbackInfo ci, ChunkPos chunkPos, boolean bl, int startX, int startZ, Profiler profiler, ChunkSection[] var8, int var9, int var10, ChunkSection chunkSection) {
int startY = chunkSection.getYOffset();

for (int i = 0; i < randomTickSpeed; ++i) {
for (int j = 0; j < Tweaks.CONFIG.leafDecaySpeed - 1; ++j) {
BlockPos blockPos4 = this.getRandomPosInChunk(startX, startY, startZ, 15);
profiler.push("randomTick");
BlockState blockState = chunkSection.getBlockState(blockPos4.getX() - startX, blockPos4.getY() - startY, blockPos4.getZ() - startZ);

if (blockState.hasRandomTicks() && blockState.isIn(BlockTags.LEAVES)) {
blockState.randomTick((ServerWorld) (Object) this, blockPos4, this.random);
}

profiler.pop();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.hephaestus.tweaks.mixin.world;

import dev.hephaestus.tweaks.Tweaks;
import dev.hephaestus.tweaks.util.CauldronChunk;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -19,7 +18,6 @@ public abstract class UpgradeChunk implements CauldronChunk {
private void copyCauldrons(World world, ProtoChunk protoChunk, CallbackInfo ci) {
for (Map.Entry<BlockPos, Boolean> entry : ((CauldronChunk) protoChunk).getCauldrons()) {
this.setInfinite(entry.getKey(), entry.getValue());
Tweaks.log("FUCKING HELL");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dev.hephaestus.tweaks.util;

import net.minecraft.item.Item;

public interface ItemEntityShapeContext {
Item getItem();
}
Loading

0 comments on commit 5cb7d21

Please sign in to comment.