Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/java
{
"name": "Java",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/java:1-17-bullseye",

"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "none",
"installMaven": "true",
"installGradle": "true"
}
}

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "java -version",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.14
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.22

# Mod Properties
mod_version = 1.2.4
mod_version = 1.2.5
maven_group = com.innky
archives_base_name = majobroom
#Fabric api
fabric_version=0.73.2+1.19.3
fabric_version=0.87.0+1.20.1
Empty file modified gradlew
100644 → 100755
Empty file.
16 changes: 10 additions & 6 deletions src/main/java/net/fabricmc/majobroom/MajoBroom.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.text.Text;
import net.minecraft.registry.Registry;


public class MajoBroom implements ModInitializer {
public static final String MODID = "majobroom";
public static final ItemGroup majoGroup = FabricItemGroup.builder(new Identifier(MODID, "majo_group"))
private static final RegistryKey<ItemGroup> majoGroupRegistryKey = RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier(MODID, "majo_group"));
public static final ItemGroup majoGroup = FabricItemGroup.builder()
.displayName(Text.translatable("itemGroup.majobroom.majo_group"))
.icon(() -> new ItemStack(MajoBroom.broomItem)).build();


//盔甲部分
public static final ArmorMaterial FABRIC_ARMOR = new ArmorFabric();
Expand All @@ -39,12 +44,11 @@ public class MajoBroom implements ModInitializer {
// public static final Item majoStocking = new BaseArmor(FABRIC_ARMOR, EquipmentSlot.FEET);
public static final Item majoHat = new BaseArmor(FABRIC_ARMOR, EquipmentSlot.HEAD);


//ItemGroup
static {
ItemGroupEvents.modifyEntriesEvent(majoGroup).register(MajoBroom::setItemGroup);
ItemGroupEvents.modifyEntriesEvent(majoGroupRegistryKey).register(MajoBroom::setItemGroup);
}

protected static void setItemGroup(FabricItemGroupEntries entries) {
entries.add(broomItem);
entries.add(majoHat);
Expand All @@ -61,7 +65,7 @@ protected static void setItemGroup(FabricItemGroupEntries entries) {

@Override
public void onInitialize() {

Registry.register(Registries.ITEM_GROUP, majoGroupRegistryKey, majoGroup);
Registry.register(Registries.ITEM, new Identifier(MODID, "broom_item"), broomItem);
Registry.register(Registries.ITEM, new Identifier(MODID, "majo_cloth"), majoCloth);
// Registry.register(Registries.ITEM, new Identifier(MODID, "stocking"), majoStocking);
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/fabricmc/majobroom/armors/ArmorFabric.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.fabricmc.majobroom.armors;

import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.Items;
Expand All @@ -13,13 +14,13 @@ public class ArmorFabric implements ArmorMaterial {
public static final int[] BASE_PROTECTION_AMOUNT = new int[]{2,5,6,3};//定义护甲的保护值,顺序同上

@Override
public int getDurability(EquipmentSlot arg0) {
return BASE_DURABILITY[arg0.getEntitySlotId()]*25;
public int getDurability(ArmorItem.Type type) {
return BASE_DURABILITY[type.getEquipmentSlot().getEntitySlotId()]*25;
}

@Override
public int getProtectionAmount(EquipmentSlot arg0) {
return BASE_PROTECTION_AMOUNT[arg0.getEntitySlotId()];
public int getProtection(ArmorItem.Type type) {
return BASE_PROTECTION_AMOUNT[type.getEquipmentSlot().getEntitySlotId()];
}

@Override
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/net/fabricmc/majobroom/armors/BaseArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,25 @@
public class BaseArmor extends DyeableArmorItem implements DyeableItem {

public BaseArmor(ArmorMaterial material, EquipmentSlot slot) {
super(material, slot, new Item.Settings());
super(material, getArmorType(slot), new Item.Settings());
DispenserBlock.registerBehavior(this,ArmorItem.DISPENSER_BEHAVIOR);//发射器穿装备
}

private static ArmorItem.Type getArmorType(EquipmentSlot slot) {
switch (slot) {
case HEAD:
return ArmorItem.Type.HELMET;
case CHEST:
return ArmorItem.Type.CHESTPLATE;
case LEGS:
return ArmorItem.Type.LEGGINGS;
case FEET:
return ArmorItem.Type.BOOTS;
default:
throw new IllegalArgumentException("Invalid equipment slot: " + slot);
}
}

@Override
public int getColor(ItemStack stack) {
NbtCompound nbtCompound = stack.getSubNbt("display");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.majobroom.MajoBroom;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.model.Dilation;
import net.minecraft.client.render.*;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
Expand All @@ -30,8 +32,9 @@ public class MajoClothFeatureRenderer<T extends LivingEntity, M extends BipedEnt
private static MajoWearableModel hat = null;
private static MajoWearableModel cloth = null;
private static MajoWearableModel foot = null;
private static BakedModelManager bakedModelManager = MinecraftClient.getInstance().getBakedModelManager();
public MajoClothFeatureRenderer(FeatureRendererContext<T, M> context, A leggingsModel, A bodyModel) {
super(context, leggingsModel, bodyModel);
super(context, leggingsModel, bodyModel, bakedModelManager);
}
@Override
public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, T livingEntity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/fabricmc/majobroom/entity/BroomEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ protected boolean canAddPassenger(Entity passenger) {
}

@Override
public void updatePassengerPosition(Entity passenger) {
super.updatePassengerPosition(passenger);
passenger.setPosition(passenger.getX(),passenger.getY()+0.6 +floatingValue,passenger.getZ());
protected void updatePassengerPosition(Entity passenger, Entity.PositionUpdater positionUpdater) {
super.updatePassengerPosition(passenger, positionUpdater);
passenger.setPosition(passenger.getX(), passenger.getY() + 0.6 + floatingValue, passenger.getZ());
}

@Environment(EnvType.CLIENT)
private void clientTick(){

if (passenger != null){
if ((!this.hasPassengers()) && this.world.isClient && MinecraftClient.getInstance().player.getId() == passenger.getId()){
if ((!this.hasPassengers()) && this.getWorld().isClient && MinecraftClient.getInstance().player.getId() == passenger.getId()){
if(MajoBroomConfig.getInstance().autoThirdPersonView) {
MinecraftClient.getInstance().options.setPerspective(Perspective.FIRST_PERSON);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ public void tick() {



if (this.world.isClient()){
if (this.getWorld().isClient()){
clientTick();
updateKeys();
if(this.hasPassengers() && MinecraftClient.getInstance().player.getId() == this.getFirstPassenger().getId()){
Expand Down Expand Up @@ -239,7 +239,7 @@ public ActionResult interact(PlayerEntity player, Hand hand) {

return ActionResult.PASS;
} else {
if (!this.world.isClient) {
if (!this.getWorld().isClient) {
return player.startRiding(this) ? ActionResult.CONSUME : ActionResult.PASS;
} else {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ public BroomFlyingSoundWrapper(BroomEntity attachedInstance) {
}

public void stop() {
if(attachedInstance.world.isClient){
if(attachedInstance.getWorld().isClient){
stop0();
}
}

public void play() {
if(attachedInstance.world.isClient){
if(attachedInstance.getWorld().isClient){
play0();
}
}

public void tick() {
if(attachedInstance.world.isClient){
if(attachedInstance.getWorld().isClient){
tick0();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "majobroom",
"version": "1.2.4",
"version": "1.2.5",

"name": "Majo's Broom",
"description": "A flying broom!",
Expand Down Expand Up @@ -42,12 +42,12 @@
"depends": {
"fabricloader": ">=0.12.0",
"fabric": "*",
"minecraft": "1.19.3",
"minecraft": "1.20.1",
"java": ">=17",
"cloth-config2":">=9.0.92"
"cloth-config2":">=11.1.106"
},
"suggests": {
"modmenu": ">=5.0.0"
"modmenu": ">=7.2.1"
},
"custom": {
"modmenu": {
Expand Down