Merge branch '1.12.2' into 1.12.2-dev

This commit is contained in:
Electroblob77
2019-01-06 16:26:02 +00:00
29 changed files with 1078 additions and 55 deletions
@@ -33,12 +33,12 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemEnchantedBook;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.nbt.*;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -278,12 +278,14 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
for(ItemStack stack : player.inventory.mainInventory){
if(stack.isItemEnchanted()){
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
NBTTagList enchantmentList = stack.getItem() == Items.ENCHANTED_BOOK ?
ItemEnchantedBook.getEnchantments(stack) : stack.getEnchantmentTagList();
Iterator<Entry<Enchantment, Integer>> iterator = enchantments.entrySet().iterator();
Iterator<NBTBase> iterator =enchantmentList.iterator();
// For each of the item's enchantments
while(iterator.hasNext()){
Enchantment enchantment = iterator.next().getKey();
NBTTagCompound enchantmentTag = (NBTTagCompound) iterator.next();
Enchantment enchantment = Enchantment.getEnchantmentByID(enchantmentTag.getShort("id"));
// Ignores the enchantment unless it is an imbuement
if(enchantment instanceof Imbuement){
int duration = this.getImbuementDuration(enchantment);
@@ -295,10 +297,8 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
activeImbuements.add((Imbuement)enchantment);
// Otherwise:
}else{
// Removes the enchantment from the enchantment map
// Removes the enchantment from the item
iterator.remove();
// Applies the new enchantment map to the item
EnchantmentHelper.setEnchantments(enchantments, stack);
}
}
}
@@ -51,6 +51,7 @@ import net.minecraft.world.storage.loot.LootPool;
import net.minecraft.world.storage.loot.RandomValueRange;
import net.minecraft.world.storage.loot.conditions.LootCondition;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
@@ -200,7 +201,8 @@ public final class WizardryEventHandler {
// Ice Shroud
if(event.getEntityLiving().isPotionActive(WizardryPotions.ice_shroud)
&& !MagicDamage.isEntityImmune(DamageType.FROST, event.getEntityLiving()))
&& !MagicDamage.isEntityImmune(DamageType.FROST, event.getEntityLiving())
&& !(event.getEntityLiving() instanceof FakePlayer))
attacker.addPotionEffect(new PotionEffect(WizardryPotions.frost, 100, 0));
// Static Aura
@@ -175,7 +175,7 @@ public class WizardryWorldGenerator implements IWorldGenerator {
}
// 0 = West, 1 = North, 2 = East, 3 = South (The way you would face when walking out of the door)
EnumFacing orientation = EnumFacing.getHorizontal(random.nextInt(4));
EnumFacing orientation = EnumFacing.byHorizontalIndex(random.nextInt(4));
boolean flip = random.nextBoolean();
if(checkSpaceForTower(world, origin, towerBlueprint, orientation, flip)){
@@ -237,7 +237,8 @@ public class WizardryWorldGenerator implements IWorldGenerator {
// BlockPos is immutable, so I'm not sure if simply saying pos1 = pos will be sufficient.
BlockPos layerCentre = new BlockPos(origin);
while(flag){
// Stop when the bottom of the world is reached
while(flag && layerCentre.getY() > 0){
flag = false;
@@ -299,7 +300,7 @@ public class WizardryWorldGenerator implements IWorldGenerator {
// Rotates the door depending on whether flip is true.
ItemDoor.placeDoor(
world, pos, flip
? EnumFacing.getHorizontal(3 - orientation.getHorizontalIndex())
? EnumFacing.byHorizontalIndex(3 - orientation.getHorizontalIndex())
.getOpposite()
: orientation.rotateYCCW(),
Blocks.OAK_DOOR, false);
@@ -51,7 +51,7 @@ public class BlockSnare extends BlockContainer {
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity){
public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity){
if(!world.isRemote && entity instanceof EntityLivingBase){
if(world.getTileEntity(pos) instanceof TileEntityPlayerSave){
@@ -80,7 +80,7 @@ public class BlockSnare extends BlockContainer {
}
@Override
public BlockRenderLayer getBlockLayer(){
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@@ -36,7 +36,7 @@ public class BlockSpectral extends BlockContainer {
// Replaces getRenderBlockPass
@Override
public BlockRenderLayer getBlockLayer(){
public BlockRenderLayer getRenderLayer(){
return BlockRenderLayer.TRANSLUCENT;
}
@@ -101,7 +101,7 @@ public class BlockStatue extends BlockContainer {
}
@Override
public BlockRenderLayer getBlockLayer(){
public BlockRenderLayer getRenderLayer(){
return this.isIce ? BlockRenderLayer.TRANSLUCENT : BlockRenderLayer.SOLID;
}
@@ -55,7 +55,7 @@ public class BlockVanishingCobweb extends BlockContainer {
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity){
public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity){
entity.setInWeb();
}
@@ -53,6 +53,8 @@ public class GuiArcaneWorkbench extends GuiContainer {
@Override
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_){
this.drawDefaultBackground();
// Tests if there is a wand in the workbench and edits the positioning accordingly
if(this.inventorySlots.getSlot(ContainerArcaneWorkbench.CENTRE_SLOT).getHasStack() && this.inventorySlots
.getSlot(ContainerArcaneWorkbench.CENTRE_SLOT).getStack().getItem() instanceof ItemWand){
@@ -40,7 +40,7 @@ public class RenderMagicLight extends TileEntitySpecialRenderer<TileEntityMagicL
GlStateManager.scale((float)tileentity.timer / 10, (float)tileentity.timer / 10,
(float)tileentity.timer / 10);
}
if(tileentity.timer > tileentity.maxTimer - 10){
if(tileentity.timer > tileentity.maxTimer - 10 && tileentity.timer <= tileentity.maxTimer){
GlStateManager.scale((float)(tileentity.maxTimer - tileentity.timer) / 10,
(float)(tileentity.maxTimer - tileentity.timer) / 10,
(float)(tileentity.maxTimer - tileentity.timer) / 10);
@@ -92,24 +92,20 @@ public class CommandViewAllies extends CommandBase {
if(WizardData.get(player) != null){
String string = "";
Object playerList = null;
Set<String> names = WizardData.get(player).allyNames;
if(!names.isEmpty()){
for(String name : names){
string = string + name + ", ";
}
// Cuts the last " ," off of the string.
string = string.substring(0, string.length() - 2);
playerList = joinNiceStringFromCollection(names);
}else{
string = I18n.format("commands." + Wizardry.MODID + ":allies.none");
playerList = new TextComponentTranslation("commands." + Wizardry.MODID + ":allies.none");
}
if(executeAsOtherPlayer){
sender.sendMessage(
new TextComponentTranslation("commands." + Wizardry.MODID + ":allies.list_other", player.getName(), string));
new TextComponentTranslation("commands." + Wizardry.MODID + ":allies.list_other", player.getName(), playerList));
}else{
sender.sendMessage(new TextComponentTranslation("commands." + Wizardry.MODID + ":allies.list", string));
sender.sendMessage(new TextComponentTranslation("commands." + Wizardry.MODID + ":allies.list", playerList));
}
}
}
@@ -1,7 +1,9 @@
package electroblob.wizardry.enchantment;
import java.util.Iterator;
import java.util.Map;
import com.google.common.collect.Iterables;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.registry.WizardryEnchantments;
import electroblob.wizardry.spell.FreezingWeapon;
@@ -10,11 +12,15 @@ import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemEnchantedBook;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
@@ -55,11 +61,18 @@ public interface Imbuement {
if(stack.isItemEnchanted()){
// No need to check what enchantments the item has, since remove() does nothing if the element does not
// exist.
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
// Removes the magic weapon enchantments from the enchantment map
enchantments.entrySet().removeIf(entry -> entry.getKey() instanceof Imbuement);
// Applies the new enchantment map to the item
EnchantmentHelper.setEnchantments(enchantments, stack);
NBTTagList enchantmentList = stack.getItem() == Items.ENCHANTED_BOOK ?
ItemEnchantedBook.getEnchantments(stack) : stack.getEnchantmentTagList();
// Check all enchantments of the item
Iterator<NBTBase> enchantmentIt = enchantmentList.iterator();
while(enchantmentIt.hasNext()){
NBTTagCompound enchantmentTag = (NBTTagCompound) enchantmentIt.next();
Enchantment enchantment = Enchantment.getEnchantmentByID(enchantmentTag.getShort("id"));
// If the item contains a magic weapon enchantment, remove it from the item
if(enchantment instanceof Imbuement){
enchantmentIt.remove();
}
}
}
}
@@ -70,18 +83,23 @@ public interface Imbuement {
// Still not sure if it's better to set stacks in slots or modify the itemstack list directly, but I would
// imagine it's the former.
for(Slot slot : event.getContainer().inventorySlots){
if(slot.getStack().getItem() instanceof ItemEnchantedBook){
ItemStack slotStack = slot.getStack();
if(slotStack.getItem() instanceof ItemEnchantedBook){
// We don't care about the level of the enchantments
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(slot.getStack());
NBTTagList enchantmentList = ItemEnchantedBook.getEnchantments(slotStack);
// Removes all imbuements
if(enchantments.keySet().removeIf(e -> e instanceof Imbuement)){
// If any imbuements were removed, replaces the enchantments on the book with the new ones, or
// deletes the book entirely if there are none left.
if(enchantments.isEmpty()){
slot.putStack(ItemStack.EMPTY);
if(Iterables.removeIf(enchantmentList, tag -> {
NBTTagCompound enchantmentTag = (NBTTagCompound) tag;
return Enchantment.getEnchantmentByID(enchantmentTag.getShort("id"))
instanceof Imbuement;
})){
// If any imbuements were removed, inform about the removal of the enchantment(s), or
// delete the book entirely if there are none left.
if(enchantmentList.isEmpty()){
slot.putStack(ItemStack.EMPTY); // NOTE: Will need changing in 1.11
Wizardry.logger.info("Deleted enchanted book with illegal enchantments");
}else{
EnchantmentHelper.setEnchantments(enchantments, slot.getStack());
// Inform about enchantment removal
Wizardry.logger.info("Removed illegal enchantments from enchanted book");
}
}
@@ -395,7 +395,7 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
this.onBlockHit(raytraceresult);
if(this.stuckInBlock.getMaterial() != Material.AIR){
this.stuckInBlock.getBlock().onEntityCollidedWithBlock(this.world, raytraceresult.getBlockPos(),
this.stuckInBlock.getBlock().onEntityCollision(this.world, raytraceresult.getBlockPos(),
this.stuckInBlock, this);
}
}
@@ -53,7 +53,7 @@ public final class WizardryBlocks {
*/
public static void registerBlock(IForgeRegistry<Block> registry, String name, Block block){
block.setRegistryName(Wizardry.MODID, name);
block.setUnlocalizedName(block.getRegistryName().toString());
block.setTranslationKey(block.getRegistryName().toString());
registry.register(block);
}
@@ -335,7 +335,7 @@ public final class WizardryItems {
// It now makes sense to have the name first, since it's shorter than an entire item declaration.
public static void registerItem(IForgeRegistry<Item> registry, String name, Item item, boolean setTabIcon){
item.setRegistryName(Wizardry.MODID, name);
item.setUnlocalizedName(item.getRegistryName().toString());
item.setTranslationKey(item.getRegistryName().toString());
registry.register(item);
if(setTabIcon && item.getCreativeTab() instanceof CreativeTabSorted){
@@ -31,7 +31,7 @@ public final class WizardryTabs {
@Override
@SideOnly(Side.CLIENT)
public ItemStack getTabIconItem(){
public ItemStack createIcon(){
return new ItemStack(WizardryItems.wizard_handbook);
}
@@ -47,7 +47,7 @@ public final class WizardryTabs {
@Override
@SideOnly(Side.CLIENT)
public ItemStack getTabIconItem(){
public ItemStack createIcon(){
return new ItemStack(WizardryItems.spell_book);
}
@@ -149,7 +149,7 @@ public class IceAge extends Spell {
world.setBlockState(pos.down(), Blocks.OBSIDIAN.getDefaultState());
}else if(world.getBlockState(pos.down()) == Blocks.FLOWING_LAVA.getDefaultState()){
world.setBlockState(pos.down(), Blocks.COBBLESTONE.getDefaultState());
}else{
}else if(Blocks.SNOW_LAYER.canPlaceBlockAt(world, pos)){
world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState());
}
}
@@ -398,7 +398,7 @@ public abstract class Spell extends IForgeRegistryEntry.Impl<Spell> implements C
*/
public static Spell get(String name){
ResourceLocation key = new ResourceLocation(name);
if(key.getResourceDomain().equals("minecraft")) key = new ResourceLocation(Wizardry.MODID, name);
if(key.getNamespace().equals("minecraft")) key = new ResourceLocation(Wizardry.MODID, name);
return ((ForgeRegistry<Spell>)registry).getValue(key);
}
@@ -110,7 +110,7 @@ public final class WandHelper {
int selectedSpell = wand.getTagCompound().getInteger(SELECTED_SPELL_KEY);
if(selectedSpell < spells.length){
if(selectedSpell >= 0 && selectedSpell < spells.length){
return spells[selectedSpell];
}
}