diff --git a/build.gradle b/build.gradle index 3b42dab4..60a73644 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' //apply plugin: 'maven-publish' -version = '1.0.1' +version = '1.0.2' group = 'com.fi0x.deepmagic' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'deepmagic' diff --git a/src/main/java/com/fi0x/deepmagic/Main.java b/src/main/java/com/fi0x/deepmagic/Main.java index d03bd993..b8123fd0 100644 --- a/src/main/java/com/fi0x/deepmagic/Main.java +++ b/src/main/java/com/fi0x/deepmagic/Main.java @@ -60,8 +60,7 @@ public static void preInit(FMLPreInitializationEvent event) PacketHandler.registerMessages(Reference.MOD_ID); ModFluids.registerFluids(); EntityInit.registerEntities(); - RenderHandler.registerEntityRenders(); - RenderHandler.registerCustomMeshesAndStates(); + proxy.preInit2(event); BiomeInit.registerBiomes(); DimensionInit.registerDimensions(); GameRegistry.registerWorldGenerator(new ModWorldGen(), 3); diff --git a/src/main/java/com/fi0x/deepmagic/advancements/CustomTrigger.java b/src/main/java/com/fi0x/deepmagic/advancements/CustomTrigger.java new file mode 100644 index 00000000..c24ae9d9 --- /dev/null +++ b/src/main/java/com/fi0x/deepmagic/advancements/CustomTrigger.java @@ -0,0 +1,153 @@ +package com.fi0x.deepmagic.advancements; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonObject; +import net.minecraft.advancements.ICriterionTrigger; +import net.minecraft.advancements.PlayerAdvancements; +import net.minecraft.advancements.critereon.AbstractCriterionInstance; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.ResourceLocation; + +import javax.annotation.Nonnull; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class CustomTrigger implements ICriterionTrigger +{ + private final ResourceLocation RL; + private final Map listeners = Maps.newHashMap(); + + public CustomTrigger(String parString) + { + super(); + RL = new ResourceLocation(parString); + } + + public CustomTrigger(ResourceLocation parRL) + { + super(); + RL = parRL; + } + + @Nonnull + @Override + public ResourceLocation getId() + { + return RL; + } + + @Override + public void addListener(@Nonnull PlayerAdvancements playerAdvancementsIn, @Nonnull ICriterionTrigger.Listener listener) + { + CustomTrigger.Listeners customTriggerListeners = listeners.get(playerAdvancementsIn); + + if (customTriggerListeners == null) + { + customTriggerListeners = new CustomTrigger.Listeners(playerAdvancementsIn); + listeners.put(playerAdvancementsIn, customTriggerListeners); + } + + customTriggerListeners.add(listener); + } + + @Override + public void removeListener(@Nonnull PlayerAdvancements playerAdvancementsIn, @Nonnull ICriterionTrigger.Listener listener) + { + CustomTrigger.Listeners customTriggerListeners = listeners.get(playerAdvancementsIn); + + if (customTriggerListeners != null) + { + customTriggerListeners.remove(listener); + + if (customTriggerListeners.isEmpty()) + listeners.remove(playerAdvancementsIn); + } + } + + @Override + public void removeAllListeners(@Nonnull PlayerAdvancements playerAdvancementsIn) + { + listeners.remove(playerAdvancementsIn); + } + + @Nonnull + @Override + public CustomTrigger.Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) + { + return new CustomTrigger.Instance(getId()); + } + + public void trigger(EntityPlayerMP parPlayer) + { + CustomTrigger.Listeners customTriggerListeners = listeners.get(parPlayer.getAdvancements()); + + if (customTriggerListeners != null) + customTriggerListeners.trigger(parPlayer); + } + + public static class Instance extends AbstractCriterionInstance + { + + public Instance(ResourceLocation parRL) + { + super(parRL); + } + + public boolean test() + { + return true; + } + } + + static class Listeners + { + private final PlayerAdvancements playerAdvancements; + private final Set> listeners = Sets.newHashSet(); + + public Listeners(PlayerAdvancements playerAdvancementsIn) + { + playerAdvancements = playerAdvancementsIn; + } + + public boolean isEmpty() + { + return listeners.isEmpty(); + } + + public void add(ICriterionTrigger.Listener listener) + { + listeners.add(listener); + } + + public void remove(ICriterionTrigger.Listener listener) + { + listeners.remove(listener); + } + + public void trigger(EntityPlayerMP player) + { + List> list = null; + + for (ICriterionTrigger.Listener listener : listeners) + { + if (listener.getCriterionInstance().test()) + { + if (list == null) + list = Lists.newArrayList(); + + list.add(listener); + } + } + + if (list != null) + { + for (ICriterionTrigger.Listener listener1 : list) + listener1.grantCriterion(playerAdvancements); + } + } + } +} diff --git a/src/main/java/com/fi0x/deepmagic/advancements/ModTriggers.java b/src/main/java/com/fi0x/deepmagic/advancements/ModTriggers.java new file mode 100644 index 00000000..3a548cf4 --- /dev/null +++ b/src/main/java/com/fi0x/deepmagic/advancements/ModTriggers.java @@ -0,0 +1,14 @@ +package com.fi0x.deepmagic.advancements; + +public class ModTriggers +{ + public static final CustomTrigger RIGHT_CLICK_SPELL = new CustomTrigger("right_click_spell"); + public static final CustomTrigger LINK_MANA_RELAY = new CustomTrigger("link_mana_relay"); + public static final CustomTrigger KNOWLEDGE_UI_OPENED = new CustomTrigger("altar_of_knowledge_ui_opened"); + + public static final CustomTrigger[] TRIGGER_ARRAY = new CustomTrigger[]{ + RIGHT_CLICK_SPELL, + LINK_MANA_RELAY, + KNOWLEDGE_UI_OPENED + }; +} \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/blocks/mana/AltarOfKnowledge.java b/src/main/java/com/fi0x/deepmagic/blocks/mana/AltarOfKnowledge.java index c041a18a..bb64aba0 100644 --- a/src/main/java/com/fi0x/deepmagic/blocks/mana/AltarOfKnowledge.java +++ b/src/main/java/com/fi0x/deepmagic/blocks/mana/AltarOfKnowledge.java @@ -1,6 +1,7 @@ package com.fi0x.deepmagic.blocks.mana; import com.fi0x.deepmagic.Main; +import com.fi0x.deepmagic.advancements.ModTriggers; import com.fi0x.deepmagic.blocks.BlockBase; import com.fi0x.deepmagic.mana.player.PlayerMana; import com.fi0x.deepmagic.mana.player.PlayerProperties; @@ -11,6 +12,7 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; @@ -42,6 +44,7 @@ public boolean onBlockActivated(@Nonnull World worldIn, @Nonnull BlockPos pos, @ assert playerMana != null; PacketHandler.INSTANCE.sendToServer(new PacketGetSkill(playerIn.getName(), playerMana.getMaxMana(), playerMana.getSkillXP(), playerMana.getSkillpoints(), playerMana.getManaRegenRate(), playerMana.getManaEfficiencyValue(), playerMana.addedHP, playerMana.hpRegeneration, playerMana.getSpellTier())); Main.proxy.openSkilltreeGui(playerIn); + ModTriggers.KNOWLEDGE_UI_OPENED.trigger((EntityPlayerMP) playerIn); } return true; } diff --git a/src/main/java/com/fi0x/deepmagic/blocks/mana/ManaBattery.java b/src/main/java/com/fi0x/deepmagic/blocks/mana/ManaBattery.java new file mode 100644 index 00000000..e737b4a0 --- /dev/null +++ b/src/main/java/com/fi0x/deepmagic/blocks/mana/ManaBattery.java @@ -0,0 +1,133 @@ +package com.fi0x.deepmagic.blocks.mana; + +import com.fi0x.deepmagic.blocks.BlockBase; +import com.fi0x.deepmagic.blocks.mana.tile.TileEntityManaBattery; +import com.fi0x.deepmagic.init.ModBlocks; +import com.fi0x.deepmagic.items.mana.ManaLinker; +import com.fi0x.deepmagic.particlesystem.ParticleEnum; +import com.fi0x.deepmagic.particlesystem.ParticleSpawner; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Objects; +import java.util.Random; + +public class ManaBattery extends BlockBase implements ITileEntityProvider +{ + public ManaBattery(String name, Material material) + { + super(name, material); + setSoundType(SoundType.STONE); + setHardness(5.0F); + setResistance(5.0F); + setHarvestLevel("pickaxe", 0); + } + + @Override + public boolean onBlockActivated(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull EntityPlayer playerIn, @Nonnull EnumHand hand, @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ) + { + if(worldIn.isRemote) return false; + ItemStack stack = playerIn.getHeldItem(hand); + Item item = stack.getItem(); + + TileEntityManaBattery te = (TileEntityManaBattery) worldIn.getTileEntity(pos); + assert te != null; + + if(item instanceof ManaLinker) + { + NBTTagCompound compound; + if(!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); + compound = stack.getTagCompound(); + assert compound != null; + + if(compound.hasKey("x")) + { + int x = compound.getInteger("x"); + int y = compound.getInteger("y"); + int z = compound.getInteger("z"); + + if(te.addOrRemoveTarget(new BlockPos(x, y, z))) + playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Linked to " + x + ", " + y + ", " + z)); + else + playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Unlinked " + x + ", " + y + ", " + z)); + } else + { + compound.setInteger("x", pos.getX()); + compound.setInteger("y", pos.getY()); + compound.setInteger("z", pos.getZ()); + playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Location stored")); + } + } + else if(playerIn.isCreative() && item.getUnlocalizedName().equals("item.dimensional_crystal")) + { + if(te.isCreative()) + playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Battery already in creative mode")); + else + { + te.makeCreative(); + playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Upgraded Battery to creative mode")); + } + } else if(stack.isEmpty()) + playerIn.sendMessage(new TextComponentString(TextFormatting.BLUE + "Stored Mana: " + te.getStoredMana())); + + return false; + } + @Nonnull + @Override + public Item getItemDropped(@Nonnull IBlockState state, @Nonnull Random rand, int fortune) + { + return Item.getItemFromBlock(ModBlocks.MANA_BATTERY); + } + @Nonnull + @Override + public ItemStack getItem(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state) + { + return new ItemStack(ModBlocks.MANA_BATTERY); + } + @Nullable + @Override + public TileEntity createNewTileEntity(@Nonnull World worldIn, int meta) + { + return new TileEntityManaBattery(); + } + @Override + public boolean isOpaqueCube(@Nonnull IBlockState state) + { + return false; + } + @Override + public boolean isFullCube(@Nonnull IBlockState state) + { + return false; + } + @SideOnly(Side.CLIENT) + public void randomDisplayTick(@Nonnull IBlockState stateIn, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull Random rand) + { + if(rand.nextInt(4) > 0) return; + if(((TileEntityManaBattery) Objects.requireNonNull(worldIn.getTileEntity(pos))).hasTargets()) + { + double x = pos.getX() + (Math.random() * 0.2) + 0.4; + double y = pos.getY() + 1 + (Math.random() * 0.2); + double z = pos.getZ() + (Math.random() * 0.2) + 0.4; + + ParticleSpawner.spawnParticle(ParticleEnum.MANA_BLOCK, x, y, z, 0, 0, 0, Math.random() * 0.3 + 0.2, false, 16); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/blocks/mana/ManaRelay.java b/src/main/java/com/fi0x/deepmagic/blocks/mana/ManaRelay.java index 5d6d2602..5357d919 100644 --- a/src/main/java/com/fi0x/deepmagic/blocks/mana/ManaRelay.java +++ b/src/main/java/com/fi0x/deepmagic/blocks/mana/ManaRelay.java @@ -1,5 +1,6 @@ package com.fi0x.deepmagic.blocks.mana; +import com.fi0x.deepmagic.advancements.ModTriggers; import com.fi0x.deepmagic.blocks.BlockBase; import com.fi0x.deepmagic.blocks.mana.tile.TileEntityManaRelay; import com.fi0x.deepmagic.init.ModBlocks; @@ -11,6 +12,7 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -65,8 +67,13 @@ public boolean onBlockActivated(@Nonnull World worldIn, @Nonnull BlockPos pos, @ int y = compound.getInteger("y"); int z = compound.getInteger("z"); - if(te.addOrRemoveTarget(new BlockPos(x, y, z))) playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Linked to " + x + ", " + y + ", " + z)); - else playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Unlinked " + x + ", " + y + ", " + z)); + if(te.addOrRemoveTarget(new BlockPos(x, y, z))) + { + playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Linked to " + x + ", " + y + ", " + z)); + ModTriggers.LINK_MANA_RELAY.trigger((EntityPlayerMP) playerIn); + } + else + playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Unlinked " + x + ", " + y + ", " + z)); } else { compound.setInteger("x", pos.getX()); diff --git a/src/main/java/com/fi0x/deepmagic/blocks/mana/tile/TileEntityManaBattery.java b/src/main/java/com/fi0x/deepmagic/blocks/mana/tile/TileEntityManaBattery.java new file mode 100644 index 00000000..76a52295 --- /dev/null +++ b/src/main/java/com/fi0x/deepmagic/blocks/mana/tile/TileEntityManaBattery.java @@ -0,0 +1,141 @@ +package com.fi0x.deepmagic.blocks.mana.tile; + +import com.fi0x.deepmagic.util.IManaTileEntity; +import com.fi0x.deepmagic.util.handlers.ConfigHandler; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ITickable; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.util.Constants; + +import javax.annotation.Nonnull; +import java.util.ArrayList; + +public class TileEntityManaBattery extends TileEntity implements IManaTileEntity, ITickable +{ + private boolean isCreative = false; + private final ArrayList manaTargets = new ArrayList<>(); + private double storedMana; + + @Nonnull + @Override + public NBTTagCompound writeToNBT(@Nonnull NBTTagCompound compound) + { + compound.setBoolean("isCreative", isCreative); + + NBTTagList targets = new NBTTagList(); + for(BlockPos pos : manaTargets) + { + NBTTagCompound position = new NBTTagCompound(); + position.setInteger("x", pos.getX()); + position.setInteger("y", pos.getY()); + position.setInteger("z", pos.getZ()); + targets.appendTag(position); + } + compound.setTag("targets", targets); + + compound.setDouble("stored", storedMana); + + return super.writeToNBT(compound); + } + @Override + public void readFromNBT(NBTTagCompound compound) + { + isCreative = compound.getBoolean("isCreative"); + + manaTargets.clear(); + NBTTagList targetList = compound.getTagList("targets", Constants.NBT.TAG_COMPOUND); + for(int i = 0; i < targetList.tagCount(); i++) + { + NBTTagCompound position = targetList.getCompoundTagAt(i); + int x = position.getInteger("x"); + int y = position.getInteger("y"); + int z = position.getInteger("z"); + manaTargets.add(new BlockPos(x, y, z)); + } + + storedMana = compound.getDouble("stored"); + + super.readFromNBT(compound); + } + + @Override + public void update() + { + if(world.isRemote) return; + boolean dirty = false; + + if(isCreative || storedMana >= 100) + { + for(int i = 0; i < manaTargets.size(); i++) + { + if(manaTargets.get(i) == null) + { + manaTargets.remove(i); + i--; + continue; + } + TileEntity te = world.getTileEntity(manaTargets.get(i)); + int remainingTargets = manaTargets.size() - i; + storedMana -= ManaHelper.sendMana(world, manaTargets.get(i), te, storedMana / remainingTargets); + dirty = true; + } + } + if(dirty) + markDirty(); + } + public boolean addOrRemoveTarget(BlockPos pos) + { + if(this.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > ConfigHandler.manaBlockTransferRange * ConfigHandler.manaBlockTransferRange) + { + manaTargets.remove(pos); + return false; + } + if(manaTargets.remove(pos)) return false; + if(this.pos == pos) return false; + manaTargets.add(pos); + return true; + } + public boolean hasTargets() + { + return !manaTargets.isEmpty(); + } + public String getStoredMana() + { + return isCreative ? "Infinite" : "" + storedMana; + } + public void makeCreative() + { + isCreative = true; + markDirty(); + } + public boolean isCreative() + { + return isCreative; + } + @Override + public double getSpaceForMana() + { + if(isCreative) + return ConfigHandler.manaBatteryCapacity; + else + return ConfigHandler.manaBatteryCapacity - storedMana; + } + @Override + public double addManaToStorage(double amount) + { + if(isCreative) + return 0; + else + { + double ret = amount - (ConfigHandler.manaBatteryCapacity - storedMana); + if(ret > 0) + storedMana = ConfigHandler.manaBatteryCapacity; + else + storedMana += amount; + markDirty(); + return ret > 0 ? ret : 0; + } + } +} diff --git a/src/main/java/com/fi0x/deepmagic/blocks/mana/tile/TileEntitySpellStone.java b/src/main/java/com/fi0x/deepmagic/blocks/mana/tile/TileEntitySpellStone.java index 94c9bc37..66b623eb 100644 --- a/src/main/java/com/fi0x/deepmagic/blocks/mana/tile/TileEntitySpellStone.java +++ b/src/main/java/com/fi0x/deepmagic/blocks/mana/tile/TileEntitySpellStone.java @@ -19,8 +19,6 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import javax.annotation.Nonnull; import java.util.ArrayList; @@ -41,7 +39,6 @@ public class TileEntitySpellStone extends TileEntity implements IInventory, ITic private ArrayList partNames = new ArrayList<>(); private String currentPartName = ""; - @SideOnly(Side.CLIENT) private int sync = 0; private int manaAdder; @@ -110,8 +107,8 @@ public void update() sync = 10; PacketHandler.INSTANCE.sendToServer(new PacketGetSpellStone(world.provider.getDimension(), pos)); ISpellPart currentPart = verifier.getPartFromItems(); - if(currentPart != null) currentPartName = currentPart.getDisplayName(); - else currentPartName = ""; + if(currentPart != null) currentPartName = currentPart.getDisplayName();//TODO: Find out why this is no longer working + else currentPartName = "Unknown"; } } diff --git a/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/QuarryHelper.java b/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/QuarryHelper.java index d401b44e..a630b644 100644 --- a/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/QuarryHelper.java +++ b/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/QuarryHelper.java @@ -1,12 +1,25 @@ package com.fi0x.deepmagic.blocks.rituals.tile; import com.fi0x.deepmagic.blocks.rituals.structureblocks.RitualStructure; +import com.fi0x.deepmagic.init.ModBlocks; import com.fi0x.deepmagic.world.StructureChecker; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import java.util.ArrayList; + public class QuarryHelper { + public static final ArrayList blacklistedBlocks = new ArrayList<>(); + + static + { + blacklistedBlocks.add(ModBlocks.RITUAL_STRUCTURE); + blacklistedBlocks.add(Blocks.BEDROCK); + } + public static BlockPos getRandomFilledStructurePos(World world, BlockPos center) { for(BlockPos offset : StructureChecker.ritualFloorLocations) @@ -31,4 +44,9 @@ public static BlockPos getRandomFreeStructurePos(World world, BlockPos center) } return null; } + + public static boolean isBlacklistedBlock(World world, BlockPos pos) + { + return blacklistedBlocks.contains(world.getBlockState(pos).getBlock()); + } } diff --git a/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/TileEntityRitualQuarry.java b/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/TileEntityRitualQuarry.java index 8e79fe88..efbed0a9 100644 --- a/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/TileEntityRitualQuarry.java +++ b/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/TileEntityRitualQuarry.java @@ -25,14 +25,14 @@ public class TileEntityRitualQuarry extends TileEntityRitualStone { - private int digX; - private int digY; - private int digZ; - private int currentDigRadius; - private int maxDigRadius; + private int digX = 0; + private int digY = -2; + private int digZ = 0; + private int currentDigRadius = 0; + private int maxDigRadius = 4; private EnumFacing direction; - private STATUS currentState; + private STATUS currentState = STATUS.DIG; private int[] structureBlocks; public TileEntityRitualQuarry() @@ -76,42 +76,59 @@ public void readFromNBT(NBTTagCompound compound) } @Override - public String getPacketData() + public String getPacketData()//TODO: Find out why so many packets are sent { StringBuilder packetString = new StringBuilder(); - packetString.append(digX).append("-"); - packetString.append(digY).append("-"); - packetString.append(digZ).append("-"); - packetString.append(currentDigRadius).append("-"); - packetString.append(maxDigRadius).append("-"); - packetString.append(direction.ordinal()).append("-"); + packetString.append(digX).append("###"); + packetString.append(digY).append("###"); + packetString.append(digZ).append("###"); + packetString.append(currentDigRadius).append("###"); + packetString.append(maxDigRadius).append("###"); + packetString.append(direction.ordinal()).append("###"); packetString.append(currentState.ordinal()); for (int structureBlock : structureBlocks) { - packetString.append("-"); + packetString.append("###"); packetString.append(structureBlock); } - return packetString.toString(); } @Override public void setDataFromPacket(String data) { - String[] packetData = data.split("-"); + String[] packetData = data.split("###"); - digX = Integer.parseInt(packetData[0]); - digY = Integer.parseInt(packetData[1]); - digZ = Integer.parseInt(packetData[2]); - currentDigRadius = Integer.parseInt(packetData[3]); - maxDigRadius = Integer.parseInt(packetData[4]); - direction = EnumFacing.values()[Integer.parseInt(packetData[5])]; - currentState = STATUS.values()[Integer.parseInt(packetData[6])]; + if(!packetData[0].equals("")) + digX = Integer.parseInt(packetData[0]); + if(!packetData[1].equals("")) + digY = Integer.parseInt(packetData[1]); + if(!packetData[2].equals("")) + digZ = Integer.parseInt(packetData[2]); + if(!packetData[3].equals("")) + currentDigRadius = Integer.parseInt(packetData[3]); + if(!packetData[4].equals("")) + maxDigRadius = Integer.parseInt(packetData[4]); + if(!packetData[5].equals("")) + try + { + direction = EnumFacing.values()[Integer.parseInt(packetData[5])]; + } catch(IndexOutOfBoundsException ignored) + { + } + if(!packetData[6].equals("")) + try + { + currentState = STATUS.values()[Integer.parseInt(packetData[6])]; + } catch(IndexOutOfBoundsException ignored) + { + } - for (int i = 0; i < structureBlocks.length; i++) + for (int i = 0; i < packetData.length - 7 && i < structureBlocks.length; i++) { - structureBlocks[i] = Integer.parseInt(packetData[i + 7]); + if(!packetData[i + 7].equals("")) + structureBlocks[i] = Integer.parseInt(packetData[i + 7]); } } @@ -120,9 +137,9 @@ public void syncedUpdate() { if(digY == -100) { - digX = pos.getX(); - digY = pos.getY() - 2; - digZ = pos.getZ(); + digX = 0; + digY = -2; + digZ = 0; } if(!world.isRemote) { @@ -131,23 +148,27 @@ public void syncedUpdate() case DIG: if(setNextBlock()) { - if(!digNextBlock(new BlockPos(digX, digY, digZ))) sync *= 4; + if(!digNextBlock(new BlockPos(pos.getX() + digX, pos.getY() + digY, pos.getZ() + digZ))) sync *= 4; } else { currentState = STATUS.PACK; + needsStructure = false; markDirty(); } break; case PACK: + needsStructure = false; if(!packNextBlock()) currentState = STATUS.MOVE; markDirty(); break; case MOVE: + needsStructure = false; if(!move()) currentState = STATUS.UNPACK; markDirty(); break; case UNPACK: + needsStructure = false; if(!unpackNextBlock()) setReady(); markDirty(); break; @@ -170,35 +191,36 @@ private void setReady() maxDigRadius = 4; currentState = STATUS.DIG; structureBlocks = new int[1]; + needsStructure = true; } private boolean setNextBlock() { - while(digY <= 0 - || world.isAirBlock(new BlockPos(digX, digY, digZ)) - || world.getBlockState(new BlockPos(digX, digY, digZ)).getBlock() == Blocks.BEDROCK - || world.containsAnyLiquid(new AxisAlignedBB(digX, digY, digZ, digX + 1, digY + 1, digZ + 1))) + while(pos.getY() + digY <= 0 + || world.isAirBlock(new BlockPos(pos.getX() + digX, pos.getY() + digY, pos.getZ() + digZ)) + || QuarryHelper.isBlacklistedBlock(world, new BlockPos(pos.getX() + digX, pos.getY() + digY, pos.getZ() + digZ)) + || world.containsAnyLiquid(new AxisAlignedBB(pos.getX() + digX, pos.getY() + digY, pos.getZ() + digZ, pos.getX() + digX + 1, pos.getY() + digY + 1, pos.getZ() + digZ + 1))) { digY--; - if(digY > 0) continue; + if(pos.getY() + digY > 0) continue; - digY = pos.getY() - 2 - currentDigRadius; + digY = - 2 - currentDigRadius; - if(digX != pos.getX() + currentDigRadius) digX++; - else if(digZ != pos.getZ() + currentDigRadius) + if(digX != currentDigRadius) digX++; + else if(digZ != currentDigRadius) { digZ++; - digX = pos.getX() - currentDigRadius; + digX = -currentDigRadius; } else if(currentDigRadius < maxDigRadius) { currentDigRadius++; - digX = pos.getX() - currentDigRadius; - digZ = pos.getZ() - currentDigRadius; + digX = -currentDigRadius; + digZ = -currentDigRadius; digY--; } else return false; - if(digX != pos.getX() - currentDigRadius && digX != pos.getX() + currentDigRadius && digZ != pos.getZ() - currentDigRadius && digZ != pos.getZ() + currentDigRadius) + if(digX != -currentDigRadius && digX != currentDigRadius && digZ != -currentDigRadius && digZ != currentDigRadius) { - while(digX < pos.getX() + currentDigRadius) + while(digX < currentDigRadius) { digX++; } @@ -208,13 +230,16 @@ else if(digZ != pos.getZ() + currentDigRadius) } private boolean digNextBlock(BlockPos position) { + if(QuarryHelper.isBlacklistedBlock(world, position)) + return true; + Block block = world.getBlockState(position).getBlock(); Item droppedItem = block.getItemDropped(world.getBlockState(position), world.rand, 0); int quantity = block.quantityDropped(world.rand); int itemMeta = block.damageDropped(world.getBlockState(position)); ItemStack stack = new ItemStack(droppedItem, quantity, itemMeta); - world.setBlockToAir(new BlockPos(digX, digY, digZ)); + world.setBlockToAir(new BlockPos(pos.getX() + digX, pos.getY() + digY, pos.getZ() + digZ)); if(stack.isEmpty()) return true; TileEntity storage = world.getTileEntity(pos.up()); diff --git a/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/TileEntityRitualStone.java b/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/TileEntityRitualStone.java index 371ef9c5..206ed6ff 100644 --- a/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/TileEntityRitualStone.java +++ b/src/main/java/com/fi0x/deepmagic/blocks/rituals/tile/TileEntityRitualStone.java @@ -24,6 +24,7 @@ public abstract class TileEntityRitualStone extends TileEntity implements ITicka protected int syncTime = 20; protected boolean manaOnSync = true; protected boolean needsRedstone = true; + protected boolean needsStructure = true; @Nonnull @Override @@ -36,6 +37,7 @@ public NBTTagCompound writeToNBT(@Nonnull NBTTagCompound compound) compound.setInteger("syncTime", syncTime); compound.setBoolean("manaOnSync", manaOnSync); compound.setBoolean("redstoneMode", needsRedstone); + compound.setBoolean("structureRequired", needsStructure); return super.writeToNBT(compound); } @@ -49,6 +51,7 @@ public void readFromNBT(NBTTagCompound compound) syncTime = compound.getInteger("syncTime"); manaOnSync = compound.getBoolean("manaOnSync"); needsRedstone = compound.getBoolean("redstoneMode"); + needsStructure = compound.getBoolean("structureRequired"); super.readFromNBT(compound); } @@ -64,7 +67,7 @@ public void update() if(!needsRedstone || hasRedstonePower()) { - if(StructureChecker.verifyRitualStructure(world, pos, type)) + if(!needsStructure || StructureChecker.verifyRitualStructure(world, pos, type)) { if(manaOnSync) { diff --git a/src/main/java/com/fi0x/deepmagic/entities/ai/EntityAIRandomFly.java b/src/main/java/com/fi0x/deepmagic/entities/ai/EntityAIRandomFly.java index 6503b5f6..3c55ef3c 100644 --- a/src/main/java/com/fi0x/deepmagic/entities/ai/EntityAIRandomFly.java +++ b/src/main/java/com/fi0x/deepmagic/entities/ai/EntityAIRandomFly.java @@ -1,10 +1,13 @@ package com.fi0x.deepmagic.entities.ai; +import com.fi0x.deepmagic.entities.ai.navigation.CustomPositionGenerator; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIWanderAvoidWater; import net.minecraft.util.math.Vec3d; +import javax.annotation.Nullable; + public class EntityAIRandomFly extends EntityAIWanderAvoidWater { private final EntityLiving entity; @@ -22,12 +25,16 @@ public boolean shouldExecute() { if (!this.mustUpdate) { - if (this.entity.getIdleTime() >= 100) return false; - if (this.entity.getRNG().nextInt(this.executionChance) != 0) return false; + if (this.entity.getIdleTime() >= 100) + return false; + + if (this.entity.getRNG().nextInt(this.executionChance) != 0) + return false; } Vec3d vec3d = this.getPosition(); - if (vec3d == null) return false; + if (vec3d == null) + return false; else { this.x = vec3d.x; @@ -47,7 +54,15 @@ public void startExecuting() @Override public boolean shouldContinueExecuting() { - entity.motionY *= -1; return !entity.getNavigator().noPath(); } + + @Nullable + @Override + protected Vec3d getPosition() + { + return this.entity.getRNG().nextFloat() >= this.probability + ? CustomPositionGenerator.getLandPos((EntityCreature) this.entity, 10, 7) + : CustomPositionGenerator.findRandomTarget((EntityCreature) this.entity, 10, 7); + } } \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/entities/ai/FlightNavigator.java b/src/main/java/com/fi0x/deepmagic/entities/ai/FlightNavigator.java deleted file mode 100644 index 689aa8f3..00000000 --- a/src/main/java/com/fi0x/deepmagic/entities/ai/FlightNavigator.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.fi0x.deepmagic.entities.ai; - -import net.minecraft.entity.EntityLiving; -import net.minecraft.pathfinding.PathFinder; -import net.minecraft.pathfinding.PathNavigateFlying; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -public class FlightNavigator extends PathNavigateFlying -{ - public FlightNavigator(EntityLiving entityIn, World worldIn) - { - super(entityIn, worldIn); - } - - @Override - protected PathFinder getPathFinder() - { - return null; - } - @Override - protected Vec3d getEntityPosition() - { - return null; - } - @Override - protected boolean canNavigate() - { - return false; - } - @Override - protected boolean isDirectPathBetweenPoints(Vec3d posVec31, Vec3d posVec32, int sizeX, int sizeY, int sizeZ) - { - return false; - } -} \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/entities/ai/helper/AIHelperSearchMines.java b/src/main/java/com/fi0x/deepmagic/entities/ai/helper/AIHelperSearchMines.java index 8cba66b8..ae87466c 100644 --- a/src/main/java/com/fi0x/deepmagic/entities/ai/helper/AIHelperSearchMines.java +++ b/src/main/java/com/fi0x/deepmagic/entities/ai/helper/AIHelperSearchMines.java @@ -97,7 +97,7 @@ public static BlockPos findMiningStartPosition(World world, EntityAIMining ai) { int idx = (int) (Math.random() * checkBlocks.size()); BlockPos pos = checkBlocks.get(idx); - if(ConfigHandler.showAISearchParticles) ParticleSpawner.spawnParticle(ParticleEnum.DWARF_SEARCH_MINE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + if(ConfigHandler.showAISearchParticles && world.isRemote) ParticleSpawner.spawnParticle(ParticleEnum.DWARF_SEARCH_MINE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); if((pos.getY() - ai.entity.homePos.getY()) % 3 == 0) { diff --git a/src/main/java/com/fi0x/deepmagic/entities/ai/helper/CustomFlyHelper.java b/src/main/java/com/fi0x/deepmagic/entities/ai/helper/CustomFlyHelper.java new file mode 100644 index 00000000..3e70ea5a --- /dev/null +++ b/src/main/java/com/fi0x/deepmagic/entities/ai/helper/CustomFlyHelper.java @@ -0,0 +1,57 @@ +package com.fi0x.deepmagic.entities.ai.helper; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityFlyHelper; +import net.minecraft.entity.ai.EntityMoveHelper; +import net.minecraft.util.math.MathHelper; + +public class CustomFlyHelper extends EntityFlyHelper +{ + public CustomFlyHelper(EntityLiving p_i47418_1_) + { + super(p_i47418_1_); + } + + @Override + public void onUpdateMoveHelper() + { + if(this.action == EntityMoveHelper.Action.MOVE_TO) + { + this.action = EntityMoveHelper.Action.WAIT; + this.entity.setNoGravity(true); + double d0 = this.posX - this.entity.posX; + double d1 = this.posY - this.entity.posY; + double d2 = this.posZ - this.entity.posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + if(d3 < 2.500000277905201E-7D) + { + this.entity.setMoveVertical(0.0F); + this.entity.setMoveForward(0.0F); + return; + } + + float f = (float) (MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F; + this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, f, 10.0F); + float f1; + + if(this.entity.onGround) + f1 = (float) (this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue()); + else + f1 = (float) (this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.FLYING_SPEED).getAttributeValue()); + + + this.entity.setAIMoveSpeed(f1); + double d4 = MathHelper.sqrt(d0 * d0 + d2 * d2); + float f2 = (float) (-(MathHelper.atan2(d1, d4) * (180D / Math.PI))); + this.entity.rotationPitch = this.limitAngle(this.entity.rotationPitch, f2, 10.0F); + this.entity.setMoveVertical(d1 > 0.0D ? f1 : -f1); + } else + { + this.entity.setNoGravity(false); + this.entity.setMoveVertical(0.0F); + this.entity.setMoveForward(0.0F); + } + } +} diff --git a/src/main/java/com/fi0x/deepmagic/entities/ai/navigation/CustomPositionGenerator.java b/src/main/java/com/fi0x/deepmagic/entities/ai/navigation/CustomPositionGenerator.java new file mode 100644 index 00000000..528cfa48 --- /dev/null +++ b/src/main/java/com/fi0x/deepmagic/entities/ai/navigation/CustomPositionGenerator.java @@ -0,0 +1,139 @@ +package com.fi0x.deepmagic.entities.ai.navigation; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityCreature; +import net.minecraft.pathfinding.PathNavigate; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +import javax.annotation.Nullable; +import java.util.Random; + +public class CustomPositionGenerator +{ + @Nullable + public static Vec3d findRandomTarget(EntityCreature entityCreatureIn, int xz, int y) + { + return generateRandomPos(entityCreatureIn, xz, y, true); + } + + @Nullable + public static Vec3d getLandPos(EntityCreature entity, int xz, int y) + { + return generateRandomPos(entity, xz, y, false); + } + + @Nullable + private static Vec3d generateRandomPos(EntityCreature entity, int xz, int y, boolean allowWater) + { + PathNavigate entityNavigator = entity.getNavigator(); + Random random = entity.getRNG(); + boolean shouldReturnHome; + + if(entity.hasHome()) + { + double d0 = entity.getHomePosition().distanceSq(MathHelper.floor(entity.posX), MathHelper.floor(entity.posY), MathHelper.floor(entity.posZ)) + 4.0D; + double d1 = entity.getMaximumHomeDistance() + (float) xz; + shouldReturnHome = d0 < d1 * d1; + } else + shouldReturnHome = false; + + boolean flag1 = false; + float f = -99999.0F; + int xOffset = 0; + int yOffset = 0; + int zOffset = 0; + + for(int i = 0; i < 10; i++) + { + int xAdd = random.nextInt(2 * xz + 1) - xz; + int yAdd = random.nextInt(2 * y + 1) - y; + int zAdd = random.nextInt(2 * xz + 1) - xz; + + if(entity.hasHome() && xz > 1) + { + BlockPos blockpos = entity.getHomePosition(); + + if(entity.posX > (double) blockpos.getX()) + xAdd -= random.nextInt(xz / 2); + else + xAdd += random.nextInt(xz / 2); + + if(entity.posZ > (double) blockpos.getZ()) + zAdd -= random.nextInt(xz / 2); + else + zAdd += random.nextInt(xz / 2); + } + + BlockPos possibleDestination = new BlockPos((double) xAdd + entity.posX, (double) yAdd + entity.posY, (double) zAdd + entity.posZ); + + if((!shouldReturnHome || entity.isWithinHomeDistanceFromPosition(possibleDestination)) && entityNavigator.canEntityStandOnPos(possibleDestination)) + { + if(!allowWater) + { + possibleDestination = moveAboveSolid(possibleDestination, entity); + if(isWaterDestination(possibleDestination, entity)) + continue; + } + + float f1 = entity.getBlockPathWeight(possibleDestination); + + if(f1 > f) + { + f = f1; + xOffset = xAdd; + yOffset = yAdd; + zOffset = zAdd; + flag1 = true; + } + } + } + + if(flag1) + { + int groundDistance = getDistanceToGround(entity.world, new BlockPos(xOffset + entity.posX, yOffset + entity.posY, zOffset + entity.posZ)); + if(groundDistance > 5) + yOffset -= (groundDistance - 2); + else if(groundDistance < 1) + yOffset++; + return new Vec3d((double) xOffset + entity.posX, (double) yOffset + entity.posY, (double) zOffset + entity.posZ); + } + else + return null; + } + + private static BlockPos moveAboveSolid(BlockPos blockPos, EntityCreature entity) + { + if(!entity.world.getBlockState(blockPos).getMaterial().isSolid()) + return blockPos; + else + { + BlockPos destinationPos = blockPos.up(); + + while(destinationPos.getY() < entity.world.getHeight() && entity.world.getBlockState(destinationPos).getMaterial().isSolid()) + destinationPos = destinationPos.up(); + + return destinationPos; + } + } + + private static boolean isWaterDestination(BlockPos blockPos, EntityCreature entity) + { + return entity.world.getBlockState(blockPos).getMaterial() == Material.WATER; + } + + private static int getDistanceToGround(World world, BlockPos position) + { + int distanceCounter = 0; + BlockPos groundSearch = position; + while(groundSearch.getY() > 0 && !world.getBlockState(groundSearch).getMaterial().isSolid()) + { + groundSearch = groundSearch.down(); + distanceCounter++; + } + + return distanceCounter; + } +} diff --git a/src/main/java/com/fi0x/deepmagic/entities/ai/navigation/FlightNavigator.java b/src/main/java/com/fi0x/deepmagic/entities/ai/navigation/FlightNavigator.java new file mode 100644 index 00000000..920c1559 --- /dev/null +++ b/src/main/java/com/fi0x/deepmagic/entities/ai/navigation/FlightNavigator.java @@ -0,0 +1,76 @@ +package com.fi0x.deepmagic.entities.ai.navigation; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.pathfinding.FlyingNodeProcessor; +import net.minecraft.pathfinding.PathFinder; +import net.minecraft.pathfinding.PathNavigateFlying; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +import javax.annotation.Nonnull; + +public class FlightNavigator extends PathNavigateFlying +{ + public FlightNavigator(EntityLiving entityIn, World worldIn) + { + super(entityIn, worldIn); + } + + @Nonnull + @Override + protected PathFinder getPathFinder() + { + this.nodeProcessor = new FlyingNodeProcessor(); + this.nodeProcessor.setCanEnterDoors(true); + return new PathFinder(this.nodeProcessor); + } + @Override + protected boolean canNavigate() + { + return true; + } + @Override + protected boolean isDirectPathBetweenPoints(@Nonnull Vec3d posVec31, @Nonnull Vec3d posVec32, int sizeX, int sizeY, int sizeZ) + { + return super.isDirectPathBetweenPoints(posVec31, posVec32, sizeX, sizeY, sizeZ); + } + + @Override + public boolean canEntityStandOnPos(BlockPos pos) + { + return true; + } + + @Override + public void onUpdateNavigation() + { + this.totalTicks++; + + if (this.tryUpdatePath) + this.updatePath(); + + if (!this.noPath()) + { + if (this.canNavigate()) + this.pathFollow(); + else if (this.currentPath != null && this.currentPath.getCurrentPathIndex() < this.currentPath.getCurrentPathLength()) + { + Vec3d vec3d = this.currentPath.getVectorFromIndex(this.entity, this.currentPath.getCurrentPathIndex()); + + if (MathHelper.floor(this.entity.posX) == MathHelper.floor(vec3d.x) && MathHelper.floor(this.entity.posY) == MathHelper.floor(vec3d.y) && MathHelper.floor(this.entity.posZ) == MathHelper.floor(vec3d.z)) + this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1); + + } + + this.debugPathFinding(); + + if (!this.noPath()) + { + Vec3d vec3d1 = this.currentPath.getPosition(this.entity); + this.entity.getMoveHelper().setMoveTo(vec3d1.x, vec3d1.y, vec3d1.z, this.speed); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/entities/ai/navigation/FlightPathFinder.java b/src/main/java/com/fi0x/deepmagic/entities/ai/navigation/FlightPathFinder.java new file mode 100644 index 00000000..28656e02 --- /dev/null +++ b/src/main/java/com/fi0x/deepmagic/entities/ai/navigation/FlightPathFinder.java @@ -0,0 +1,26 @@ +package com.fi0x.deepmagic.entities.ai.navigation; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.pathfinding.NodeProcessor; +import net.minecraft.pathfinding.Path; +import net.minecraft.pathfinding.PathFinder; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class FlightPathFinder extends PathFinder +{ + public FlightPathFinder(NodeProcessor processor) + { + super(processor); + } + + @Nullable + @Override + public Path findPath(@Nonnull IBlockAccess worldIn, @Nonnull EntityLiving entityLivingIn, @Nonnull BlockPos targetPos, float maxDistance) + { + return super.findPath(worldIn, entityLivingIn, targetPos, maxDistance); + } +} \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/entities/mobs/EntityDepthMage.java b/src/main/java/com/fi0x/deepmagic/entities/mobs/EntityDepthMage.java index 0a652521..5d7bb8ab 100644 --- a/src/main/java/com/fi0x/deepmagic/entities/mobs/EntityDepthMage.java +++ b/src/main/java/com/fi0x/deepmagic/entities/mobs/EntityDepthMage.java @@ -51,7 +51,8 @@ protected void initEntityAI() this.tasks.addTask(5, new EntityAILookIdle(this)); this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, false)); - this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityMob.class, false)); + if(ConfigHandler.npcRaceCombat) + this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityMob.class, false)); } @Override diff --git a/src/main/java/com/fi0x/deepmagic/entities/mobs/EntityHoveringOrb.java b/src/main/java/com/fi0x/deepmagic/entities/mobs/EntityHoveringOrb.java index 2e3160ec..e2be8c4b 100644 --- a/src/main/java/com/fi0x/deepmagic/entities/mobs/EntityHoveringOrb.java +++ b/src/main/java/com/fi0x/deepmagic/entities/mobs/EntityHoveringOrb.java @@ -1,11 +1,15 @@ package com.fi0x.deepmagic.entities.mobs; import com.fi0x.deepmagic.entities.ai.EntityAIRandomFly; +import com.fi0x.deepmagic.entities.ai.helper.CustomFlyHelper; +import com.fi0x.deepmagic.entities.ai.navigation.FlightNavigator; import com.fi0x.deepmagic.util.IMagicCreature; import com.fi0x.deepmagic.util.handlers.ConfigHandler; import com.fi0x.deepmagic.util.handlers.LootTableHandler; import com.fi0x.deepmagic.util.handlers.SoundsHandler; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.MoverType; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackMelee; import net.minecraft.entity.ai.EntityAIHurtByTarget; @@ -18,6 +22,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -30,6 +35,7 @@ public EntityHoveringOrb(World worldIn) super(worldIn); setSize(1F, 1F); this.isImmuneToFire = true; + this.moveHelper = new CustomFlyHelper(this); } @Override @@ -46,8 +52,11 @@ protected void initEntityAI() protected void applyEntityAttributes() { super.applyEntityAttributes(); + getAttributeMap().registerAttribute(SharedMonsterAttributes.FLYING_SPEED); + getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(ConfigHandler.healthHoveringOrb); getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.27); + getEntityAttribute(SharedMonsterAttributes.FLYING_SPEED).setBaseValue(0.4); getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(32.0D); getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(10.0D); getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.1); @@ -58,7 +67,7 @@ protected void applyEntityAttributes() @Override protected PathNavigate createNavigator(@Nonnull World worldIn) { - return super.createNavigator(worldIn); + return new FlightNavigator(this, worldIn); } @Override @@ -97,4 +106,83 @@ protected ResourceLocation getLootTable() { return LootTableHandler.HOVERING_ORB; } +// @Override +// public void onUpdate() +// { +// super.onUpdate(); +// this.motionY *= 0.6000000238418579D; +// } + @Override + public boolean doesEntityNotTriggerPressurePlate() + { + return true; + } + @Override + public void fall(float distance, float damageMultiplier) + { + } + @Override + protected void updateFallState(double y, boolean onGroundIn, @Nonnull IBlockState state, @Nonnull BlockPos pos) + { + } + @Override + public void travel(float strafe, float vertical, float forward) + { + if (this.isInWater()) + { + this.moveRelative(strafe, vertical, forward, 0.02F); + this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.800000011920929D; + this.motionY *= 0.800000011920929D; + this.motionZ *= 0.800000011920929D; + } + else if (this.isInLava()) + { + this.moveRelative(strafe, vertical, forward, 0.02F); + this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + } + else + { + float f = 0.91F; + + if (this.onGround) + { + BlockPos underPos = new BlockPos(MathHelper.floor(this.posX), MathHelper.floor(this.getEntityBoundingBox().minY) - 1, MathHelper.floor(this.posZ)); + IBlockState underState = this.world.getBlockState(underPos); + f = underState.getBlock().getSlipperiness(underState, this.world, underPos, this) * 0.91F; + } + + float f1 = 0.16277136F / (f * f * f); + this.moveRelative(strafe, vertical, forward, this.onGround ? 0.1F * f1 : 0.02F); + f = 0.91F; + + if (this.onGround) + { + BlockPos underPos = new BlockPos(MathHelper.floor(this.posX), MathHelper.floor(this.getEntityBoundingBox().minY) - 1, MathHelper.floor(this.posZ)); + IBlockState underState = this.world.getBlockState(underPos); + f = underState.getBlock().getSlipperiness(underState, this.world, underPos, this) * 0.91F; + } + + this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); + this.motionX *= f; + this.motionY *= f; + this.motionZ *= f; + } + + this.prevLimbSwingAmount = this.limbSwingAmount; + double d1 = this.posX - this.prevPosX; + double d0 = this.posZ - this.prevPosZ; + float f2 = MathHelper.sqrt(d1 * d1 + d0 * d0) * 4.0F; + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + this.limbSwingAmount += (f2 - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; + } } \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/entities/projectiles/EntitySpellProjectile.java b/src/main/java/com/fi0x/deepmagic/entities/projectiles/EntitySpellProjectile.java index 8726f1dd..488f070f 100644 --- a/src/main/java/com/fi0x/deepmagic/entities/projectiles/EntitySpellProjectile.java +++ b/src/main/java/com/fi0x/deepmagic/entities/projectiles/EntitySpellProjectile.java @@ -49,11 +49,13 @@ public void onUpdate() super.onUpdate(); if(ticksExisted > 20 * existingSeconds) setDead(); - double xOff = Math.random() - 0.5; - double yOff = Math.random() - 0.5; - double zOff = Math.random() - 0.5; - ParticleSpawner.spawnParticle(ParticleEnum.SPELL_PROJECTILE, posX + xOff, posY + yOff, posZ + zOff, 0, 0, 0, Math.random() + 0.5, false, 64); - + if(world.isRemote) + { + double xOff = Math.random() - 0.5; + double yOff = Math.random() - 0.5; + double zOff = Math.random() - 0.5; + ParticleSpawner.spawnParticle(ParticleEnum.SPELL_PROJECTILE, posX + xOff, posY + yOff, posZ + zOff, 0, 0, 0, Math.random() + 0.5, false, 64); + } } @Override protected void onImpact(@Nonnull RayTraceResult result) diff --git a/src/main/java/com/fi0x/deepmagic/init/ModBlocks.java b/src/main/java/com/fi0x/deepmagic/init/ModBlocks.java index 6fb12a83..649c63bc 100644 --- a/src/main/java/com/fi0x/deepmagic/init/ModBlocks.java +++ b/src/main/java/com/fi0x/deepmagic/init/ModBlocks.java @@ -156,6 +156,7 @@ public class ModBlocks //Mana System Blocks public static final ManaAltar MANA_ALTAR = new ManaAltar("mana_altar", Material.ROCK); public static final ManaRelay MANA_RELAY = new ManaRelay("mana_relay", Material.ROCK); + public static final ManaBattery MANA_BATTERY = new ManaBattery("mana_battery_block", Material.ROCK); public static final ManaGeneratorNormal MANA_GENERATOR_NORMAL = new ManaGeneratorNormal("mana_generator_normal", Material.ROCK); public static final ManaGeneratorInsanity MANA_GENERATOR_INSANITY = new ManaGeneratorInsanity("mana_generator_insanity", Material.ROCK); public static final ManaGeneratorMob MANA_GENERATOR_MOB = new ManaGeneratorMob("mana_generator_mob", Material.ROCK); diff --git a/src/main/java/com/fi0x/deepmagic/items/spells/Spell.java b/src/main/java/com/fi0x/deepmagic/items/spells/Spell.java index 4b4b097a..0339a1cb 100644 --- a/src/main/java/com/fi0x/deepmagic/items/spells/Spell.java +++ b/src/main/java/com/fi0x/deepmagic/items/spells/Spell.java @@ -1,5 +1,6 @@ package com.fi0x.deepmagic.items.spells; +import com.fi0x.deepmagic.advancements.ModTriggers; import com.fi0x.deepmagic.blocks.mana.SpellStone; import com.fi0x.deepmagic.init.DeepMagicTab; import com.fi0x.deepmagic.items.ItemBase; @@ -13,6 +14,7 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ActionResult; @@ -71,6 +73,8 @@ public ActionResult onItemRightClick(World worldIn, @Nonnull EntityPl if(compound.hasKey("skillXP")) playerMana.addSkillXP(playerIn, compound.getDouble("skillXP")); + ModTriggers.RIGHT_CLICK_SPELL.trigger((EntityPlayerMP) playerIn); + return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } diff --git a/src/main/java/com/fi0x/deepmagic/mana/player/PlayerPropertyEvents.java b/src/main/java/com/fi0x/deepmagic/mana/player/PlayerPropertyEvents.java index ddb6a880..9a1d9f2f 100644 --- a/src/main/java/com/fi0x/deepmagic/mana/player/PlayerPropertyEvents.java +++ b/src/main/java/com/fi0x/deepmagic/mana/player/PlayerPropertyEvents.java @@ -14,11 +14,12 @@ import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.relauncher.Side; public class PlayerPropertyEvents { public static PlayerPropertyEvents instance = new PlayerPropertyEvents(); - private static int sync = 0; + private static int playerSync = 0; @SubscribeEvent public void onEntityConstructing(AttachCapabilitiesEvent event) @@ -43,7 +44,8 @@ public void onPlayerCloned(PlayerEvent.Clone event) assert oldStore != null; newStore.copyFrom(oldStore); newStore.updatePlayerHP(event.getEntityPlayer()); - PacketHandler.INSTANCE.sendToServer(new PacketGetSkill(event.getEntityPlayer().getName(), newStore.getMaxMana(), newStore.getSkillXP(), newStore.getSkillpoints(), newStore.getManaRegenRate(), newStore.getManaEfficiencyValue(), newStore.addedHP, newStore.hpRegeneration, newStore.getSpellTier())); + if(event.getEntityPlayer().world.isRemote) + PacketHandler.INSTANCE.sendToServer(new PacketGetSkill(event.getEntityPlayer().getName(), newStore.getMaxMana(), newStore.getSkillXP(), newStore.getSkillpoints(), newStore.getManaRegenRate(), newStore.getManaEfficiencyValue(), newStore.addedHP, newStore.hpRegeneration, newStore.getSpellTier())); } } } @@ -60,13 +62,16 @@ public void onPlayerTick(TickEvent.PlayerTickEvent event) assert playermana != null; playermana.addMana(amount); - sync++; - sync %= 10; - if(sync == 0) + if(event.side == Side.CLIENT) { - PlayerMana playerMana = event.player.getCapability(PlayerProperties.PLAYER_MANA, null); - assert playerMana != null; - PacketHandler.INSTANCE.sendToServer(new PacketGetPlayerMana(event.player.getName(), playerMana.getMana())); + playerSync++; + playerSync %= 10; + if(playerSync == 0) + { + PlayerMana playerMana = event.player.getCapability(PlayerProperties.PLAYER_MANA, null); + assert playerMana != null; + PacketHandler.INSTANCE.sendToServer(new PacketGetPlayerMana(event.player.getName(), playerMana.getMana())); + } } } @@ -76,7 +81,8 @@ public void onPlayerSwapDimension(net.minecraftforge.fml.common.gameevent.Player PlayerMana playerMana = event.player.getCapability(PlayerProperties.PLAYER_MANA, null); assert playerMana != null; playerMana.updatePlayerHP(event.player); - PacketHandler.INSTANCE.sendToServer(new PacketGetSkill(event.player.getName(), playerMana.getMaxMana(), playerMana.getSkillXP(), playerMana.getSkillpoints(), playerMana.getManaRegenRate(), playerMana.getManaEfficiencyValue(), playerMana.addedHP, playerMana.hpRegeneration, playerMana.getSpellTier())); + if(event.player.world.isRemote) + PacketHandler.INSTANCE.sendToServer(new PacketGetSkill(event.player.getName(), playerMana.getMaxMana(), playerMana.getSkillXP(), playerMana.getSkillpoints(), playerMana.getManaRegenRate(), playerMana.getManaEfficiencyValue(), playerMana.addedHP, playerMana.hpRegeneration, playerMana.getSpellTier())); } @SubscribeEvent public void onPlayerJoin(EntityJoinWorldEvent event) @@ -86,7 +92,8 @@ public void onPlayerJoin(EntityJoinWorldEvent event) PlayerMana playerMana = event.getEntity().getCapability(PlayerProperties.PLAYER_MANA, null); assert playerMana != null; playerMana.updatePlayerHP((EntityPlayer) event.getEntity()); - PacketHandler.INSTANCE.sendToServer(new PacketGetSkill(event.getEntity().getName(), playerMana.getMaxMana(), playerMana.getSkillXP(), playerMana.getSkillpoints(), playerMana.getManaRegenRate(), playerMana.getManaEfficiencyValue(), playerMana.addedHP, playerMana.hpRegeneration, playerMana.getSpellTier())); + if(event.getWorld().isRemote) + PacketHandler.INSTANCE.sendToServer(new PacketGetSkill(event.getEntity().getName(), playerMana.getMaxMana(), playerMana.getSkillXP(), playerMana.getSkillpoints(), playerMana.getManaRegenRate(), playerMana.getManaEfficiencyValue(), playerMana.addedHP, playerMana.hpRegeneration, playerMana.getSpellTier())); } } @SubscribeEvent diff --git a/src/main/java/com/fi0x/deepmagic/network/PacketReturnRitual.java b/src/main/java/com/fi0x/deepmagic/network/PacketReturnRitual.java index 22affbad..70819c56 100644 --- a/src/main/java/com/fi0x/deepmagic/network/PacketReturnRitual.java +++ b/src/main/java/com/fi0x/deepmagic/network/PacketReturnRitual.java @@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketReturnRitual implements IMessage { @@ -62,11 +63,12 @@ public static class Handler implements IMessageHandler processMessage(message)); return null; } + @SideOnly(Side.CLIENT) void processMessage(PacketReturnRitual message) { World world = Minecraft.getMinecraft().world; diff --git a/src/main/java/com/fi0x/deepmagic/network/PacketReturnSpellStone.java b/src/main/java/com/fi0x/deepmagic/network/PacketReturnSpellStone.java index 38a072f4..6fd2f09e 100644 --- a/src/main/java/com/fi0x/deepmagic/network/PacketReturnSpellStone.java +++ b/src/main/java/com/fi0x/deepmagic/network/PacketReturnSpellStone.java @@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketReturnSpellStone implements IMessage { @@ -62,11 +63,12 @@ public static class Handler implements IMessageHandler processMessage(message)); return null; } + @SideOnly(Side.CLIENT) void processMessage(PacketReturnSpellStone message) { World world = Minecraft.getMinecraft().world; diff --git a/src/main/java/com/fi0x/deepmagic/particlesystem/ParticleEnum.java b/src/main/java/com/fi0x/deepmagic/particlesystem/ParticleEnum.java index d6ce2928..98106a91 100644 --- a/src/main/java/com/fi0x/deepmagic/particlesystem/ParticleEnum.java +++ b/src/main/java/com/fi0x/deepmagic/particlesystem/ParticleEnum.java @@ -2,7 +2,10 @@ import com.fi0x.deepmagic.particlesystem.particles.*; import com.fi0x.deepmagic.util.handlers.ConfigHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public enum ParticleEnum { MAGIC_LIGHT("magic_light", ConfigHandler.firstParticleID, true, ParticleMagicLight.class), diff --git a/src/main/java/com/fi0x/deepmagic/particlesystem/ParticleSpawner.java b/src/main/java/com/fi0x/deepmagic/particlesystem/ParticleSpawner.java index 4d9adc44..38624d8e 100644 --- a/src/main/java/com/fi0x/deepmagic/particlesystem/ParticleSpawner.java +++ b/src/main/java/com/fi0x/deepmagic/particlesystem/ParticleSpawner.java @@ -7,7 +7,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -public class ParticleSpawner +public class ParticleSpawner//TODO: Fix everywhere: currently no particles visible due to client-side check { private static final Minecraft mc = Minecraft.getMinecraft(); diff --git a/src/main/java/com/fi0x/deepmagic/particlesystem/particles/ParticleMagicLight.java b/src/main/java/com/fi0x/deepmagic/particlesystem/particles/ParticleMagicLight.java index 37d669b5..916b2e80 100644 --- a/src/main/java/com/fi0x/deepmagic/particlesystem/particles/ParticleMagicLight.java +++ b/src/main/java/com/fi0x/deepmagic/particlesystem/particles/ParticleMagicLight.java @@ -52,7 +52,6 @@ public void renderParticle(@Nonnull BufferBuilder buffer, @Nonnull Entity entity { this.particleAlpha = (float) -((particleAge - particleMaxAge) / (0.2 * particleMaxAge)); } else this.particleAlpha = 1; - if(particleAlpha > 1) System.out.println("Alpha too big"); } @Override public int getFXLayer() diff --git a/src/main/java/com/fi0x/deepmagic/proxy/ClientProxy.java b/src/main/java/com/fi0x/deepmagic/proxy/ClientProxy.java index ad9568ec..be094886 100644 --- a/src/main/java/com/fi0x/deepmagic/proxy/ClientProxy.java +++ b/src/main/java/com/fi0x/deepmagic/proxy/ClientProxy.java @@ -3,6 +3,7 @@ import com.fi0x.deepmagic.gui.GuiManaRenderOverlay; import com.fi0x.deepmagic.gui.GuiSkilltree; import com.fi0x.deepmagic.init.BlockColors; +import com.fi0x.deepmagic.util.handlers.RenderHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.player.EntityPlayer; @@ -33,10 +34,17 @@ public void preInit(FMLPreInitializationEvent event) super.preInit(event); MinecraftForge.EVENT_BUS.register(GuiManaRenderOverlay.instance); } - + @Override + public void preInit2(FMLPreInitializationEvent event) + { + super.preInit2(event); + RenderHandler.registerEntityRenders(); + RenderHandler.registerCustomMeshesAndStates(); + } @Override public void init(FMLInitializationEvent event) { + super.init(event); BlockColors.registerColors(); } } \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/proxy/CommonProxy.java b/src/main/java/com/fi0x/deepmagic/proxy/CommonProxy.java index fd68edf6..ed9adcb1 100644 --- a/src/main/java/com/fi0x/deepmagic/proxy/CommonProxy.java +++ b/src/main/java/com/fi0x/deepmagic/proxy/CommonProxy.java @@ -1,19 +1,50 @@ package com.fi0x.deepmagic.proxy; +import com.fi0x.deepmagic.advancements.ModTriggers; +import net.minecraft.advancements.CriteriaTriggers; +import net.minecraft.advancements.ICriterionTrigger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.relauncher.ReflectionHelper; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; public class CommonProxy { - public void registerItemRenderer(Item item, int meta, String id) {} - public void openSkilltreeGui(EntityPlayer player) {} + public void registerItemRenderer(Item item, int meta, String id) + { + } + public void openSkilltreeGui(EntityPlayer player) + { + } public void preInit(FMLPreInitializationEvent event) { } + public void preInit2(FMLPreInitializationEvent event) + { + } public void init(FMLInitializationEvent event) { + Method method; + + method = ReflectionHelper.findMethod(CriteriaTriggers.class, "register", "func_192118_a", ICriterionTrigger.class); + + method.setAccessible(true); + + for (int i = 0; i < ModTriggers.TRIGGER_ARRAY.length; i++) + { + try + { + method.invoke(null, ModTriggers.TRIGGER_ARRAY[i]); + } + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) + { + e.printStackTrace(); + } + } } } \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/util/Reference.java b/src/main/java/com/fi0x/deepmagic/util/Reference.java index 5c9508b0..a7752c5b 100644 --- a/src/main/java/com/fi0x/deepmagic/util/Reference.java +++ b/src/main/java/com/fi0x/deepmagic/util/Reference.java @@ -3,7 +3,7 @@ public class Reference { public static final String MOD_ID = "deepmagic"; public static final String NAME = "Deep Magic"; - public static final String VERSION = "1.0.1"; + public static final String VERSION = "1.0.2"; public static final String ACCEPTED_VERSIONS = "[1.12.2]"; public static final String CLIENT_PROXY_CLASS = "com.fi0x.deepmagic.proxy.ClientProxy"; public static final String COMMON_PROXY_CLASS = "com.fi0x.deepmagic.proxy.CommonProxy"; diff --git a/src/main/java/com/fi0x/deepmagic/util/handlers/ConfigHandler.java b/src/main/java/com/fi0x/deepmagic/util/handlers/ConfigHandler.java index c78505b1..db92b9eb 100644 --- a/src/main/java/com/fi0x/deepmagic/util/handlers/ConfigHandler.java +++ b/src/main/java/com/fi0x/deepmagic/util/handlers/ConfigHandler.java @@ -72,6 +72,7 @@ public class ConfigHandler public static boolean dwarfMining; public static boolean trollDefenceState; public static int dwarfMaxMiningHeight; + public static boolean npcRaceCombat; //Whitelist public static boolean dwarfMineOres; public static boolean dwarfMineResources; @@ -116,6 +117,7 @@ public class ConfigHandler public static int manaMachineManaCapacity; public static int manaGainFromMob; public static int manaToleranceSpellStone; + public static int manaBatteryCapacity; //Rituals public static boolean allowRituals; public static boolean requireRitualStructure; @@ -269,6 +271,7 @@ public static void initNPCs(File file) dwarfMining = npcsGeneral.getBoolean("Dwarf Mining", category, true, "Allow Dwarfs to dig tunnels"); trollDefenceState = npcsGeneral.getBoolean("Troll Defence State", category, true, "Allow Trolls to use an invulnerable Defence State"); dwarfMaxMiningHeight = npcsGeneral.getInt("Max Dwarf Mining Height", category, 50, 20, 250, "Maximum Height in which dwarfs dig mines (Does not apply for depth dimension)"); + npcRaceCombat = npcsGeneral.getBoolean("NPC Race Combat", category, false, "Weather or not NPCs should fight each other, like Mages vs. Mobs"); category = "NPC Whitelist"; npcsGeneral.addCustomCategoryComment(category, "NPC Whitelist"); @@ -345,6 +348,7 @@ public static void initBlocks(File file) manaMachineManaCapacity = blocks.getInt("Mana Machine Capacity", category, 1000, 100, 100000, "The Mana Capacity for all Mana consuming Machines"); manaGainFromMob = blocks.getInt("Mana From Mob", category, 10, 1, 1000, "Mana gained by inflicting 1HP damage to a Mob with the Mob Generator"); manaToleranceSpellStone = blocks.getInt("Spell Stone Mana Tolerance", category, 100, 1, 10000, "How much mana a Spell Stone can be short of without explodint"); + manaBatteryCapacity = blocks.getInt("Mana Battery Capacity", category, 1000000, 100, 10000000, "The Capacity of a Mana Battery"); category = "Rituals"; blocks.addCustomCategoryComment(category, "Rituals"); diff --git a/src/main/java/com/fi0x/deepmagic/util/handlers/PacketHandler.java b/src/main/java/com/fi0x/deepmagic/util/handlers/PacketHandler.java index e6ce8306..59f4e3df 100644 --- a/src/main/java/com/fi0x/deepmagic/util/handlers/PacketHandler.java +++ b/src/main/java/com/fi0x/deepmagic/util/handlers/PacketHandler.java @@ -28,12 +28,12 @@ public static void registerMessages(String channelName) INSTANCE.registerMessage(PacketGetMobAnimation.Handler.class, PacketGetMobAnimation.class, nextID(), Side.SERVER); INSTANCE.registerMessage(PacketReturnMobAnimation.Handler.class, PacketReturnMobAnimation.class, nextID(), Side.CLIENT); - INSTANCE.registerMessage(PacketInformGuiChange.Handler.class, PacketInformGuiChange.class, nextID(), Side.SERVER); - INSTANCE.registerMessage(PacketGetSpellStone.Handler.class, PacketGetSpellStone.class, nextID(), Side.SERVER); INSTANCE.registerMessage(PacketReturnSpellStone.Handler.class, PacketReturnSpellStone.class, nextID(), Side.CLIENT); INSTANCE.registerMessage(PacketGetRitual.Handler.class, PacketGetRitual.class, nextID(), Side.SERVER); INSTANCE.registerMessage(PacketReturnRitual.Handler.class, PacketReturnRitual.class, nextID(), Side.CLIENT); + + INSTANCE.registerMessage(PacketInformGuiChange.Handler.class, PacketInformGuiChange.class, nextID(), Side.SERVER); } } \ No newline at end of file diff --git a/src/main/java/com/fi0x/deepmagic/util/handlers/RegistryHandler.java b/src/main/java/com/fi0x/deepmagic/util/handlers/RegistryHandler.java index b1b9540b..27c57743 100644 --- a/src/main/java/com/fi0x/deepmagic/util/handlers/RegistryHandler.java +++ b/src/main/java/com/fi0x/deepmagic/util/handlers/RegistryHandler.java @@ -81,6 +81,7 @@ public static void registerTileEntities() GameRegistry.registerTileEntity(TileEntityManaGeneratorInsanity.class, new ResourceLocation(Reference.MOD_ID, "mana_generator_insanity")); GameRegistry.registerTileEntity(TileEntityManaGeneratorMob.class, new ResourceLocation(Reference.MOD_ID, "mana_generator_mob")); GameRegistry.registerTileEntity(TileEntityManaRelay.class, new ResourceLocation(Reference.MOD_ID, "mana_relay")); + GameRegistry.registerTileEntity(TileEntityManaBattery.class, new ResourceLocation(Reference.MOD_ID, "mana_battery_block")); GameRegistry.registerTileEntity(TileEntityManaAltar.class, new ResourceLocation(Reference.MOD_ID, "mana_altar")); GameRegistry.registerTileEntity(TileEntityManaInfuser.class, new ResourceLocation(Reference.MOD_ID, "mana_infuser")); diff --git a/src/main/java/com/fi0x/deepmagic/world/StructureChecker.java b/src/main/java/com/fi0x/deepmagic/world/StructureChecker.java index 90bff655..761d7185 100644 --- a/src/main/java/com/fi0x/deepmagic/world/StructureChecker.java +++ b/src/main/java/com/fi0x/deepmagic/world/StructureChecker.java @@ -22,14 +22,16 @@ public static boolean verifyRitualStructure(World world, BlockPos pos, RITUAL_TY { BlockPos position = pos.add(offset); if(world.getBlockState(position).getBlock() instanceof RitualStructure) continue; - ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); + if(world.isRemote) + ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); valid = false; } for(BlockPos offset : ritualArmLocations) { BlockPos position = pos.add(offset); if(world.getBlockState(position).getBlock() instanceof RitualStructure) continue; - ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); + if(world.isRemote) + ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); valid = false; } @@ -44,21 +46,24 @@ public static boolean verifyDemonStructure(World world, BlockPos pos) { BlockPos position = pos.add(offset); if(world.getBlockState(position).getBlock().getUnlocalizedName().equals("tile.demon_crystal_block")) continue; - ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); + if(world.isRemote) + ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); valid = false; } for(BlockPos offset : demonLocationsDeepCrystal) { BlockPos position = pos.add(offset); if(world.getBlockState(position).getBlock().getUnlocalizedName().equals("tile.deep_crystal_block")) continue; - ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); + if(world.isRemote) + ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); valid = false; } for(BlockPos offset : demonLocationsIronBlock) { BlockPos position = pos.add(offset); if(world.getBlockState(position).getBlock().getUnlocalizedName().equals("tile.blockIron")) continue; - ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); + if(world.isRemote) + ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); valid = false; } @@ -73,28 +78,32 @@ public static boolean verifySpellStoneStructure(World world, BlockPos pos) { BlockPos position = pos.add(offset); if(world.getBlockState(position).getBlock() instanceof ManaRelay) continue; - ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); + if(world.isRemote) + ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); valid = false; } for(BlockPos offset : spellStoneLocationsGlowstone) { BlockPos position = pos.add(offset); if(world.getBlockState(position).getBlock() instanceof BlockGlowstone) continue; - ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); + if(world.isRemote) + ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); valid = false; } for(BlockPos offset : spellStoneLocationsDeepCrystal) { BlockPos position = pos.add(offset); if(world.getBlockState(position).getBlock().getUnlocalizedName().equals("tile.deep_crystal_block")) continue; - ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); + if(world.isRemote) + ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); valid = false; } for(BlockPos offset : spellStoneLocationsObsidian) { BlockPos position = pos.add(offset); if(world.getBlockState(position).getBlock() instanceof BlockObsidian) continue; - ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); + if(world.isRemote) + ParticleSpawner.spawnParticle(ParticleEnum.RITUAL_MISSING, position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5); valid = false; } diff --git a/src/main/java/com/fi0x/deepmagic/world/biomes/depth/BiomeDepth.java b/src/main/java/com/fi0x/deepmagic/world/biomes/depth/BiomeDepth.java index 976bbb85..f56caf45 100644 --- a/src/main/java/com/fi0x/deepmagic/world/biomes/depth/BiomeDepth.java +++ b/src/main/java/com/fi0x/deepmagic/world/biomes/depth/BiomeDepth.java @@ -5,7 +5,6 @@ import com.fi0x.deepmagic.util.handlers.ConfigHandler; import net.minecraft.block.Block; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; import javax.annotation.Nonnull; @@ -14,8 +13,8 @@ public class BiomeDepth extends Biome { private static final Block TOP_BLOCK = ModBlocks.DEPTH_STONE; private static final Block FILLER_BLOCK = ModBlocks.DEPTH_STONE; - private static final int SKY_COLOR = MathHelper.hsvToRGB(0.1F, 0F, 0F); - private static final int FOLIAGE_COLOR = MathHelper.hsvToRGB(0.33F, 0.48F, 0.22F); + private static final int SKY_COLOR = 0; + private static final int FOLIAGE_COLOR = 3681309; public BiomeDepth() { diff --git a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestLarge.java b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestLarge.java index 0e4894f2..2c3dd4c5 100644 --- a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestLarge.java +++ b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestLarge.java @@ -10,7 +10,6 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.ChunkPrimer; @@ -23,8 +22,8 @@ public class BiomeInsanityForestLarge extends Biome { private static final Block TOP_BLOCK = ModBlocks.INSANITY_GRASS; private static final Block FILLER_BLOCK = ModBlocks.INSANITY_DIRT; - private static final int SKY_COLOR = MathHelper.hsvToRGB(0.1F, 0.91F, 0.50F); - private static final int FOLIAGE_COLOR = MathHelper.hsvToRGB(0.319F, 1F, 0.89F); + private static final int SKY_COLOR = 8396555; + private static final int FOLIAGE_COLOR = 14907648; public BiomeInsanityForestLarge() { @@ -37,8 +36,8 @@ public BiomeInsanityForestLarge() this.spawnableMonsterList.clear(); this.spawnableWaterCreatureList.clear(); - if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityCockroach.class, 20, 1, 3)); - if(ConfigHandler.allowHoveringOrb) this.spawnableMonsterList.add(new SpawnListEntry(EntityHoveringOrb.class, 5, 2, 6)); + if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityCockroach.class, 20, 1, 2)); + if(ConfigHandler.allowHoveringOrb) this.spawnableMonsterList.add(new SpawnListEntry(EntityHoveringOrb.class, 5, 1, 2)); if(ConfigHandler.allowGiant) this.spawnableMonsterList.add(new SpawnListEntry(EntityGiant.class, 5, 1, 2)); this.flowers.clear(); diff --git a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestMixed.java b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestMixed.java index d65eb98e..71bd7494 100644 --- a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestMixed.java +++ b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestMixed.java @@ -11,7 +11,6 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.ChunkPrimer; @@ -24,8 +23,8 @@ public class BiomeInsanityForestMixed extends Biome { private static final Block TOP_BLOCK = ModBlocks.INSANITY_GRASS; private static final Block FILLER_BLOCK = ModBlocks.INSANITY_DIRT; - private static final int SKY_COLOR = MathHelper.hsvToRGB(0.1F, 0.91F, 0.50F); - private static final int FOLIAGE_COLOR = MathHelper.hsvToRGB(0.319F, 1F, 0.89F); + private static final int SKY_COLOR = 8396555; + private static final int FOLIAGE_COLOR = 14907648; public BiomeInsanityForestMixed() { @@ -38,10 +37,10 @@ public BiomeInsanityForestMixed() this.spawnableMonsterList.clear(); this.spawnableWaterCreatureList.clear(); - if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityCockroach.class, 20, 1, 3)); - if(ConfigHandler.allowInsanityCow) this.spawnableCreatureList.add(new SpawnListEntry(EntityInsanityCow.class, 5, 2, 3)); - if(ConfigHandler.allowDepthMage) this.spawnableCreatureList.add(new SpawnListEntry(EntityDepthMage.class, 15, 1, 2)); - if(ConfigHandler.allowHoveringOrb) this.spawnableMonsterList.add(new SpawnListEntry(EntityHoveringOrb.class, 5, 2, 6)); + if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityCockroach.class, 20, 1, 2)); + if(ConfigHandler.allowInsanityCow) this.spawnableCreatureList.add(new SpawnListEntry(EntityInsanityCow.class, 5, 1, 3)); + if(ConfigHandler.allowDepthMage) this.spawnableCreatureList.add(new SpawnListEntry(EntityDepthMage.class, 1, 1, 2)); + if(ConfigHandler.allowHoveringOrb) this.spawnableMonsterList.add(new SpawnListEntry(EntityHoveringOrb.class, 5, 1, 2)); this.flowers.clear(); addFlower(ModBlocks.INSANITY_FLOWER.getDefaultState(), 20); diff --git a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestSmall.java b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestSmall.java index 75f68b31..1c8a0730 100644 --- a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestSmall.java +++ b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityForestSmall.java @@ -11,7 +11,6 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.ChunkPrimer; @@ -24,8 +23,8 @@ public class BiomeInsanityForestSmall extends Biome { private static final Block TOP_BLOCK = ModBlocks.INSANITY_GRASS; private static final Block FILLER_BLOCK = ModBlocks.INSANITY_DIRT; - private static final int SKY_COLOR = MathHelper.hsvToRGB(0.1F, 0.91F, 0.50F); - private static final int FOLIAGE_COLOR = MathHelper.hsvToRGB(0.319F, 1F, 0.89F); + private static final int SKY_COLOR = 8396555; + private static final int FOLIAGE_COLOR = 14907648; public BiomeInsanityForestSmall() { @@ -38,10 +37,10 @@ public BiomeInsanityForestSmall() this.spawnableMonsterList.clear(); this.spawnableWaterCreatureList.clear(); - if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityCockroach.class, 20, 1, 3)); - if(ConfigHandler.allowInsanityCow) this.spawnableCreatureList.add(new SpawnListEntry(EntityInsanityCow.class, 5, 2, 3)); - if(ConfigHandler.allowDepthMage) this.spawnableCreatureList.add(new SpawnListEntry(EntityDepthMage.class, 15, 1, 2)); - if(ConfigHandler.allowHoveringOrb) this.spawnableMonsterList.add(new SpawnListEntry(EntityHoveringOrb.class, 5, 2, 6)); + if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityCockroach.class, 20, 1, 2)); + if(ConfigHandler.allowInsanityCow) this.spawnableCreatureList.add(new SpawnListEntry(EntityInsanityCow.class, 5, 1, 3)); + if(ConfigHandler.allowDepthMage) this.spawnableCreatureList.add(new SpawnListEntry(EntityDepthMage.class, 1, 1, 2)); + if(ConfigHandler.allowHoveringOrb) this.spawnableMonsterList.add(new SpawnListEntry(EntityHoveringOrb.class, 5, 1, 2)); this.flowers.clear(); addFlower(ModBlocks.INSANITY_FLOWER.getDefaultState(), 20); diff --git a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityHills.java b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityHills.java index e55936d4..6edbf8fc 100644 --- a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityHills.java +++ b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityHills.java @@ -9,7 +9,6 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.ChunkPrimer; @@ -22,8 +21,8 @@ public class BiomeInsanityHills extends Biome { private static final Block TOP_BLOCK = ModBlocks.INSANITY_GRASS; private static final Block FILLER_BLOCK = ModBlocks.INSANITY_DIRT; - private static final int SKY_COLOR = MathHelper.hsvToRGB(0.1F, 0.91F, 0.50F); - private static final int FOLIAGE_COLOR = MathHelper.hsvToRGB(0.319F, 1F, 0.57F); + private static final int SKY_COLOR = 8396555; + private static final int FOLIAGE_COLOR = 9522688; public BiomeInsanityHills() { @@ -36,8 +35,8 @@ public BiomeInsanityHills() this.spawnableMonsterList.clear(); this.spawnableWaterCreatureList.clear(); - if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityCockroach.class, 20, 1, 3)); - if(ConfigHandler.allowGiant) this.spawnableMonsterList.add(new SpawnListEntry(EntityGiant.class, 5, 2, 3)); + if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityCockroach.class, 20, 1, 2)); + if(ConfigHandler.allowGiant) this.spawnableMonsterList.add(new SpawnListEntry(EntityGiant.class, 5, 1, 2)); this.flowers.clear(); addFlower(ModBlocks.INSANITY_FLOWER2.getDefaultState(), 20); diff --git a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityPlains.java b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityPlains.java index 9fd23cda..ed2aad35 100644 --- a/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityPlains.java +++ b/src/main/java/com/fi0x/deepmagic/world/biomes/insanity/BiomeInsanityPlains.java @@ -11,7 +11,6 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.ChunkPrimer; @@ -24,8 +23,8 @@ public class BiomeInsanityPlains extends Biome { private static final Block TOP_BLOCK = ModBlocks.INSANITY_GRASS; private static final Block FILLER_BLOCK = ModBlocks.INSANITY_DIRT; - private static final int SKY_COLOR = MathHelper.hsvToRGB(0.1F, 0.91F, 0.50F); - private static final int FOLIAGE_COLOR = MathHelper.hsvToRGB(0.319F, 1F, 0.89F); + private static final int SKY_COLOR = 8396555; + private static final int FOLIAGE_COLOR = 14907648; public BiomeInsanityPlains() { @@ -38,10 +37,10 @@ public BiomeInsanityPlains() this.spawnableMonsterList.clear(); this.spawnableWaterCreatureList.clear(); - if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new Biome.SpawnListEntry(EntityCockroach.class, 20, 1, 3)); - if(ConfigHandler.allowInsanityCow) this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityInsanityCow.class, 5, 2, 3)); - if(ConfigHandler.allowDepthMage) this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityDepthMage.class, 15, 1, 2)); - if(ConfigHandler.allowHoveringOrb) this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityHoveringOrb.class, 5, 2, 6)); + if(ConfigHandler.allowCockroach) this.spawnableCaveCreatureList.add(new Biome.SpawnListEntry(EntityCockroach.class, 20, 1, 2)); + if(ConfigHandler.allowInsanityCow) this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityInsanityCow.class, 5, 1, 3)); + if(ConfigHandler.allowDepthMage) this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityDepthMage.class, 1, 1, 2)); + if(ConfigHandler.allowHoveringOrb) this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityHoveringOrb.class, 5, 1, 2)); this.flowers.clear(); addFlower(ModBlocks.INSANITY_FLOWER.getDefaultState(), 20); diff --git a/src/main/resources/assets/deepmagic/advancements/altar_of_knowledge_opened.json b/src/main/resources/assets/deepmagic/advancements/altar_of_knowledge_opened.json new file mode 100644 index 00000000..649db83b --- /dev/null +++ b/src/main/resources/assets/deepmagic/advancements/altar_of_knowledge_opened.json @@ -0,0 +1,28 @@ +{ + "display": { + "icon": { + "item": "deepmagic:altar_of_knowledge" + }, + "title": { + "translate": "advancement.deepmagic.altar_of_knowledge.opened.title" + }, + "description": { + "translate": "advancement.deepmagic.altar_of_knowledge.opened.description" + }, + "frame": "goal", + "hidden": false + }, + "parent": "deepmagic:knowledge_segment", + "criteria": { + "ui_opened": { + "trigger": "altar_of_knowledge_ui_opened", + "conditions": { + } + } + }, + "requirements": [ + [ + "ui_opened" + ] + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/deepmagic/advancements/knowledge_segment.json b/src/main/resources/assets/deepmagic/advancements/knowledge_segment.json new file mode 100644 index 00000000..56fed5f8 --- /dev/null +++ b/src/main/resources/assets/deepmagic/advancements/knowledge_segment.json @@ -0,0 +1,33 @@ +{ + "display": { + "icon": { + "item": "deepmagic:knowledge_segment" + }, + "title": { + "translate": "advancement.deepmagic.knowledge_segment.crafted.title" + }, + "description": { + "translate": "advancement.deepmagic.knowledge_segment.crafted.description" + }, + "frame": "task", + "hidden": false + }, + "parent": "deepmagic:sigil_crafting", + "criteria": { + "segment_crafted": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "deepmagic:knowledge_segment" + } + ] + } + } + }, + "requirements": [ + [ + "segment_crafted" + ] + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/deepmagic/advancements/linked_mana_relay.json b/src/main/resources/assets/deepmagic/advancements/linked_mana_relay.json new file mode 100644 index 00000000..00036da3 --- /dev/null +++ b/src/main/resources/assets/deepmagic/advancements/linked_mana_relay.json @@ -0,0 +1,28 @@ +{ + "display": { + "icon": { + "item": "deepmagic:mana_linker" + }, + "title": { + "translate": "advancement.deepmagic.mana_relay.linked.title" + }, + "description": { + "translate": "advancement.deepmagic.mana_relay.linked.description" + }, + "frame": "challenge", + "hidden": false + }, + "parent": "deepmagic:mana_linker", + "criteria": { + "relay_linked": { + "trigger": "link_mana_relay", + "conditions": { + } + } + }, + "requirements": [ + [ + "relay_linked" + ] + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/deepmagic/advancements/mana_linker.json b/src/main/resources/assets/deepmagic/advancements/mana_linker.json index 0a7949bc..bfcf9eae 100644 --- a/src/main/resources/assets/deepmagic/advancements/mana_linker.json +++ b/src/main/resources/assets/deepmagic/advancements/mana_linker.json @@ -9,7 +9,7 @@ "description": { "translate": "advancement.deepmagic.linker.crafted.description" }, - "frame": "goal", + "frame": "task", "hidden": false }, "parent": "deepmagic:dimensional_crafting", diff --git a/src/main/resources/assets/deepmagic/advancements/spell_used.json b/src/main/resources/assets/deepmagic/advancements/spell_used.json new file mode 100644 index 00000000..19f8d331 --- /dev/null +++ b/src/main/resources/assets/deepmagic/advancements/spell_used.json @@ -0,0 +1,28 @@ +{ + "display": { + "icon": { + "item": "deepmagic:spell" + }, + "title": { + "translate": "advancement.deepmagic.spell.used.title" + }, + "description": { + "translate": "advancement.deepmagic.spell.used.description" + }, + "frame": "goal", + "hidden": false + }, + "parent": "deepmagic:spell_crafting", + "criteria": { + "spell_used": { + "trigger": "right_click_spell", + "conditions": { + } + } + }, + "requirements": [ + [ + "spell_used" + ] + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/deepmagic/blockstates/mana_battery_block.json b/src/main/resources/assets/deepmagic/blockstates/mana_battery_block.json new file mode 100644 index 00000000..0463cd2c --- /dev/null +++ b/src/main/resources/assets/deepmagic/blockstates/mana_battery_block.json @@ -0,0 +1,7 @@ +{ + "variants": { + "normal": { + "model": "deepmagic:mana_battery_block" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/deepmagic/lang/en_us.lang b/src/main/resources/assets/deepmagic/lang/en_us.lang index 14f0bc20..30c0bfff 100644 --- a/src/main/resources/assets/deepmagic/lang/en_us.lang +++ b/src/main/resources/assets/deepmagic/lang/en_us.lang @@ -131,6 +131,7 @@ tile.ritual_quarry.name=Quarry Ritual tile.mana_altar.name=Mana Altar tile.mana_relay.name=Mana Relay +tile.mana_battery_block.name=Mana Battery tile.mana_generator_normal.name=Normal Mana Generator tile.mana_generator_insanity.name=Insanity Mana Generator tile.mana_generator_mob.name=Mob Mana Generator @@ -291,4 +292,12 @@ advancement.deepmagic.ritual_weather.crafted.description=Craft and place a Weath advancement.deepmagic.ritual_spawn.crafted.title=Master of the Dead advancement.deepmagic.ritual_spawn.crafted.description=Craft and place a Spawn Denial Ritual advancement.deepmagic.ritual_quarry.crafted.title=Master of Mining -advancement.deepmagic.ritual_quarry.crafted.description=Craft and place a Quarry Ritual \ No newline at end of file +advancement.deepmagic.ritual_quarry.crafted.description=Craft and place a Quarry Ritual +advancement.deepmagic.spell.used.title="Magician" +advancement.deepmagic.spell.used.description="Use a spell" +advancement.deepmagic.mana_relay.linked.title="Magic Networker" +advancement.deepmagic.mana_relay.linked.description="Link a Mana Relay" +advancement.deepmagic.altar_of_knowledge.opened.title="Level up!" +advancement.deepmagic.altar_of_knowledge.opened.description="Open the Altar of Knowledge UI" +advancement.deepmagic.knowledge_segment.crafted.title=Knowledge Blocks +advancement.deepmagic.knowledge_segment.crafted.description=Craft a Knowledge Segment \ No newline at end of file diff --git a/src/main/resources/assets/deepmagic/models/block/mana_battery_block.json b/src/main/resources/assets/deepmagic/models/block/mana_battery_block.json new file mode 100644 index 00000000..92a83928 --- /dev/null +++ b/src/main/resources/assets/deepmagic/models/block/mana_battery_block.json @@ -0,0 +1,13 @@ +{ + "forge_marker": 1, + "parent": "block/cube", + "textures": { + "particle": "deepmagic:blocks/mana/battery_block/mana_battery_block_side", + "up": "deepmagic:blocks/mana/battery_block/mana_battery_block_top", + "down": "deepmagic:blocks/mana/battery_block/mana_battery_block_bottom", + "north": "deepmagic:blocks/mana/battery_block/mana_battery_block_side", + "east": "deepmagic:blocks/mana/battery_block/mana_battery_block_side", + "south": "deepmagic:blocks/mana/battery_block/mana_battery_block_side", + "west": "deepmagic:blocks/mana/battery_block/mana_battery_block_side" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/deepmagic/models/item/mana_battery_block.json b/src/main/resources/assets/deepmagic/models/item/mana_battery_block.json new file mode 100644 index 00000000..b8fbf3c4 --- /dev/null +++ b/src/main/resources/assets/deepmagic/models/item/mana_battery_block.json @@ -0,0 +1,3 @@ +{ + "parent": "deepmagic:block/mana_battery_block" +} \ No newline at end of file diff --git a/src/main/resources/assets/deepmagic/recipes/mana_battery_block.json b/src/main/resources/assets/deepmagic/recipes/mana_battery_block.json new file mode 100644 index 00000000..7a55ea6c --- /dev/null +++ b/src/main/resources/assets/deepmagic/recipes/mana_battery_block.json @@ -0,0 +1,36 @@ +{ + "type": "minecraft:crafting_shaped", + + "pattern": + [ + "BSB", + "FRF", + "BFB" + ], + + "key": + { + "B": + { + "item": "deepmagic:mana_segment" + }, + "S": + { + "item": "deepmagic:magic_sigil" + }, + "F": + { + "item": "deepmagic:magic_flow_controller" + }, + "R": + { + "item": "deepmagic:mana_relay" + } + }, + + "result": + { + "item": "deepmagic:mana_battery_block", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/assets/deepmagic/textures/blocks/mana/battery_block/mana_battery_block_bottom.png b/src/main/resources/assets/deepmagic/textures/blocks/mana/battery_block/mana_battery_block_bottom.png new file mode 100644 index 00000000..544aac0f Binary files /dev/null and b/src/main/resources/assets/deepmagic/textures/blocks/mana/battery_block/mana_battery_block_bottom.png differ diff --git a/src/main/resources/assets/deepmagic/textures/blocks/mana/battery_block/mana_battery_block_side.png b/src/main/resources/assets/deepmagic/textures/blocks/mana/battery_block/mana_battery_block_side.png new file mode 100644 index 00000000..23b393d9 Binary files /dev/null and b/src/main/resources/assets/deepmagic/textures/blocks/mana/battery_block/mana_battery_block_side.png differ diff --git a/src/main/resources/assets/deepmagic/textures/blocks/mana/battery_block/mana_battery_block_top.png b/src/main/resources/assets/deepmagic/textures/blocks/mana/battery_block/mana_battery_block_top.png new file mode 100644 index 00000000..9d78ea4e Binary files /dev/null and b/src/main/resources/assets/deepmagic/textures/blocks/mana/battery_block/mana_battery_block_top.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index efb2b7d9..8b0cd723 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "deepmagic", "name": "Deep Magic", "description": "Mod that uses magic from the depths of the world.", - "version": "1.0.1", + "version": "1.0.2", "mcversion": "1.12.2", "url": "https://github.com/Fi0x/DeepMagic", "updateUrl": "",