Skip to content

Commit

Permalink
1.7 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mizuri-n committed May 7, 2024
1 parent b237432 commit f30a31f
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 87 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
org.gradle.jvmargs=-Xmx2G

# BTA
bta_version=7.1_01
bta_version=7.1

# Loader
loader_version=0.15.6-babric.5-bta

# HalpLibe
halplibe_version=3.5.4
halplibe_version=3.5.2

prismatic_version=3.1.2-7.1

# Mod
mod_version=1.0.5
mod_version=1.1.4
mod_group=Mizuri-n
mod_name=Better with Defense
2 changes: 0 additions & 2 deletions src/main/java/mizurin/shieldmod/ShieldAchievements.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.core.Global;
import net.minecraft.core.achievement.Achievement;
import net.minecraft.core.achievement.AchievementList;
import net.minecraft.core.achievement.stat.Stat;
import net.minecraft.core.block.Block;
import net.minecraft.core.item.ItemDye;
import net.minecraft.core.util.helper.Side;
Expand All @@ -26,7 +25,6 @@ public class ShieldAchievements extends AchievementPage {

public ShieldAchievements(){
super("Better with defense", "achievements.page.defense");
((Stat) BLOCK).registerStat();
achievementList.add(SHIELD_GOT);
achievementList.add(BLOCK);
achievementList.add(MODERN_AGE);
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/mizurin/shieldmod/ShieldMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import turniplabs.halplibe.helper.AchievementHelper;
import turniplabs.halplibe.util.ConfigHandler;
import turniplabs.halplibe.util.GameStartEntrypoint;
import mizurin.shieldmod.item.Shields;
import turniplabs.halplibe.util.achievements.AchievementPage;

import java.util.Properties;

public class ShieldMod implements ModInitializer, GameStartEntrypoint {
public static final String MOD_ID = "shieldmod";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

public static int itemID;
static {
Properties prop = new Properties();
prop.setProperty("starting_item_id", "17000");
ConfigHandler config = new ConfigHandler(ShieldMod.MOD_ID, prop);
itemID = config.getInt("starting_item_id");
config.updateConfig();
}



@Override
Expand All @@ -24,9 +36,9 @@ public void onInitialize() {
@Override
public void beforeGameStart() {
new Shields().initializeItems();
AchievementPage SHIELDACHIEVEMENTS;
SHIELDACHIEVEMENTS = new ShieldAchievements();
AchievementHelper.addPage(SHIELDACHIEVEMENTS);
//AchievementPage SHIELDACHIEVEMENTS;
//SHIELDACHIEVEMENTS = new ShieldAchievements();
AchievementHelper.addPage(new ShieldAchievements());

}

Expand Down
15 changes: 0 additions & 15 deletions src/main/java/mizurin/shieldmod/item/ShieldItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package mizurin.shieldmod.item;

import mizurin.shieldmod.ShieldAchievements;
import net.minecraft.core.entity.Entity;
import net.minecraft.core.entity.EntityLiving;
import net.minecraft.core.entity.player.EntityPlayer;
Expand Down Expand Up @@ -65,19 +64,5 @@ public void inventoryTick(ItemStack itemstack, World world, Entity entity, int i
}
}
}

/*@Override
public void onCraftedBy(ItemStack itemstack, World world, EntityPlayer entityplayer) {
super.onCraftedBy(itemstack, world, entityplayer);
if (itemstack != null && itemstack.getItem() instanceof ShieldItem) {
ShieldItem shield = ((ShieldItem) itemstack.getItem());
if(shield.tool == ShieldMaterials.TOOL_WOOD) {
entityplayer.addStat(ShieldAchievements.SHIELD_GOT, 1);
}
if(shield.tool == ShieldMaterials.TOOL_STEEL) {
entityplayer.addStat(ShieldAchievements.MODERN_AGE, 1);
}
}
} */
}

15 changes: 8 additions & 7 deletions src/main/java/mizurin/shieldmod/item/Shields.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import mizurin.shieldmod.ShieldMod;
import org.slf4j.Logger;
import net.minecraft.core.item.material.ArmorMaterial;
import static mizurin.shieldmod.ShieldMod.itemID;

public class Shields {
public static final String MOD_ID = ShieldMod.MOD_ID;
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static final Item leatherShield = ItemHelper.createItem(MOD_ID, new ShieldColored("leather.shield", 17006, ShieldMaterials.TOOL_LEATHER), "wooden_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item woodenShield = ItemHelper.createItem(MOD_ID, new ShieldItem("wooden.shield", 17000, ShieldMaterials.TOOL_WOOD),"wooden_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item stoneShield = ItemHelper.createItem(MOD_ID, new ShieldItem("stone.shield", 17001, ShieldMaterials.TOOL_STONE), "stone_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item ironShield = ItemHelper.createItem(MOD_ID, new ShieldItem("iron.shield", 17002, ShieldMaterials.TOOL_IRON), "iron_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item goldShield = ItemHelper.createItem(MOD_ID, new ShieldItem("gold.shield", 17003, ShieldMaterials.TOOL_GOLD), "gold_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item diamondShield = ItemHelper.createItem(MOD_ID, new ShieldItem("diamond.shield", 17004, ShieldMaterials.TOOL_DIAMOND), "diamond_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item steelShield = ItemHelper.createItem(MOD_ID, new ShieldItem("steel.shield", 17005, ShieldMaterials.TOOL_STEEL), "steel_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item woodenShield = ItemHelper.createItem(MOD_ID, new ShieldItem("wooden.shield", ++itemID, ShieldMaterials.TOOL_WOOD),"wooden_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item stoneShield = ItemHelper.createItem(MOD_ID, new ShieldItem("stone.shield", ++itemID, ShieldMaterials.TOOL_STONE), "stone_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item ironShield = ItemHelper.createItem(MOD_ID, new ShieldItem("iron.shield", ++itemID, ShieldMaterials.TOOL_IRON), "iron_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item goldShield = ItemHelper.createItem(MOD_ID, new ShieldItem("gold.shield", ++itemID, ShieldMaterials.TOOL_GOLD), "gold_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item diamondShield = ItemHelper.createItem(MOD_ID, new ShieldItem("diamond.shield", ++itemID, ShieldMaterials.TOOL_DIAMOND), "diamond_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item steelShield = ItemHelper.createItem(MOD_ID, new ShieldItem("steel.shield", ++itemID, ShieldMaterials.TOOL_STEEL), "steel_shield.png").withTags(ItemTags.preventCreativeMining);
public static final Item leatherShield = ItemHelper.createItem(MOD_ID, new ShieldColored("leather.shield", ++itemID, ShieldMaterials.TOOL_LEATHER), "wooden_shield.png").withTags(ItemTags.preventCreativeMining);

public static final Item armorLeatherHelmet = ItemHelper.createItem(MOD_ID, new ArmorColored("Leather Cap", 16426,ArmorMaterial.LEATHER , 0 ), "armor.helmet.leather");
public static final Item armorLeatherChest = ItemHelper.createItem(MOD_ID, new ArmorColored("Leather Tunic", 16427,ArmorMaterial.LEATHER , 1 ), "armor.chestplate.leather");
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import mizurin.shieldmod.ShieldAchievements;



// mixin to EntityPlayer, do not remap(forgot what remap does)
@Mixin(value = EntityPlayer.class, remap = false)

Expand Down Expand Up @@ -47,7 +48,8 @@ public ShieldMixin(World world) {
public abstract void addStat(Stat statbase, int i);



@Shadow
public abstract void triggerAchievement(Stat statbase);

// inject at the top(HEAD) of hurt(), allow us to call return(cancel/set return value)
@Inject(method = "hurt", at = @At("HEAD"), cancellable = true)
Expand Down Expand Up @@ -82,17 +84,18 @@ public void injectHurt(Entity attacker, int damage, DamageType type, CallbackInf

if (shield.tool == ShieldMaterials.TOOL_LEATHER){
attacker.push(0 ,1,0);
addStat(ShieldAchievements.FLY_HIGH, 1);
//addStat(ShieldAchievements.FLY_HIGH, 1);
}
if(shield.tool == ShieldMaterials.TOOL_GOLD){
attacker.hurt(attacker, newDamage, type);
addStat(ShieldAchievements.GOLD_RETAL, 1);
//addStat(ShieldAchievements.GOLD_RETAL, 1);
}
super.hurt(attacker, newDamage, type);
addStat(ShieldAchievements.BLOCK, 1);
if( damage > 20 && isAlive()){
addStat(ShieldAchievements.INVINCIBLE, 1);
}
//addStat(ShieldAchievements.BLOCK, 1);

//if( damage > 20 && isAlive()){
//addStat(ShieldAchievements.INVINCIBLE, 1);
//}

world.playSoundAtEntity(attacker,
attacker, ("mob.ghast.fireball"),
Expand All @@ -113,6 +116,7 @@ public void injectHurt(Entity attacker, int damage, DamageType type, CallbackInf
dx, dy, dz
);
}

stack.damageItem(4, inventory.player);
} else {
super.hurt(attacker, damage, type);
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/mizurin/shieldmod/mixins/achievement/dyeMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package mizurin.shieldmod.mixins.achievement;

import mizurin.shieldmod.ShieldAchievements;
import mizurin.shieldmod.item.Shields;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.player.inventory.slot.SlotCrafting;
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(value = SlotCrafting.class, remap = false)
public class dyeMixin {

@Shadow
private EntityPlayer thePlayer;

@Inject(method = "onPickupFromSlot", at = @At("TAIL"))
private void injectPickup(ItemStack itemStack, CallbackInfo ci){
/*Item item = itemStack.getItem();
if(item.id == Shields.woodenShield.id){
thePlayer.triggerAchievement(ShieldAchievements.SHIELD_GOT);
}
if(item.id == Shields.steelShield.id){
thePlayer.addStat(ShieldAchievements.MODERN_AGE, 1);
}
if(item.id == Shields.armorLeatherHelmet.id && itemStack.getData().containsKey("dyed_color")){
thePlayer.addStat(ShieldAchievements.COLORS, 1);
}
if(item.id == Shields.armorLeatherChest.id && itemStack.getData().containsKey("dyed_color")){
thePlayer.addStat(ShieldAchievements.COLORS, 1);
}
if(item.id == Shields.armorLeatherLeg.id && itemStack.getData().containsKey("dyed_color")){
thePlayer.addStat(ShieldAchievements.COLORS, 1);
}
if(item.id == Shields.armorLeatherBoot.id && itemStack.getData().containsKey("dyed_color")){
thePlayer.addStat(ShieldAchievements.COLORS, 1);
}
if(item.id == Shields.leatherShield.id && itemStack.getData().containsKey("dyed_color")){
thePlayer.addStat(ShieldAchievements.COLORS, 1);
}
*/}
}
45 changes: 0 additions & 45 deletions src/main/java/mizurin/shieldmod/mixins/dyeMixin.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/resources/lang/shieldmod/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ achievement.shieldmod.shield.got.desc=Use planks and a log to make a shield
achievement.shieldmod.modern.age=The Modern Age
achievement.shieldmod.modern.age.desc=Obtain a Steel Shield
achievement.shieldmod.fly.high=Fly High
achievement.shieldmod.fly.high.desc=Knock an enemy into the air!
achievement.shieldmod.fly.high.desc=Knock an attacker into the air!
achievement.shieldmod.gold.retal=Golden Retaliation
achievement.shieldmod.gold.retal.desc=Send damage back to an enemy
achievement.shieldmod.gold.retal.desc=Send damage back to an attacker
achievement.shieldmod.colorful.world=Colorful World
achievement.shieldmod.colorful.world.desc=Obtain a dyed shield or armor

Expand Down
5 changes: 2 additions & 3 deletions src/main/resources/shieldmod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"package": "mizurin.shieldmod.mixins",
"compatibilityLevel": "JAVA_8",
"mixins": [
"dyeMixin",
"ItemMixin",
"ShieldMixin"
"ShieldMixin",
"achievement.dyeMixin"
],
"client": [
"dyeMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit f30a31f

Please sign in to comment.