Initial commit
This commit is contained in:
27
src/main/java/net/arcmods/gamer/gamerorigins/Gamer.java
Normal file
27
src/main/java/net/arcmods/gamer/gamerorigins/Gamer.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package net.arcmods.gamer.gamerorigins;
|
||||
|
||||
import net.arcmods.gamer.gamerorigins.items.mync_eye;
|
||||
import net.arcmods.gamer.gamerorigins.items.umbrella;
|
||||
import net.arcmods.gamer.gamerorigins.registry.modEnchantments;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.minecraft.item.ItemGroups;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Gamer implements ModInitializer {
|
||||
public static final String MOD_ID = "gamerorigins";
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
umbrella.registerItems();
|
||||
mync_eye.register();
|
||||
modEnchantments.register();
|
||||
|
||||
ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register((content) -> content.add(umbrella.UMBRELLA));
|
||||
LOGGER.info("man this Origins is Gamer");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.arcmods.gamer.gamerorigins.client;
|
||||
|
||||
import io.github.apace100.apoli.ApoliClient;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GamerKeybinds implements ClientModInitializer {
|
||||
|
||||
public List<String> keys = List.of("ternary","quaternary","quinary","senary","septenary","octonary","nonary","denary");
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
for(String key : keys) {
|
||||
KeyBinding binding = new KeyBinding("key.origins."+key+"_active", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_UNKNOWN, "category.origins");
|
||||
ApoliClient.registerPowerKeybinding(binding.getTranslationKey(), binding);
|
||||
ApoliClient.registerPowerKeybinding(key, binding);
|
||||
KeyBindingHelper.registerKeyBinding(binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.arcmods.gamer.gamerorigins.client;
|
||||
|
||||
import net.arcmods.gamer.gamerorigins.items.umbrella;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
public class layerRenderer implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
umbrella.registerRenderLayers();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.arcmods.gamer.gamerorigins.enchantment;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentTarget;
|
||||
import net.minecraft.enchantment.ProtectionEnchantment;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
|
||||
public class SunProtectionEnchantment extends Enchantment {
|
||||
|
||||
public SunProtectionEnchantment(Rarity weight, EnchantmentTarget type, EquipmentSlot[] slotTypes) {
|
||||
super(weight, type, slotTypes);
|
||||
}
|
||||
|
||||
public int getMinPower(int level) {
|
||||
return 8 + level * 5;
|
||||
}
|
||||
|
||||
public int getMaxPower(int level) {
|
||||
return this.getMinPower(level) + 8;
|
||||
}
|
||||
|
||||
public boolean isTreasure() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAccept(Enchantment other) {
|
||||
if(other == this || ((other instanceof ProtectionEnchantment && !(((ProtectionEnchantment)other).protectionType == ProtectionEnchantment.Type.ALL)))) {
|
||||
return false;
|
||||
}
|
||||
return super.canAccept(other);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.arcmods.gamer.gamerorigins.items;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Rarity;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
|
||||
public class mync_eye {
|
||||
|
||||
public static final Item MYNC_EYE = new Item(new Item.Settings().maxCount(1).rarity(Rarity.EPIC));
|
||||
|
||||
public static void register() {
|
||||
Registry.register(Registries.ITEM, new Identifier("gamerorigins", "mync_eye"), MYNC_EYE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.arcmods.gamer.gamerorigins.items;
|
||||
|
||||
import net.arcmods.gamer.gamerorigins.Gamer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.minecraft.item.DyeableItem;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
|
||||
public class umbrella {
|
||||
public static final umbrellaDyeTest UMBRELLA = new umbrellaDyeTest(new FabricItemSettings().maxCount(1).maxDamage(1200));
|
||||
|
||||
|
||||
public static void registerItems() {
|
||||
Registry.register(Registries.ITEM, new Identifier(Gamer.MOD_ID, "umbrella"), UMBRELLA);
|
||||
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static void registerRenderLayers() {
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> (tintIndex > 0) ? -1 : ((DyeableItem) stack.getItem()).getColor(stack), UMBRELLA);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.arcmods.gamer.gamerorigins.items;
|
||||
|
||||
import net.minecraft.item.DyeableItem;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class umbrellaDyeTest extends Item implements DyeableItem {
|
||||
|
||||
public umbrellaDyeTest(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.arcmods.gamer.gamerorigins.mixin;
|
||||
|
||||
import net.arcmods.gamer.gamerorigins.items.umbrella;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.world.World;
|
||||
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(Entity.class)
|
||||
public abstract class EntityMixin {
|
||||
|
||||
|
||||
@Shadow World world;
|
||||
|
||||
@Shadow abstract BlockPos getBlockPos();
|
||||
|
||||
@Shadow abstract Box getBoundingBox();
|
||||
|
||||
@Shadow abstract Iterable<ItemStack> getHandItems();
|
||||
|
||||
@Inject(method = "isBeingRainedOn", at = @At("HEAD"), cancellable = true)
|
||||
private void isBeingRainedOn(CallbackInfoReturnable<Boolean> cir) {
|
||||
Iterable<ItemStack> hands = this.getHandItems();
|
||||
for (ItemStack stack : hands) {
|
||||
if (stack.getItem() == umbrella.UMBRELLA)
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.arcmods.gamer.gamerorigins.mixin;
|
||||
|
||||
import io.github.apace100.apoli.power.factory.condition.EntityConditions;
|
||||
import io.github.apace100.calio.data.SerializableData;
|
||||
import net.arcmods.gamer.gamerorigins.items.umbrella;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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(EntityConditions.class)
|
||||
public class PlayerConditionsMixin {
|
||||
|
||||
@Inject(method = { "lambda$register$10" }, at = { @At("HEAD") }, cancellable = true)
|
||||
private static void sunDamagePrevention(SerializableData.Instance data, Entity player, CallbackInfoReturnable<Boolean> cir) {
|
||||
for (ItemStack stack : player.getHandItems()) {
|
||||
if (stack.getItem().equals(umbrella.UMBRELLA) && stack.getDamage() < stack.getMaxDamage() - 1) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = { "lambda$register$11" }, at = { @At("HEAD") }, cancellable = true)
|
||||
private static void umbrellaRainedOn(SerializableData.Instance data, Entity player, CallbackInfoReturnable<Boolean> cir) {
|
||||
for (ItemStack stack : player.getHandItems()) {
|
||||
if (stack.getItem().equals(umbrella.UMBRELLA) && stack.getDamage() < stack.getMaxDamage() - 1) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package net.arcmods.gamer.gamerorigins.mixin;
|
||||
|
||||
import io.github.apace100.apoli.mixin.EntityAccessor;
|
||||
import net.arcmods.gamer.gamerorigins.items.umbrella;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
public abstract class PlayerEntityMixin extends Entity {
|
||||
@Shadow
|
||||
public abstract ItemStack getEquippedStack(EquipmentSlot slot);
|
||||
|
||||
@Shadow
|
||||
public abstract Iterable<ItemStack> getHandItems();
|
||||
|
||||
@Shadow
|
||||
public abstract PlayerInventory getInventory();
|
||||
|
||||
protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
private void tick(CallbackInfo ci) {
|
||||
boolean isBeingRainedOn = ((EntityAccessor) this).callIsBeingRainedOn();
|
||||
|
||||
if (isBeingRainedOn && this.age % 10 == 0) {
|
||||
for (ItemStack stack : this.getHandItems()) {
|
||||
if (stack.getItem().equals(umbrella.UMBRELLA) && stack.getDamage() < stack.getMaxDamage() - 1) {
|
||||
// Set damage instead of calling stack.damage, otherwise an animation is
|
||||
// triggered for each damage tick.
|
||||
stack.setDamage(stack.getDamage() + 1);
|
||||
}
|
||||
}
|
||||
} else if (!isBeingRainedOn && this.age % 20 == 0) {
|
||||
ItemStack offHand = this.getEquippedStack(EquipmentSlot.OFFHAND);
|
||||
boolean isHot = getWorld().getBiome(this.getBlockPos()).value().isCold(this.getBlockPos());
|
||||
|
||||
// Repair off-hand umbrella.
|
||||
this.repairStack(offHand, isHot, true);
|
||||
|
||||
// Repair any umbrellas in the player's inventory.
|
||||
for (int i = 0; i < 36; i++) {
|
||||
this.repairStack(this.getInventory().getStack(i), isHot, this.getInventory().selectedSlot == i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void repairStack(ItemStack stack, boolean isHot, boolean isExposed) {
|
||||
if (stack.getItem().equals(umbrella.UMBRELLA) && stack.isDamaged()) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
if (isHot) {
|
||||
// Umbrellas dry faster in hot climates.
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
if (isExposed) {
|
||||
// Umbrellas dry faster if they're exposed (not tucked away in inventory).
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.arcmods.gamer.gamerorigins.registry;
|
||||
|
||||
import net.arcmods.gamer.gamerorigins.Gamer;
|
||||
import net.arcmods.gamer.gamerorigins.enchantment.SunProtectionEnchantment;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentTarget;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.registry.Registry;
|
||||
|
||||
public class modEnchantments {
|
||||
|
||||
public static final Enchantment SUN_PROTECTION = new SunProtectionEnchantment(Enchantment.Rarity.RARE, EnchantmentTarget.ARMOR, new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET});
|
||||
|
||||
public static void register() {
|
||||
register("sun_protection", SUN_PROTECTION);
|
||||
}
|
||||
|
||||
private static Enchantment register(String path, Enchantment enchantment) {
|
||||
Registry.register(Registries.ENCHANTMENT, new Identifier(Gamer.MOD_ID, path), enchantment);
|
||||
return enchantment;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user