Skip to content

Commit

Permalink
Merge pull request #12 from RubixDev/development
Browse files Browse the repository at this point in the history
v1.1.5
  • Loading branch information
RubixDev authored Mar 10, 2021
2 parents 8389b9f + 5f5c14e commit 01c1252
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 10 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ Extension Mod for [gnembon's fabric-carpet](https://github.com/gnembon/fabric-ca
- [`SURVIVAL`](markdown/SURVIVAL_Category.md)

## Index
Count: 69
Count: 71
- [anvilledBlueIce](#anvilledblueice)
- [anvilledIce](#anvilledice)
- [anvilledPackedIce](#anvilledpackedice)
- [basaltToBlackstoneConversion](#basalttoblackstoneconversion)
- [cactusFurnaceXp](#cactusfurnacexp)
- [campSleeping](#campsleeping)
- [commandFrame](#commandframe)
Expand Down Expand Up @@ -63,6 +64,7 @@ Count: 69
- [maxBannerLayers](#maxbannerlayers)
- [moreBarkCrafting](#morebarkcrafting)
- [moreFortressSpawningBlocks](#morefortressspawningblocks)
- [netherrackGeneration](#netherrackgeneration)
- [newShulkerBehavior](#newshulkerbehavior)
- [noCreeperGriefing](#nocreepergriefing)
- [noEndermanGriefing](#noendermangriefing)
Expand Down Expand Up @@ -124,6 +126,13 @@ Custom amount of ice crushed by falling anvils make one packed ice.
- You must choose a value from 0 to 32
- From [QuickCarpet](https://github.com/DeadlyMC/QuickCarpet114)

### basaltToBlackstoneConversion
Basalt converts to Blackstone if next to both Lava and Water
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
- Categories: `EXPERIMENTAL`, `FEATURE`, `SURVIVAL`

### cactusFurnaceXp
Amount of XP a Cactus smelted in a furnace gives
1 XP per Cactus seems to be a bug, as in Bedrock Edition it's only 0.2, which fits more in line with other items
Expand Down Expand Up @@ -442,6 +451,13 @@ off: nether bricks only / more: (red) nether bricks, netherrack, soul sand/soil,
- Additional notes:
- [Idea from DragonEggBedrockBreaking](https://github.com/gnembon/carpet-extra/issues/182)

### netherrackGeneration
Netherrack is generated instead of Cobblestone if a Magma Block is below
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
- Categories: `EXPERIMENTAL`, `FEATURE`, `SURVIVAL`

### newShulkerBehavior
Makes shulkers behave like in the current 1.17 snapshots
Shulkers hit by a shulker bullet have a chance to spawn a new shulker and teleport
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ org.gradle.jvmargs=-Xmx2G
carpet_core_version=1.4.23+v210115

# Mod Properties
mod_version = 1.1.4
mod_version = 1.1.5
maven_group = com.rubixdev.rug
archives_base_name = fabric-rug

Expand Down
18 changes: 17 additions & 1 deletion markdown/EXPERIMENTAL_Category.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

For a list of all implemented Rules go [here](../README.md)
## Index
Count: 30
Count: 32
- [anvilledBlueIce](#anvilledblueice)
- [anvilledIce](#anvilledice)
- [anvilledPackedIce](#anvilledpackedice)
- [basaltToBlackstoneConversion](#basalttoblackstoneconversion)
- [campSleeping](#campsleeping)
- [dragonEggConvertsCobbleToEndstone](#dragoneggconvertscobbletoendstone)
- [dragonXpDrop](#dragonxpdrop)
Expand All @@ -23,6 +24,7 @@ Count: 30
- [longerRepeaters](#longerrepeaters)
- [maxBannerLayers](#maxbannerlayers)
- [moreFortressSpawningBlocks](#morefortressspawningblocks)
- [netherrackGeneration](#netherrackgeneration)
- [newShulkerBehavior](#newshulkerbehavior)
- [peacefulHunger](#peacefulhunger)
- [reachDistance](#reachdistance)
Expand Down Expand Up @@ -66,6 +68,13 @@ Custom amount of ice crushed by falling anvils make one packed ice.
- You must choose a value from 0 to 32
- From [QuickCarpet](https://github.com/DeadlyMC/QuickCarpet114)

### basaltToBlackstoneConversion
Basalt converts to Blackstone if next to both Lava and Water
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
- Categories: `EXPERIMENTAL`, `FEATURE`, `SURVIVAL`

### campSleeping
Allows players to sleep in a Bed without setting their spawn point by entering while sneaking
- Type: `boolean`
Expand Down Expand Up @@ -215,6 +224,13 @@ off: nether bricks only / more: (red) nether bricks, netherrack, soul sand/soil,
- Additional notes:
- [Idea from DragonEggBedrockBreaking](https://github.com/gnembon/carpet-extra/issues/182)

### netherrackGeneration
Netherrack is generated instead of Cobblestone if a Magma Block is below
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
- Categories: `EXPERIMENTAL`, `FEATURE`, `SURVIVAL`

### newShulkerBehavior
Makes shulkers behave like in the current 1.17 snapshots
Shulkers hit by a shulker bullet have a chance to spawn a new shulker and teleport
Expand Down
18 changes: 17 additions & 1 deletion markdown/FEATURE_Category.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

For a list of all implemented Rules go [here](../README.md)
## Index
Count: 26
Count: 28
- [anvilledBlueIce](#anvilledblueice)
- [anvilledIce](#anvilledice)
- [anvilledPackedIce](#anvilledpackedice)
- [basaltToBlackstoneConversion](#basalttoblackstoneconversion)
- [campSleeping](#campsleeping)
- [concreteConvertOnCauldron](#concreteconvertoncauldron)
- [dragonDrops](#dragondrops)
Expand All @@ -21,6 +22,7 @@ Count: 26
- [lilyPadsOnCauldron](#lilypadsoncauldron)
- [longerRepeaters](#longerrepeaters)
- [moreFortressSpawningBlocks](#morefortressspawningblocks)
- [netherrackGeneration](#netherrackgeneration)
- [newShulkerBehavior](#newshulkerbehavior)
- [peacefulHunger](#peacefulhunger)
- [playerHeadDrops](#playerheaddrops)
Expand Down Expand Up @@ -62,6 +64,13 @@ Custom amount of ice crushed by falling anvils make one packed ice.
- You must choose a value from 0 to 32
- From [QuickCarpet](https://github.com/DeadlyMC/QuickCarpet114)

### basaltToBlackstoneConversion
Basalt converts to Blackstone if next to both Lava and Water
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
- Categories: `EXPERIMENTAL`, `FEATURE`, `SURVIVAL`

### campSleeping
Allows players to sleep in a Bed without setting their spawn point by entering while sneaking
- Type: `boolean`
Expand Down Expand Up @@ -185,6 +194,13 @@ off: nether bricks only / more: (red) nether bricks, netherrack, soul sand/soil,
- Additional notes:
- [Idea from DragonEggBedrockBreaking](https://github.com/gnembon/carpet-extra/issues/182)

### netherrackGeneration
Netherrack is generated instead of Cobblestone if a Magma Block is below
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
- Categories: `EXPERIMENTAL`, `FEATURE`, `SURVIVAL`

### newShulkerBehavior
Makes shulkers behave like in the current 1.17 snapshots
Shulkers hit by a shulker bullet have a chance to spawn a new shulker and teleport
Expand Down
18 changes: 17 additions & 1 deletion markdown/SURVIVAL_Category.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

For a list of all implemented Rules go [here](../README.md)
## Index
Count: 48
Count: 50
- [basaltToBlackstoneConversion](#basalttoblackstoneconversion)
- [cactusFurnaceXp](#cactusfurnacexp)
- [campSleeping](#campsleeping)
- [craftableCobwebs](#craftablecobwebs)
Expand Down Expand Up @@ -30,6 +31,7 @@ Count: 48
- [kelpBlockHardness](#kelpblockhardness)
- [maxBannerLayers](#maxbannerlayers)
- [moreBarkCrafting](#morebarkcrafting)
- [netherrackGeneration](#netherrackgeneration)
- [noCreeperGriefing](#nocreepergriefing)
- [noEndermanGriefing](#noendermangriefing)
- [noGhastGriefing](#noghastgriefing)
Expand All @@ -54,6 +56,13 @@ Count: 48

## Rules in SURVIVAL Category

### basaltToBlackstoneConversion
Basalt converts to Blackstone if next to both Lava and Water
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
- Categories: `EXPERIMENTAL`, `FEATURE`, `SURVIVAL`

### cactusFurnaceXp
Amount of XP a Cactus smelted in a furnace gives
1 XP per Cactus seems to be a bug, as in Bedrock Edition it's only 0.2, which fits more in line with other items
Expand Down Expand Up @@ -283,6 +292,13 @@ Expect a lag spike when changing the value
- Required options: `true`, `false`
- Categories: `CRAFTING`, `RUG`, `SURVIVAL`

### netherrackGeneration
Netherrack is generated instead of Cobblestone if a Magma Block is below
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
- Categories: `EXPERIMENTAL`, `FEATURE`, `SURVIVAL`

### noCreeperGriefing
Prevents Creepers from destroying blocks
- Type: `boolean`
Expand Down
4 changes: 3 additions & 1 deletion markdown/curseforge.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ Extension Mod for [gnembon's fabric-carpet](https://github.com/gnembon/fabric-ca
**Visit the [GitHub page](https://github.com/RubixDev/fabric-rug) for a more detailed explanation of all features.**

## List of implemented Carpet Rules
Count: 69
Count: 71
- anvilledBlueIce
- anvilledIce
- anvilledPackedIce
- basaltToBlackstoneConversion
- cactusFurnaceXp
- campSleeping
- commandFrame
Expand Down Expand Up @@ -47,6 +48,7 @@ Count: 69
- maxBannerLayers
- moreBarkCrafting
- moreFortressSpawningBlocks
- netherrackGeneration
- newShulkerBehavior
- noCreeperGriefing
- noEndermanGriefing
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/rubixdev/rug/RugSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,18 @@ public String description() {
category = {COMMAND, RUG}
)
public static String commandSkull = "ops";

@Rule(
desc = "Netherrack is generated instead of Cobblestone if a Magma Block is below",
category = {EXPERIMENTAL, FEATURE, SURVIVAL}
)
public static boolean netherrackGeneration = false;

@Rule(
desc = "Basalt converts to Blackstone if next to both Lava and Water",
category = {EXPERIMENTAL, FEATURE, SURVIVAL}
)
public static boolean basaltToBlackstoneConversion = false;
}

// BUGFIX
Expand Down
24 changes: 20 additions & 4 deletions src/main/java/com/rubixdev/rug/commands/SkullCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.rubixdev.rug.commands;

import carpet.settings.SettingsManager;
import com.google.common.collect.Sets;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
Expand All @@ -12,29 +13,44 @@
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;

import java.util.Arrays;
import java.util.Collection;
import java.util.Set;

import static net.minecraft.command.CommandSource.suggestMatching;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.server.command.CommandManager.argument;

public class SkullCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
LiteralArgumentBuilder<ServerCommandSource> command = literal("skull").
requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandSkull)).
executes(context -> execute(context, 0)).
then(argument("player", StringArgumentType.word()).
executes(context -> giveSkulls(context, 1)).
suggests(((context, builder) -> suggestMatching(getPlayers(context.getSource()), builder))).
executes(context -> execute(context, 1)).
then(argument("count", IntegerArgumentType.integer(1)).
executes(context -> giveSkulls(context, context.getArgument("count", Integer.class)))));
executes(context -> execute(context, context.getArgument("count", Integer.class)))));
dispatcher.register(command);
}

private static int giveSkulls(CommandContext<ServerCommandSource> context, int count) throws CommandSyntaxException {
private static int execute(CommandContext<ServerCommandSource> context, int count) throws CommandSyntaxException {
ServerCommandSource playerSource = context.getSource();
ServerCommandSource source = playerSource.getMinecraftServer().getCommandSource();
CommandManager manager = playerSource.getMinecraftServer().getCommandManager();

ServerPlayerEntity playerEntity = playerSource.getPlayer();
String playerName = playerEntity.getName().getString();
String skullOwner = context.getArgument("player", String.class);
String skullOwner = count == 0 ? playerName : context.getArgument("player", String.class);

if (count == 0) count = 1;

return manager.execute(source, "give " + playerName + " minecraft:player_head{SkullOwner:" + skullOwner + "} " + count);
}

private static Collection<String> getPlayers(ServerCommandSource source) {
Set<String> players = Sets.newLinkedHashSet(Arrays.asList("RubixDev", "Gnembon", "Steve", "Alex"));
players.addAll(source.getPlayerNames());
return players;
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/rubixdev/rug/mixins/AbstractBlockMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.rubixdev.rug.mixins;

import com.rubixdev.rug.util.Storage;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldAccess;
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.CallbackInfoReturnable;

@Mixin(AbstractBlock.class)
public class AbstractBlockMixin {
@Inject(method = "getStateForNeighborUpdate", at = @At("HEAD"), cancellable = true)
private void convertBasalt(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom, CallbackInfoReturnable<BlockState> cir) {
if (((Block) (Object) this).is(Blocks.BASALT) && Storage.shouldConvertBasalt(world, pos)) {
cir.setReturnValue(Blocks.BLACKSTONE.getDefaultState());
world.syncWorldEvent(1501, pos, 0);
}
}
}
41 changes: 41 additions & 0 deletions src/main/java/com/rubixdev/rug/mixins/FluidBlockMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.rubixdev.rug.mixins;

import com.rubixdev.rug.RugSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FluidBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
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.CallbackInfoReturnable;

@Mixin(FluidBlock.class)
public abstract class FluidBlockMixin {
@Shadow protected abstract void playExtinguishSound(WorldAccess world, BlockPos pos);

@Inject(
method = "receiveNeighborFluids",
at = @At(value = "INVOKE_ASSIGN",
target = "Lnet/minecraft/fluid/FluidState;isStill()Z"),
cancellable = true
)
private void generateNetherrack(
World world,
BlockPos pos,
BlockState state,
CallbackInfoReturnable<Boolean> cir
) {
if (RugSettings.netherrackGeneration
&& world.getBlockState(pos.down()).isOf(Blocks.MAGMA_BLOCK)
&& !world.getFluidState(pos).isStill()
) {
world.setBlockState(pos, Blocks.NETHERRACK.getDefaultState());
this.playExtinguishSound(world, pos);
cir.setReturnValue(false);
}
}
}
32 changes: 32 additions & 0 deletions src/main/java/com/rubixdev/rug/mixins/PillarBlockMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.rubixdev.rug.mixins;

import com.rubixdev.rug.util.Storage;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.PillarBlock;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
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.CallbackInfoReturnable;

@Mixin(PillarBlock.class)
public class PillarBlockMixin extends Block {
public PillarBlockMixin(Settings settings) {
super(settings);
}

@Inject(method = "getPlacementState", at = @At("HEAD"), cancellable = true)
private void convertBasalt(ItemPlacementContext ctx, CallbackInfoReturnable<BlockState> cir) {
WorldAccess world = ctx.getWorld();
BlockPos pos = ctx.getBlockPos();

if (this.is(Blocks.BASALT) && Storage.shouldConvertBasalt(world, pos)) {
cir.setReturnValue(Blocks.BLACKSTONE.getDefaultState());
world.syncWorldEvent(1501, pos, 0);
}
}
}
Loading

0 comments on commit 01c1252

Please sign in to comment.