-
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.
Added obsidian plated reinforced magic armor and tools
- Loading branch information
Showing
45 changed files
with
447 additions
and
18 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
71 changes: 71 additions & 0 deletions
71
src/main/java/com/pitheguy/magicmod/armor/ObsidianPlatedReinforcedMagicArmorMaterial.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,71 @@ | ||
package com.pitheguy.magicmod.armor; | ||
|
||
import com.pitheguy.magicmod.util.RegistryHandler; | ||
import net.minecraft.inventory.EquipmentSlotType; | ||
import net.minecraft.item.IArmorMaterial; | ||
import net.minecraft.item.crafting.Ingredient; | ||
import net.minecraft.util.SoundEvent; | ||
import net.minecraft.util.SoundEvents; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public enum ObsidianPlatedReinforcedMagicArmorMaterial implements IArmorMaterial { | ||
|
||
OBSIDIAN_PLATED_REINFORCED_MAGIC(new int[] {300,550,675,300}, () -> { return Ingredient.fromItems(RegistryHandler.MAGIC_GEM.get()); }); | ||
|
||
private static final int[] MAX_DAMAGE_ARRAY = new int[] {11,16,15,13}; | ||
private final String name; | ||
private final int maxDamageFactor; | ||
private final int[] damageReductionAmountArray; | ||
private final int enchantability; | ||
private final SoundEvent soundEvent; | ||
private final float toughness; | ||
private final Supplier<Ingredient> repairMaterial; | ||
|
||
ObsidianPlatedReinforcedMagicArmorMaterial(int[] damageReductionAmountArray, Supplier<Ingredient> repairMaterial){ | ||
this.name = "magicmod:obsidian_plated_reinforced_magic"; | ||
this.maxDamageFactor = 20000; | ||
this.damageReductionAmountArray = damageReductionAmountArray; | ||
this.enchantability = 80; | ||
this.soundEvent = SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND; | ||
this.toughness = (float) 175.0; | ||
this.repairMaterial = repairMaterial; | ||
} | ||
|
||
@Override | ||
public int getDurability(EquipmentSlotType slotIn) { | ||
return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * maxDamageFactor; | ||
} | ||
|
||
@Override | ||
public int getDamageReductionAmount(EquipmentSlotType slotIn) { | ||
return damageReductionAmountArray[slotIn.getIndex()]; | ||
} | ||
|
||
@Override | ||
public int getEnchantability() { | ||
return enchantability; | ||
} | ||
|
||
@Override | ||
public SoundEvent getSoundEvent() { | ||
return soundEvent; | ||
} | ||
|
||
@Override | ||
public Ingredient getRepairMaterial() { | ||
return repairMaterial.get(); | ||
} | ||
@OnlyIn(Dist.CLIENT) | ||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public float getToughness() { | ||
return toughness; | ||
} | ||
} |
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
76 changes: 76 additions & 0 deletions
76
src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicHoe.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,76 @@ | ||
package com.pitheguy.magicmod.tools; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.HoeItem; | ||
import net.minecraft.item.IItemTier; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.ItemUseContext; | ||
import net.minecraft.state.properties.BlockStateProperties; | ||
import net.minecraft.util.ActionResultType; | ||
import net.minecraft.util.Direction; | ||
import net.minecraft.util.SoundCategory; | ||
import net.minecraft.util.SoundEvents; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ObsidianPlatedReinforcedMagicHoe extends HoeItem { | ||
public ObsidianPlatedReinforcedMagicHoe(IItemTier tier, float attackSpeedIn, Properties builder) { | ||
super(tier, attackSpeedIn, builder); | ||
} | ||
|
||
@Override | ||
public ActionResultType onItemUse(ItemUseContext context) { | ||
World world = context.getWorld(); | ||
BlockPos blockpos = context.getPos(); | ||
int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(context); | ||
if (hook != 0) return hook > 0 ? ActionResultType.SUCCESS : ActionResultType.FAIL; | ||
BlockState blockstate = HOE_LOOKUP.get(world.getBlockState(blockpos).getBlock()); | ||
if (context.getFace() != Direction.DOWN && blockstate != null && world.isAirBlock(blockpos.up())) { | ||
int blocksTilled = 0; | ||
for (int tillX = -5; tillX <= 5; tillX++) { | ||
for (int tillZ = -5; tillZ <= 5; tillZ++) { | ||
BlockPos tillpos = blockpos.add(tillX,0,tillZ); | ||
blockstate = HOE_LOOKUP.get(world.getBlockState(tillpos).getBlock()); | ||
if (blockstate != null && world.isAirBlock(tillpos.up())) { | ||
PlayerEntity playerentity = context.getPlayer(); | ||
world.playSound(playerentity, tillpos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F); | ||
if (!world.isRemote) { | ||
world.setBlockState(tillpos, blockstate, 11); | ||
blocksTilled++; | ||
if (playerentity != null && blocksTilled == 1) { | ||
context.getItem().damageItem(1, playerentity, (p_220043_1_) -> p_220043_1_.sendBreakAnimation(context.getHand())); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (blocksTilled > 0) { | ||
return ActionResultType.SUCCESS; | ||
} | ||
} | ||
|
||
return ActionResultType.PASS; | ||
} | ||
private static final List<Block> CROP_BLOCKS_AGE_7 = Arrays.asList(Blocks.WHEAT, Blocks.CARROTS, Blocks.POTATOES); | ||
private static final List<Block> CROP_BLOCKS_AGE_3 = Arrays.asList(Blocks.BEETROOTS, Blocks.NETHER_WART); | ||
|
||
@Override | ||
public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { | ||
for (int x = -3; x <= 3; x++) { | ||
for (int z = -3; z <= 3; z++) { | ||
BlockState currBlock = worldIn.getBlockState(pos.add(x, 0, z)); | ||
if((CROP_BLOCKS_AGE_7.contains(currBlock.getBlock()) && currBlock.get(BlockStateProperties.AGE_0_7) == 7) || (CROP_BLOCKS_AGE_3.contains(currBlock.getBlock()) && currBlock.get(BlockStateProperties.AGE_0_3) == 3)) { | ||
worldIn.destroyBlock(pos.add(x, 0, z), true); | ||
} | ||
} | ||
} | ||
return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicItemTier.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,59 @@ | ||
package com.pitheguy.magicmod.tools; | ||
|
||
import com.pitheguy.magicmod.util.RegistryHandler; | ||
import net.minecraft.item.IItemTier; | ||
import net.minecraft.item.crafting.Ingredient; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public enum ObsidianPlatedReinforcedMagicItemTier implements IItemTier { | ||
OBSIDIAN_PLATED_REINFORCED_MAGIC(() -> { | ||
return Ingredient.fromItems(RegistryHandler.MAGIC_GEM.get()); | ||
}); | ||
|
||
private final int harvestLevel; | ||
private final int maxUses; | ||
private final float efficiency; | ||
private final float attackDamage; | ||
private final int enchantability; | ||
private final Supplier<Ingredient> repairMaterial; | ||
|
||
ObsidianPlatedReinforcedMagicItemTier(Supplier<Ingredient> repairMaterial) { | ||
this.harvestLevel = 7; | ||
this.maxUses = 550000; | ||
this.efficiency = 135; | ||
this.attackDamage = 0; | ||
this.enchantability = 80; | ||
this.repairMaterial = repairMaterial; | ||
} | ||
|
||
@Override | ||
public int getMaxUses() { | ||
return maxUses; | ||
} | ||
|
||
@Override | ||
public float getEfficiency() { | ||
return efficiency; | ||
} | ||
|
||
@Override | ||
public float getAttackDamage() { | ||
return attackDamage; | ||
} | ||
|
||
@Override | ||
public int getHarvestLevel() { | ||
return harvestLevel; | ||
} | ||
|
||
@Override | ||
public int getEnchantability() { | ||
return enchantability; | ||
} | ||
|
||
@Override | ||
public Ingredient getRepairMaterial() { | ||
return repairMaterial.get(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicShovel.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,30 @@ | ||
package com.pitheguy.magicmod.tools; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.item.IItemTier; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.ShovelItem; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.common.ToolType; | ||
|
||
public class ObsidianPlatedReinforcedMagicShovel extends ShovelItem { | ||
public ObsidianPlatedReinforcedMagicShovel(IItemTier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { | ||
super(tier, attackDamageIn, attackSpeedIn, builder); | ||
} | ||
|
||
@Override | ||
public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { | ||
for (int x = -2; x <= 2; x++) { | ||
for (int y = -2; y <= 2; y++) { | ||
for (int z = -2; z <= 2; z++) { | ||
if (worldIn.getBlockState(pos.add(x, y, z)).getBlock().getHarvestTool(null) == ToolType.SHOVEL) { | ||
worldIn.destroyBlock(pos.add(x, y, z), true); | ||
} | ||
} | ||
} | ||
} | ||
return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); | ||
} | ||
} |
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
Oops, something went wrong.