Compare commits

...

8 Commits

Author SHA1 Message Date
TheBrokenRail 3a323ad3f9 Update Version
SlightlyVanilla/pipeline/head This commit looks good Details
2020-12-15 11:22:05 -05:00
TheBrokenRail dd4694ec40 1.0.12 2020-12-15 11:21:36 -05:00
TheBrokenRail e04dc6ffe2 Fix Build
SlightlyVanilla/pipeline/head This commit looks good Details
2020-10-20 12:02:07 -04:00
TheBrokenRail a1b67ed622 1.0.11
SlightlyVanilla/pipeline/head There was a failure building this commit Details
2020-10-20 11:51:45 -04:00
TheBrokenRail e7f639092b Update Gradle Version
SlightlyVanilla/pipeline/head This commit looks good Details
2020-09-13 00:07:13 -04:00
TheBrokenRail dc61f79b95 1.0.10
SlightlyVanilla/pipeline/head This commit looks good Details
2020-09-12 23:13:21 -04:00
TheBrokenRail f3ea21bea5 Use FabricEntityTypeBuilder
SlightlyVanilla/pipeline/head This commit looks good Details
2020-09-12 22:48:51 -04:00
TheBrokenRail b6614da325 Add Note Block Screen Tweak
SlightlyVanilla/pipeline/head This commit looks good Details
2020-09-12 22:46:06 -04:00
16 changed files with 310 additions and 33 deletions

View File

@ -1,5 +1,15 @@
# Changelog
**1.0.12**
* Allow Disabling Beds Setting Spawn
**1.0.11**
* Fix Loading On Client Without ModMenu
* Fix Loading On Server
**1.0.10**
* Add Note Block Screen Tweak
**1.0.9**
* Disable Instant Nether Portal In Creative

View File

@ -13,6 +13,7 @@ Suggest more tweaks in the issue tracker!
* Crying Obsidian Nether Portal
* Allow Leashing Villagers
* Disable Instant Nether Portal In Creative
* Add Note Block Screen
## Changelog
[View Changelog](CHANGELOG.md)

View File

@ -3,20 +3,20 @@ org.gradle.jvmargs = -Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version = 1.16.2
minecraft_version = 1.16.4
curseforge_id = 368420
simple_minecraft_version = 1.16.2
yarn_build = 21
fabric_loader_version = 0.9.2+build.206
simple_minecraft_version = 1.16.4
yarn_build = 7
fabric_loader_version = 0.10.8
# Mod Properties
mod_version = 1.0.9
mod_version = 1.0.12
maven_group = com.thebrokenrail
archives_base_name = slightlyvanilla
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_api_version = 0.19.0+build.398-1.16
fabric_api_version = 0.28.1+1.16
modmenu_version = 1.14.6+build.31
cloth_config_version = 4.7.0-unstable
autoconfig_version = 3.2.0-unstable

View File

@ -3,6 +3,9 @@ package com.thebrokenrail.slightlyvanilla;
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
@Config(name = SlightlyVanilla.NAMESPACE)
public class ModConfig implements ConfigData {
@ -16,6 +19,9 @@ public class ModConfig implements ConfigData {
public boolean cryingObsidianNetherPortal = true;
public boolean allowLeashingVillagers = true;
public boolean disableInstantNetherPortalInCreative = true;
@Environment(EnvType.CLIENT)
public boolean noteBlockScreen = true;
public boolean bedsSetSpawn = true;
public static class ThrowableOption {
public boolean player;

View File

@ -7,9 +7,11 @@ import com.thebrokenrail.slightlyvanilla.entity.SpawnEggEntity;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.fabricmc.fabric.api.tag.TagRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.DispenserBlock;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.player.PlayerEntity;
@ -39,14 +41,11 @@ public class SlightlyVanilla implements ModInitializer {
public void onInitialize() {
AutoConfig.register(ModConfig.class, GsonConfigSerializer::new);
Identifier slimeballID = new Identifier(NAMESPACE, "slimeball");
Identifier spawnEggID = new Identifier(NAMESPACE, "spawn_egg");
SLIMEBALL_ENTITY = FabricEntityTypeBuilder.create(SpawnGroup.MISC, (EntityType.EntityFactory<SlimeballEntity>) SlimeballEntity::new).dimensions(new EntityDimensions(0.25f, 0.25f, true)).build();
SPAWN_EGG_ENTITY = FabricEntityTypeBuilder.create(SpawnGroup.MISC, (EntityType.EntityFactory<SpawnEggEntity>) SpawnEggEntity::new).dimensions(new EntityDimensions(0.25f, 0.25f, true)).build();
SLIMEBALL_ENTITY = EntityType.Builder.create((EntityType.EntityFactory<SlimeballEntity>) SlimeballEntity::new, SpawnGroup.MISC).setDimensions(0.25f, 0.25f).build(slimeballID.toString());
SPAWN_EGG_ENTITY = EntityType.Builder.create((EntityType.EntityFactory<SpawnEggEntity>) SpawnEggEntity::new, SpawnGroup.MISC).setDimensions(0.25f, 0.25f).build(spawnEggID.toString());
Registry.register(Registry.ENTITY_TYPE, slimeballID, SLIMEBALL_ENTITY);
Registry.register(Registry.ENTITY_TYPE, spawnEggID, SPAWN_EGG_ENTITY);
Registry.register(Registry.ENTITY_TYPE, new Identifier(NAMESPACE, "slimeball"), SLIMEBALL_ENTITY);
Registry.register(Registry.ENTITY_TYPE, new Identifier(NAMESPACE, "spawn_egg"), SPAWN_EGG_ENTITY);
DispenserBlock.registerBehavior(Items.SLIME_BALL, new SlimeballDispenserBehavior());

View File

@ -0,0 +1,18 @@
package com.thebrokenrail.slightlyvanilla.client;
import com.thebrokenrail.slightlyvanilla.ModConfig;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.Screen;
@SuppressWarnings("unused")
@Environment(EnvType.CLIENT)
public class ModMenu implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return (ConfigScreenFactory<Screen>) screen -> AutoConfig.getConfigScreen(ModConfig.class, screen).get();
}
}

View File

@ -1,30 +1,20 @@
package com.thebrokenrail.slightlyvanilla.client;
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
import com.thebrokenrail.slightlyvanilla.ModConfig;
import com.thebrokenrail.slightlyvanilla.entity.SlimeballEntity;
import com.thebrokenrail.slightlyvanilla.entity.SpawnEggEntity;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.entity.FlyingItemEntityRenderer;
@SuppressWarnings("unused")
@Environment(EnvType.CLIENT)
public class SlightlyVanillaClient implements ClientModInitializer, ModMenuApi {
public class SlightlyVanillaClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
EntityRendererRegistry.INSTANCE.register(SlightlyVanilla.SLIMEBALL_ENTITY, (entityRenderDispatcher, context) -> new FlyingItemEntityRenderer<SlimeballEntity>(entityRenderDispatcher, context.getItemRenderer()));
EntityRendererRegistry.INSTANCE.register(SlightlyVanilla.SPAWN_EGG_ENTITY, (entityRenderDispatcher, context) -> new FlyingItemEntityRenderer<SpawnEggEntity>(entityRenderDispatcher, context.getItemRenderer()));
}
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return (ConfigScreenFactory<Screen>) screen -> AutoConfig.getConfigScreen(ModConfig.class, screen).get();
}
}

View File

@ -0,0 +1,144 @@
package com.thebrokenrail.slightlyvanilla.client.screen;
import com.mojang.blaze3d.systems.RenderSystem;
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
import com.thebrokenrail.slightlyvanilla.mixin.ScreenHandlerAccessor;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket;
import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.state.property.Properties;
import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import java.util.function.BiFunction;
@Environment(EnvType.CLIENT)
public class NoteBlockScreen extends Screen {
private static class NoteSliderWidget extends SliderWidget {
private final ScreenHandlerContext context;
public NoteSliderWidget(ScreenHandlerContext context, int x, int y, int width, int height) {
super(x, y, width, height, LiteralText.EMPTY, (double) getNote(context) / getMax());
this.context = context;
updateMessage();
}
private static double getMax() {
return (double) Properties.NOTE.getValues().size() - 1;
}
@SuppressWarnings("OptionalGetWithoutIsPresent")
private static int getNote(ScreenHandlerContext context) {
return context.run((BiFunction<World, BlockPos, Integer>) (world, pos) -> world.getBlockState(pos).get(Properties.NOTE)).get();
}
private int toNote() {
return (int) (value * getMax());
}
@Override
protected void updateMessage() {
int note = toNote();
setMessage(new TranslatableText("text." + SlightlyVanilla.NAMESPACE + ".noteblock_screen_slider", note, new TranslatableText("text." + SlightlyVanilla.NAMESPACE + ".noteblock_note." + note)));
}
@Override
protected void applyValue() {
context.run((world, blockPos) -> {
BlockState target = world.getBlockState(blockPos);
int currentNote = target.get(Properties.NOTE);
int targetNote = toNote();
int amount;
if (targetNote >= currentNote) {
amount = targetNote - currentNote;
} else {
amount = ((int) getMax()) - currentNote + 1 + targetNote;
}
MinecraftClient client = MinecraftClient.getInstance();
assert client != null;
assert client.getNetworkHandler() != null;
BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(blockPos), Direction.UP, blockPos, false);
for (int i = 0; i < amount; i++) {
client.getNetworkHandler().sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, hitResult));
}
world.setBlockState(blockPos, target.with(Properties.NOTE, targetNote));
});
}
}
private static final Identifier TEXTURE = new Identifier(SlightlyVanilla.NAMESPACE, "textures/gui/noteblock.png");
private final ScreenHandlerContext context;
public NoteBlockScreen(ScreenHandlerContext context) {
super(Blocks.NOTE_BLOCK.getName());
passEvents = true;
this.context = context;
}
@Override
protected void init() {
super.init();
int sliderWidth = BACKGROUND_WIDTH - 36;
int sliderHeight = 20;
addButton(new NoteSliderWidget(context, width / 2 - sliderWidth / 2, (height / 2) - (sliderHeight / 2) + 4, sliderWidth, sliderHeight));
}
private static final int BACKGROUND_WIDTH = 176;
private static final int BACKGROUND_HEIGHT = 60;
private static final int TITLE_X_OFFSET = 8;
private static final int TITLE_Y_OFFSEt = 6;
@Override
public void renderBackground(MatrixStack matrices) {
super.renderBackground(matrices);
//noinspection deprecation
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
assert client != null;
client.getTextureManager().bindTexture(TEXTURE);
int centerX = width / 2;
int centerY = height / 2;
drawTexture(matrices, centerX - (BACKGROUND_WIDTH / 2), centerY - (BACKGROUND_HEIGHT / 2), 0, 0, BACKGROUND_WIDTH, BACKGROUND_HEIGHT);
int titleX = centerX - (BACKGROUND_WIDTH / 2) + TITLE_X_OFFSET;
int titleY = centerY - (BACKGROUND_HEIGHT / 2) + TITLE_Y_OFFSEt;
textRenderer.draw(matrices, title, titleX, titleY, 4210752);
}
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
}
@Override
public void tick() {
super.tick();
assert client != null;
if (!ScreenHandlerAccessor.callCanUse(context, client.player, Blocks.NOTE_BLOCK)) {
assert client.player != null;
client.player.closeScreen();
}
}
}

View File

@ -2,7 +2,7 @@ package com.thebrokenrail.slightlyvanilla.mixin;
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.AbstractTraderEntity;
import net.minecraft.entity.passive.MerchantEntity;
import net.minecraft.entity.passive.PassiveEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@SuppressWarnings("unused")
@Mixin(AbstractTraderEntity.class)
@Mixin(MerchantEntity.class)
public abstract class MixinAbstractTraderEntity extends PassiveEntity {
protected MixinAbstractTraderEntity(EntityType<? extends PassiveEntity> entityType, World world) {
super(entityType, world);

View File

@ -0,0 +1,39 @@
package com.thebrokenrail.slightlyvanilla.mixin;
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
import com.thebrokenrail.slightlyvanilla.client.screen.NoteBlockScreen;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import org.spongepowered.asm.mixin.Final;
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;
@Environment(EnvType.CLIENT)
@Mixin(ClientPlayerInteractionManager.class)
public class MixinClientPlayerInteractionManager {
@Shadow
@Final
private MinecraftClient client;
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getStackInHand(Lnet/minecraft/util/Hand;)Lnet/minecraft/item/ItemStack;", ordinal = 0), method = "interactBlock", cancellable = true)
public void interactBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> info) {
if (!player.isSpectator() && SlightlyVanilla.getConfig().noteBlockScreen && world.getBlockState(hitResult.getBlockPos()).getBlock() == Blocks.NOTE_BLOCK) {
NoteBlockScreen screen = new NoteBlockScreen(ScreenHandlerContext.create(world, hitResult.getBlockPos()));
client.openScreen(screen);
info.setReturnValue(ActionResult.SUCCESS);
}
}
}

View File

@ -0,0 +1,20 @@
package com.thebrokenrail.slightlyvanilla.mixin;
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ServerPlayerEntity.class)
public class MixinServerPlayerEntity {
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;setSpawnPoint(Lnet/minecraft/util/registry/RegistryKey;Lnet/minecraft/util/math/BlockPos;FZZ)V"), method = "trySleep")
public void setSpawnPoint(ServerPlayerEntity obj, RegistryKey<World> dimension, BlockPos pos, float angle, boolean spawnPointSet, boolean bl) {
if (SlightlyVanilla.getConfig().bedsSetSpawn) {
obj.setSpawnPoint(dimension, pos, angle, spawnPointSet, bl);
}
}
}

View File

@ -0,0 +1,19 @@
package com.thebrokenrail.slightlyvanilla.mixin;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerContext;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Environment(EnvType.CLIENT)
@Mixin(ScreenHandler.class)
public interface ScreenHandlerAccessor {
@Invoker
static boolean callCanUse(ScreenHandlerContext context, PlayerEntity player, Block block) {
throw new UnsupportedOperationException();
}
}

View File

@ -12,6 +12,34 @@
"text.autoconfig.slightlyvanilla.option.cryingObsidianNetherPortal": "Crying Obsidian Nether Portal",
"text.autoconfig.slightlyvanilla.option.allowLeashingVillagers": "Allow Leashing Villagers",
"text.autoconfig.slightlyvanilla.option.disableInstantNetherPortalInCreative": "Disable Instant Nether Portal In Creative",
"text.autoconfig.slightlyvanilla.option.noteBlockScreen": "Add Note Block Screen",
"text.autoconfig.slightlyvanilla.option.bedsSetSpawn": "Beds Set Spawn",
"entity.slightlyvanilla.slimeball": "Slimeball",
"entity.slightlyvanilla.spawn_egg": "Spawn Egg"
"entity.slightlyvanilla.spawn_egg": "Spawn Egg",
"text.slightlyvanilla.noteblock_screen_slider": "Note: %s (%s)",
"text.slightlyvanilla.noteblock_note.0": "F#",
"text.slightlyvanilla.noteblock_note.1": "G",
"text.slightlyvanilla.noteblock_note.2": "G#",
"text.slightlyvanilla.noteblock_note.3": "A",
"text.slightlyvanilla.noteblock_note.4": "A#",
"text.slightlyvanilla.noteblock_note.5": "B",
"text.slightlyvanilla.noteblock_note.6": "C",
"text.slightlyvanilla.noteblock_note.7": "C#",
"text.slightlyvanilla.noteblock_note.8": "D",
"text.slightlyvanilla.noteblock_note.9": "D#",
"text.slightlyvanilla.noteblock_note.10": "E",
"text.slightlyvanilla.noteblock_note.11": "F",
"text.slightlyvanilla.noteblock_note.12": "F#",
"text.slightlyvanilla.noteblock_note.13": "G",
"text.slightlyvanilla.noteblock_note.14": "G#",
"text.slightlyvanilla.noteblock_note.15": "A",
"text.slightlyvanilla.noteblock_note.16": "A#",
"text.slightlyvanilla.noteblock_note.17": "B",
"text.slightlyvanilla.noteblock_note.18": "C",
"text.slightlyvanilla.noteblock_note.19": "C#",
"text.slightlyvanilla.noteblock_note.20": "D",
"text.slightlyvanilla.noteblock_note.21": "D#",
"text.slightlyvanilla.noteblock_note.22": "E",
"text.slightlyvanilla.noteblock_note.23": "F",
"text.slightlyvanilla.noteblock_note.24": "F#"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -23,7 +23,7 @@
"com.thebrokenrail.slightlyvanilla.client.SlightlyVanillaClient"
],
"modmenu": [
"com.thebrokenrail.slightlyvanilla.client.SlightlyVanillaClient"
"com.thebrokenrail.slightlyvanilla.client.ModMenu"
]
},
"mixins": [

View File

@ -3,16 +3,19 @@
"package": "com.thebrokenrail.slightlyvanilla.mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"MixinClientPlayNetworkHandler"
"MixinClientPlayerInteractionManager",
"MixinClientPlayNetworkHandler",
"ScreenHandlerAccessor"
],
"mixins": [
"MixinRespawnAnchorBlock",
"MixinPlayerEntity",
"MixinAbstractTraderEntity",
"MixinItem",
"MixinSpawnEggItem",
"MixinLootableContainerBlockEntity",
"MixinNetherPortalBlockAreaHelper",
"MixinAbstractTraderEntity"
"MixinPlayerEntity",
"MixinRespawnAnchorBlock",
"MixinServerPlayerEntity",
"MixinSpawnEggItem"
],
"injectors": {
"defaultRequire": 1