Skip to content

Commit

Permalink
Added obsidian plated reinforced magic armor and tools
Browse files Browse the repository at this point in the history
  • Loading branch information
PiTheGuy committed Apr 9, 2022
1 parent d52c4a6 commit d4bc109
Show file tree
Hide file tree
Showing 45 changed files with 447 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public CustomArmorMagic(IArmorMaterial materialIn, EquipmentSlotType slot, Prope
public void onArmorTick(ItemStack itemstack, World world, PlayerEntity player) {
if (ArmorHandler.isWearingReinforcedMagicArmor(player)) {
player.addPotionEffect(new EffectInstance(Effects.REGENERATION, 2, 1, true, false));
} else if (ArmorHandler.isWearingObsidianPlatedReinforcedMagicArmor(player)) {
player.addPotionEffect(new EffectInstance(Effects.REGENERATION, 2, 3, true, false));
player.addPotionEffect(new EffectInstance(Effects.SATURATION, 1, 0, true, false));
player.addPotionEffect(new EffectInstance(Effects.SPEED, 1, 1, true, false));
}
}
}
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public MagicPressContainer(final int windowID, final PlayerInventory playerInv,
}
}
//Magic Press Inventory
this.addSlot(new MultiItemSlotItemHandler(tile.getInventory(), 0, 27, 19, Arrays.asList(MAGIC_HELMET.get(),MAGIC_CHESTPLATE.get(),MAGIC_LEGGINGS.get(),MAGIC_BOOTS.get(),MAGIC_PICKAXE.get(),MAGIC_AXE.get(),MAGIC_SHOVEL.get(),MAGIC_SWORD.get(),MAGIC_HOE.get())));
this.addSlot(new SingleItemSlotItemHandler(tile.getInventory(), 1, 76, 19, MAGIC_PLATE.get()));
this.addSlot(new MultiItemSlotItemHandler(tile.getInventory(), 2, 134,19, Arrays.asList(REINFORCED_MAGIC_HELMET.get(), REINFORCED_MAGIC_CHESTPLATE.get(), REINFORCED_MAGIC_LEGGINGS.get(), REINFORCED_MAGIC_BOOTS.get(), REINFORCED_MAGIC_PICKAXE.get(), REINFORCED_MAGIC_AXE.get(), REINFORCED_MAGIC_SHOVEL.get(), REINFORCED_MAGIC_SWORD.get(), REINFORCED_MAGIC_HOE.get())));
this.addSlot(new MultiItemSlotItemHandler(tile.getInventory(), 0, 27, 19, Arrays.asList(REINFORCED_MAGIC_HELMET.get(),REINFORCED_MAGIC_CHESTPLATE.get(),REINFORCED_MAGIC_LEGGINGS.get(),REINFORCED_MAGIC_BOOTS.get(),REINFORCED_MAGIC_PICKAXE.get(),REINFORCED_MAGIC_AXE.get(),REINFORCED_MAGIC_SHOVEL.get(),REINFORCED_MAGIC_SWORD.get(),REINFORCED_MAGIC_HOE.get())));
this.addSlot(new SingleItemSlotItemHandler(tile.getInventory(), 1, 76, 19, OBSIDIAN_PLATE.get()));
this.addSlot(new MultiItemSlotItemHandler(tile.getInventory(), 2, 134,19, Arrays.asList(OBSIDIAN_PLATED_REINFORCED_MAGIC_HELMET.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_CHESTPLATE.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_LEGGINGS.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_BOOTS.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_PICKAXE.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_AXE.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_SHOVEL.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_SWORD.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_HOE.get())));
this.addSlot(new MultiItemSlotItemHandler(tile.getInventory(), 3,15,53, Arrays.asList(MAGIC_GEM.get(), MAGIC_BLOCK_ITEM.get())));

this.trackInt(fuel = new FunctionalIntReferenceHolder(() -> this.tileEntity.fuel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public static void onDamageWithMagicArmor(LivingDamageEvent event) {
event.setAmount(event.getAmount() * 0.6f);
} else if (ArmorHandler.isWearingReinforcedMagicArmor(player)) {
event.setAmount(event.getAmount() * 0.2f);
} else if (ArmorHandler.isWearingObsidianPlatedReinforcedMagicArmor(player)) {
event.setAmount(event.getAmount() * 0.05f);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ public class MagicPressTileEntity extends TileEntity implements ITickableTileEnt
private final ModItemHandler inventory;
public int fuel = 0;
public final int maxFuel = 20;
public static final Map<Item,Integer> ITEM_FUEL_AMOUNT = Maps.newHashMap(ImmutableMap.of(MAGIC_GEM.get(), 2, MAGIC_BLOCK_ITEM.get(), 18));
public static final Map<Item,Integer> ITEM_FUEL_AMOUNT = Maps.newHashMap(ImmutableMap.of(MAGIC_GEM.get(), 1, MAGIC_BLOCK_ITEM.get(), 9));
public static final Map<Item, Item> RECIPES = Maps.newHashMap(new ImmutableMap.Builder<Item, Item>()
.put(MAGIC_HELMET.get(),REINFORCED_MAGIC_HELMET.get())
.put(MAGIC_CHESTPLATE.get(),REINFORCED_MAGIC_CHESTPLATE.get())
.put(MAGIC_LEGGINGS.get(),REINFORCED_MAGIC_LEGGINGS.get())
.put(MAGIC_BOOTS.get(),REINFORCED_MAGIC_BOOTS.get())
.put(MAGIC_PICKAXE.get(),REINFORCED_MAGIC_PICKAXE.get())
.put(MAGIC_AXE.get(),REINFORCED_MAGIC_AXE.get())
.put(MAGIC_SHOVEL.get(),REINFORCED_MAGIC_SHOVEL.get())
.put(MAGIC_SWORD.get(),REINFORCED_MAGIC_SWORD.get())
.put(MAGIC_HOE.get(),REINFORCED_MAGIC_HOE.get())
.put(REINFORCED_MAGIC_HELMET.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_HELMET.get())
.put(REINFORCED_MAGIC_CHESTPLATE.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_CHESTPLATE.get())
.put(REINFORCED_MAGIC_LEGGINGS.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_LEGGINGS.get())
.put(REINFORCED_MAGIC_BOOTS.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_BOOTS.get())
.put(REINFORCED_MAGIC_PICKAXE.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_PICKAXE.get())
.put(REINFORCED_MAGIC_AXE.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_AXE.get())
.put(REINFORCED_MAGIC_SHOVEL.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_SHOVEL.get())
.put(REINFORCED_MAGIC_SWORD.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_SWORD.get())
.put(REINFORCED_MAGIC_HOE.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_HOE.get())
.build());
public MagicPressTileEntity(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
Expand Down Expand Up @@ -124,11 +124,11 @@ public void tick() {
this.inventory.decrStackSize(3, 1);
dirty = true;
}
if (RECIPES.get(this.inventory.getStackInSlot(0).getItem()) != null && this.inventory.getStackInSlot(1).getItem() == MAGIC_PLATE.get() && this.inventory.getStackInSlot(1).getCount() >= 8 && fuel >= 1) {
if (RECIPES.get(this.inventory.getStackInSlot(0).getItem()) != null && this.inventory.getStackInSlot(1).getItem() == OBSIDIAN_PLATE.get() && this.inventory.getStackInSlot(1).getCount() >= 32 && fuel >= 1) {
fuel--;
this.inventory.insertItem(2,new ItemStack(RECIPES.get(this.inventory.getStackInSlot(0).getItem()), 1), false);
this.inventory.decrStackSize(0,1);
this.inventory.decrStackSize(1,8);
this.inventory.decrStackSize(1,32);
dirty = true;
}
}
Expand Down
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);
}
}
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();
}
}
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public ReinforcedMagicShovel(IItemTier tier, float attackDamageIn, float attackS
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) {
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
if(worldIn.getBlockState(pos.add(x,0,z)).getBlock().getHarvestTool(null)== ToolType.SHOVEL) {
worldIn.destroyBlock(pos.add(x, 0, z), true);
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
if (worldIn.getBlockState(pos.add(x, y, z)).getBlock().getHarvestTool(null) == ToolType.SHOVEL) {
worldIn.destroyBlock(pos.add(x, y, z), true);
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/pitheguy/magicmod/util/ArmorHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ public static boolean isWearingReinforcedMagicArmor (PlayerEntity player) {
player.getItemStackFromSlot(EquipmentSlotType.LEGS).getItem() == RegistryHandler.REINFORCED_MAGIC_LEGGINGS.get() &&
player.getItemStackFromSlot(EquipmentSlotType.FEET).getItem() == RegistryHandler.REINFORCED_MAGIC_BOOTS.get();
}
public static boolean isWearingObsidianPlatedReinforcedMagicArmor (PlayerEntity player) {
return player.getItemStackFromSlot(EquipmentSlotType.HEAD).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_HELMET.get()
&& player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_CHESTPLATE.get() &&
player.getItemStackFromSlot(EquipmentSlotType.LEGS).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_LEGGINGS.get() &&
player.getItemStackFromSlot(EquipmentSlotType.FEET).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_BOOTS.get();
}
}
Loading

0 comments on commit d4bc109

Please sign in to comment.