-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
169 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.rober.robercarpet; | ||
|
||
import carpet.CarpetExtension; | ||
import carpet.CarpetServer; | ||
import carpet.settings.SettingsManager; | ||
import net.fabricmc.api.ModInitializer; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public class RoberCarpet implements ModInitializer, CarpetExtension { | ||
// This logger is used to write text to the console and the log file. | ||
// It is considered best practice to use your mod id as the logger's name. | ||
// That way, it's clear which mod wrote info, warnings, and errors. | ||
public static final String MODID = "robercarpet"; | ||
public static final Logger LOGGER = LogManager.getLogger(MODID); | ||
|
||
private static final SettingsManager mySettingManager = new SettingsManager("1.0.0", MODID,"Rober-Carpet"); | ||
|
||
@Override | ||
public void onInitialize() { | ||
// This code runs as soon as Minecraft is in a mod-load-ready state. | ||
// However, some things (like resources) may still be uninitialized. | ||
// Proceed with mild caution. | ||
RoberCarpet extension = new RoberCarpet(); | ||
CarpetServer.manageExtension(extension); | ||
} | ||
@Override | ||
public void onGameStarted(){ | ||
CarpetServer.settingsManager.parseSettingsClass(RoberCarpetSettings.class); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
remappedSrc/net/rober/robercarpet/RoberCarpetSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.rober.robercarpet; | ||
|
||
import carpet.settings.Rule; | ||
|
||
public class RoberCarpetSettings { | ||
@Rule(desc="Lets dispensers convert dirt into clay with water bottles", category = {"dispenser", "rober"}) | ||
public static boolean FarmableClay = false; | ||
|
||
@Rule(desc="Sets the game-ticks of delay when you sleep in a bed (Vanilla is 100)",category = "rober") | ||
public static int SleepingDelay = 100; | ||
|
||
@Rule(desc="The amount of ticks before thunderstorm that are needed for the mod to warn you about it",category = "rober") | ||
public static int ThunderWarn = 0; | ||
} |
45 changes: 45 additions & 0 deletions
45
remappedSrc/net/rober/robercarpet/mixin/FarmableClayMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.rober.robercarpet.mixin; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.block.DispenserBlock; | ||
import net.minecraft.block.dispenser.ItemDispenserBehavior; | ||
import net.minecraft.block.entity.DispenserBlockEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.util.math.BlockPointer; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.rober.robercarpet.RoberCarpetSettings; | ||
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(ItemDispenserBehavior.class) | ||
public abstract class FarmableClayMixin { | ||
@Inject( method = "dispenseSilently", at = @At("HEAD"),cancellable = true) | ||
public void BehaviorMixin(BlockPointer pointer, ItemStack stack, CallbackInfoReturnable<ItemStack> cir) { | ||
if(RoberCarpetSettings.FarmableClay) { | ||
World world = pointer.getWorld(); | ||
if (world.isClient) { | ||
return; | ||
} | ||
if (pointer.getBlockState().getBlock() != Blocks.DISPENSER) { | ||
return; | ||
} | ||
BlockPos targetPos = pointer.getPos().offset(pointer.getBlockState().get(DispenserBlock.FACING)); | ||
BlockState block_state = world.getBlockState(targetPos); | ||
Block block = block_state.getBlock(); | ||
Item item = stack.getItem(); | ||
if (item == Items.POTION && block == Blocks.DIRT) { | ||
world.setBlockState(targetPos, Blocks.CLAY.getDefaultState()); | ||
cir.setReturnValue(new ItemStack(Items.GLASS_BOTTLE, 1)); | ||
return; | ||
} | ||
} | ||
return; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
remappedSrc/net/rober/robercarpet/mixin/SleepingDelayMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package net.rober.robercarpet.mixin; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.rober.robercarpet.RoberCarpetSettings; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
|
||
@Mixin(PlayerEntity.class) | ||
public abstract class SleepingDelayMixin { | ||
@ModifyConstant(method = "isSleepingLongEnough",constant = @Constant(intValue = 100)) | ||
public int SleepingDelayMixin(int a){ | ||
return RoberCarpetSettings.SleepingDelay; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
remappedSrc/net/rober/robercarpet/mixin/ThunderWarnMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package net.rober.robercarpet.mixin; | ||
|
||
import net.minecraft.network.MessageType; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.text.LiteralText; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.world.MutableWorldProperties; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.WorldProperties; | ||
import net.minecraft.world.level.ServerWorldProperties; | ||
import net.rober.robercarpet.RoberCarpetSettings; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.function.BooleanSupplier; | ||
|
||
@Mixin(ServerWorld.class) | ||
public abstract class ThunderWarnMixin { | ||
@Shadow protected ServerWorldProperties worldProperties; | ||
@Inject(method = "tick",at=@At("TAIL")) | ||
private void tickMixin(BooleanSupplier shouldKeepTicking,CallbackInfo ci){ | ||
if(RoberCarpetSettings.ThunderWarn!=-1) { | ||
ServerWorld server = (ServerWorld) (Object) this; | ||
if((willBeThunderstorm(RoberCarpetSettings.ThunderWarn,worldProperties))){ | ||
for (ServerPlayerEntity player : server.getPlayers()){ | ||
player.sendMessage(new LiteralText("A storm will begin in "+RoberCarpetSettings.ThunderWarn/60+" minutes"), MessageType.CHAT,player.getUuid()); | ||
} | ||
} | ||
} | ||
} | ||
boolean willBeThunderstorm(int delay,ServerWorldProperties worldProperties){ | ||
int thunderTime = worldProperties.getThunderTime(); | ||
int rainTime = worldProperties.getRainTime(); | ||
boolean thundering = worldProperties.isThundering(); | ||
boolean raining = worldProperties.isRaining(); | ||
if(thunderTime==delay){ | ||
return raining == rainTime > delay; | ||
}else if(rainTime==delay){ | ||
return thundering == thunderTime > delay; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters