More work, pretty close to being back to 1.13 level

This commit is contained in:
Vincent Lee committed 2019-06-29 00:28:18 -07:00
1 parent 828d952a86
commit bd5b395ee8
51 files changed
+336 -235

No files matched your search

@@ -106,7 +106,7 @@ public class SubTileExoflame extends TileEntityFunctionalFlower {
else {
Optional<ItemStack> maybeStack = furnace.getWorld().getRecipeManager()
.getRecipe(IRecipeType.SMELTING, furnace, furnace.getWorld())
.map(IRecipe::getRecipeOutput);
.map(r -> r.getCraftingResult(furnace));
if(!maybeStack.isPresent() || maybeStack.get().isEmpty())
return false;
@@ -100,7 +100,7 @@ public class SubTileGourmaryllis extends TileEntityGeneratingFlower {
lastFoodCount = 1;
}
int val = Math.min(12, stack.getItem().getFood().getHealing();
int val = Math.min(12, stack.getItem().getFood().getHealing());
digestingMana = val * val * 70;
digestingMana *= 1F / lastFoodCount;
cooldown = val * 10;
@@ -21,6 +21,7 @@ import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.ListNBT;
import javax.annotation.Nullable;
import java.util.UUID;
public final class ItemNBTHelper {
@@ -69,6 +70,10 @@ public final class ItemNBTHelper {
stack.getOrCreateTag().putString(tag, s);
}
public static void setUuid(ItemStack stack, String tag, UUID value) {
stack.getOrCreateTag().putUniqueId(tag, value);
}
public static void setList(ItemStack stack, String tag, ListNBT list) {
stack.getOrCreateTag().put(tag, list);
}
@@ -125,6 +130,11 @@ public final class ItemNBTHelper {
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getString(tag) : defaultExpected;
}
@Nullable
public static UUID getUuid(ItemStack stack, String tag) {
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getUniqueId(tag) : null;
}
public static ListNBT getList(ItemStack stack, String tag, int objtype, boolean nullifyOnFail) {
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getList(tag, objtype) : nullifyOnFail ? null : new ListNBT();
}
@@ -11,10 +11,11 @@
package vazkii.botania.common.crafting;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.VanillaRecipeTypes;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
@@ -598,9 +599,9 @@ public final class ModCraftingRecipes {
return Collections.emptyList();
String jsonGroup = group.toString();
return server.getRecipeManager().getRecipes(VanillaRecipeTypes.CRAFTING)
return server.getRecipeManager().getRecipes(IRecipeType.CRAFTING)
.stream()
.filter(r -> jsonGroup.equals(r.getGroup()))
.filter((ICraftingRecipe r) -> jsonGroup.equals(r.getGroup()))
.map(IRecipe::getId)
.collect(Collectors.toList());
}
@@ -36,6 +36,7 @@ import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.network.play.server.SRemoveEntityEffectPacket;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.potion.Effect;
import net.minecraft.potion.Effects;
import net.minecraft.potion.EffectInstance;
@@ -143,15 +144,14 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
private int mobSpawnTicks = 0;
private int playerCount = 0;
private boolean hardMode = false;
private BlockPos source = BlockPos.ORIGIN;
private BlockPos source = BlockPos.ZERO;
private final List<UUID> playersWhoAttacked = new ArrayList<>();
private final ServerBossInfo bossInfo = (ServerBossInfo) new ServerBossInfo(TYPE.getName(), BossInfo.Color.PINK, BossInfo.Overlay.PROGRESS).setCreateFog(true);;
private UUID bossInfoUUID = bossInfo.getUniqueId();
public PlayerEntity trueKiller = null;
public EntityDoppleganger(EntityType<EntityDoppleganger> type, World world) {
this(type, world);
isImmuneToFire = true;
super(type, world);
experienceValue = 825;
if(world.isRemote) {
Botania.proxy.addBoss(this);
@@ -238,12 +238,12 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
int playerCount = e.getPlayersAround().size();
e.playerCount = playerCount;
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP * playerCount);
e.getAttributes().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP * playerCount);
if(hard)
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ARMOR).setBaseValue(15);
e.getAttributes().getAttributeInstance(SharedMonsterAttributes.ARMOR).setBaseValue(15);
e.playSound(SoundEvents.ENTITY_ENDER_DRAGON_GROWL, 10F, 0.1F);
e.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(e)), null, null);
e.onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(e)), SpawnReason.EVENT, null, null);
world.addEntity(e);
}
@@ -279,9 +279,9 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
}
@Override
protected void initEntityAI() {
tasks.addTask(0, new SwimGoal(this));
tasks.addTask(1, new LookAtGoal(this, PlayerEntity.class, ARENA_RANGE * 1.5F));
protected void registerGoals() {
goalSelector.addGoal(0, new SwimGoal(this));
goalSelector.addGoal(1, new LookAtGoal(this, PlayerEntity.class, ARENA_RANGE * 1.5F));
}
@Override
@@ -395,9 +395,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
Vector3 motionVector = thisVector.subtract(playerVector).normalize().multiply(0.75);
if(getHealth() > 0) {
motionX = -motionVector.x;
motionY = 0.5;
motionZ = -motionVector.z;
setMotion(-motionVector.x, 0.5, -motionVector.z);
tpDelay = 4;
spawnPixies = aggro;
}
@@ -427,7 +425,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
}
@Override
public boolean canDespawn() {
public boolean canDespawn(double dist) {
return false;
}
@@ -437,14 +435,14 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
}
@Override
protected void dropLoot(boolean wasRecentlyHit, int lootingModifier, @Nonnull DamageSource source) {
protected void dropLoot(@Nonnull DamageSource source, boolean wasRecentlyHit) {
// Save true killer, they get extra loot
if (wasRecentlyHit && source.getTrueSource() instanceof PlayerEntity) {
trueKiller = (PlayerEntity) source.getTrueSource();
}
// Drop equipment and clear it so multiple calls to super don't do it again
super.dropEquipment(wasRecentlyHit, lootingModifier);
super.dropSpecialItems(source, 0, wasRecentlyHit);
for (EquipmentSlotType e : EquipmentSlotType.values()) {
setItemStackToSlot(e, ItemStack.EMPTY);
@@ -452,7 +450,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
// Generate loot table for every single attacking player
for (UUID u : playersWhoAttacked) {
PlayerEntity player = world.getPlayerEntityByUUID(u);
PlayerEntity player = world.getPlayerByUuid(u);
if (player == null)
continue;
@@ -465,7 +463,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
posX = player.posX; // Spoof pos so drops spawn at the player
posY = player.posY;
posZ = player.posZ;
super.dropLoot(wasRecentlyHit, lootingModifier, DamageSource.causePlayerDamage(player));
super.dropLoot(DamageSource.causePlayerDamage(player), wasRecentlyHit);
posX = savePosX;
posY = savePosY;
posZ = savePosZ;
@@ -564,9 +562,6 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
}
private void clearPotions(PlayerEntity player) {
int posXInt = MathHelper.floor(posX);
int posZInt = MathHelper.floor(posZ);
List<Effect> potionsToRemove = player.getActivePotionEffects().stream()
.filter(effect -> effect.getDuration() < 160 && effect.isAmbient() && !effect.getPotion().isBadEffect())
.map(EffectInstance::getPotion)
@@ -575,7 +570,8 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
potionsToRemove.forEach(potion -> {
player.removePotionEffect(potion);
((ServerWorld) world).getPlayerChunkMap().getEntry(posXInt >> 4, posZInt >> 4).sendPacket(new SRemoveEntityEffectPacket(player.getEntityId(), potion));
((ServerWorld) world).getChunkProvider().sendToTrackingAndSelf(player,
new SRemoveEntityEffectPacket(player.getEntityId(), potion));
});
}
@@ -585,9 +581,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
Vector3 playerVector = Vector3.fromEntityCenter(player);
Vector3 motion = sourceVector.subtract(playerVector).normalize();
player.motionX = motion.x;
player.motionY = 0.2;
player.motionZ = motion.z;
player.setMotion(motion.x, 0.2, motion.z);
player.velocityChanged = true;
}
}
@@ -600,14 +594,14 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
case 0: {
entity = new ZombieEntity(world);
if(world.rand.nextInt(hardMode ? 3 : 12) == 0) {
entity = new WitchEntity(world);
entity = EntityType.WITCH.create(world);
}
break;
}
case 1: {
entity = new SkeletonEntity(world);
entity = EntityType.SKELETON.create(world);
if(world.rand.nextInt(8) == 0) {
entity = new WitherSkeletonEntity(world);
entity = EntityType.WITHER_SKELETON.create(world);
}
break;
}
@@ -616,8 +610,9 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
for(int j = 0; j < 1 + world.rand.nextInt(hardMode ? 8 : 5); j++) {
EntityPixie pixie = new EntityPixie(world);
pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8);
pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2);
pixie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pixie)), null, null);
pixie.setPosition(posX + getWidth() / 2, posY + 2, posZ + getWidth() / 2);
pixie.onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(pixie)),
SpawnReason.MOB_SUMMONED, null, null);
world.addEntity(pixie);
}
}
@@ -629,8 +624,10 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
if(!entity.isImmuneToFire())
entity.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, 600, 0));
float range = 6F;
entity.setPosition(posX + 0.5 + Math.random() * range - range / 2, posY - 1, posZ + 0.5 + Math.random() * range - range / 2);
entity.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), null, null);
entity.setPosition(posX + 0.5 + Math.random() * range - range / 2, posY - 1,
posZ + 0.5 + Math.random() * range - range / 2);
entity.onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(entity)),
SpawnReason.MOB_SUMMONED, null, null);
if(entity instanceof WitherSkeletonEntity && hardMode) {
entity.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(ModItems.elementiumSword));
}
@@ -666,19 +663,19 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
List<PlayerEntity> players = getPlayersAround();
if(players.isEmpty() && !world.playerEntities.isEmpty())
if(players.isEmpty() && !world.getPlayers().isEmpty())
remove();
else {
for(PlayerEntity player : players) {
for(EquipmentSlotType e : EquipmentSlotType.values()) {
if(e.getSlotType() == EquipmentSlotType.Type.ARMOR && !player.getItemStackFromSlot(e).isEmpty()) {
if(e.getSlotType() == EquipmentSlotType.Group.ARMOR && !player.getItemStackFromSlot(e).isEmpty()) {
anyWithArmor = true;
break;
}
}
//also see SleepingHandler
if(player.isPlayerSleeping()) player.wakeUpPlayer(true, true, false);
if(player.isSleeping()) player.wakeUpPlayer(true, true, false);
clearPotions(player);
keepInsideArena(player);
@@ -686,7 +683,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
}
}
if(removed)
if(!isAlive())
return;
boolean spawnMissiles = hardMode && ticksExisted % 15 < 4;
@@ -701,18 +698,16 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
setHealth(getHealth() + (getMaxHealth() - 1F) / SPAWN_TICKS);
setInvulTime(invul - 1);
motionY = 0;
setMotion(getMotion().getX(), 0, getMotion().getZ());
} else {
if(aggro) {
boolean dying = getHealth() / getMaxHealth() < 0.2;
if(dying && mobSpawnTicks > 0) {
motionX = 0;
motionY = 0;
motionZ = 0;
setMotion(Vec3d.ZERO);
int reverseTicks = MOB_SPAWN_TICKS - mobSpawnTicks;
if(reverseTicks < MOB_SPAWN_START_TICKS) {
motionY = 0.2;
setMotion(getMotion().getX(), 0.2, getMotion().getZ());
setInvulTime(invul + 1);
}
@@ -756,8 +751,9 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
for(int i = 0; i < (spawnPixies ? world.rand.nextInt(hardMode ? 6 : 3) : 1); i++) {
EntityPixie pixie = new EntityPixie(world);
pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8);
pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2);
pixie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pixie)), null, null);
pixie.setPosition(posX + getWidth() / 2, posY + 2, posZ + getWidth() / 2);
pixie.onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(pixie)),
SpawnReason.MOB_SUMMONED, null, null);
world.addEntity(pixie);
}
@@ -851,20 +847,21 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
float vx = (random.nextFloat() - 0.5F) * 0.2F;
float vy = (random.nextFloat() - 0.5F) * 0.2F;
float vz = (random.nextFloat() - 0.5F) * 0.2F;
double px = oldX + (newX - oldX) * progress + (random.nextDouble() - 0.5D) * width * 2.0D;
double py = oldY + (newY - oldY) * progress + random.nextDouble() * height;
double pz = oldZ + (newZ - oldZ) * progress + (random.nextDouble() - 0.5D) * width * 2.0D;
double px = oldX + (newX - oldX) * progress + (random.nextDouble() - 0.5D) * getWidth() * 2.0D;
double py = oldY + (newY - oldY) * progress + random.nextDouble() * getHeight();
double pz = oldZ + (newZ - oldZ) * progress + (random.nextDouble() - 0.5D) * getWidth() * 2.0D;
world.addParticle(ParticleTypes.PORTAL, px, py, pz, vx, vy, vz);
}
Vec3d oldPosVec = new Vec3d(oldX, oldY + height / 2, oldZ);
Vec3d newPosVec = new Vec3d(newX, newY + height / 2, newZ);
Vec3d oldPosVec = new Vec3d(oldX, oldY + getHeight() / 2, oldZ);
Vec3d newPosVec = new Vec3d(newX, newY + getHeight() / 2, newZ);
if(oldPosVec.squareDistanceTo(newPosVec) > 1) {
//damage players in the path of the teleport
for(PlayerEntity player : getPlayersAround()) {
RayTraceResult rtr = player.getBoundingBox().grow(0.25).calculateIntercept(oldPosVec, newPosVec);
if(rtr != null)
boolean hit = player.getBoundingBox().grow(0.25).rayTrace(oldPosVec, newPosVec)
.isPresent();
if(hit)
player.attackEntityFrom(DamageSource.causeMobDamage(this), 6);
}
@@ -15,6 +15,7 @@ import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.IPacket;
import net.minecraft.potion.Effects;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.potion.EffectInstance;
@@ -23,6 +24,7 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ModSounds;
@@ -96,4 +98,10 @@ public class EntityMagicLandmine extends Entity {
@Override
protected void writeAdditional(@Nonnull CompoundNBT var1) {
}
@Nonnull
@Override
public IPacket<?> createSpawnPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
}
@@ -40,6 +40,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
@@ -317,7 +318,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
particles();
setBurstMotion(motionX, motionY, motionZ);
setBurstMotion(getMotion().getX(), getMotion().getY(), getMotion().getZ());
fullManaLastTick = getMana() == getStartingMana();
@@ -391,9 +392,9 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
par1nbtTagCompound.putInt(TAG_SPREADER_Y, coords.getY());
par1nbtTagCompound.putInt(TAG_SPREADER_Z, coords.getZ());
par1nbtTagCompound.putDouble(TAG_LAST_MOTION_X, motionX);
par1nbtTagCompound.putDouble(TAG_LAST_MOTION_Y, motionY);
par1nbtTagCompound.putDouble(TAG_LAST_MOTION_Z, motionZ);
par1nbtTagCompound.putDouble(TAG_LAST_MOTION_X, getMotion().getX());
par1nbtTagCompound.putDouble(TAG_LAST_MOTION_Y, getMotion().getY());
par1nbtTagCompound.putDouble(TAG_LAST_MOTION_Z, getMotion().getZ());
UUID identity = getShooterUUID();
boolean hasShooter = identity != null;
@@ -498,7 +499,10 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
b = ob + (float) Math.random() * 0.125F;
}
size = osize + ((float) Math.random() - 0.5F) * 0.065F + (float) Math.sin(new Random(entityUniqueID.getMostSignificantBits()).nextInt(9001)) * 0.4F;
Botania.proxy.wispFX(posX, posY, posZ, r, g, b, 0.2F * size, (float) -motionX * 0.01F, (float) -motionY * 0.01F, (float) -motionZ * 0.01F);
Botania.proxy.wispFX(posX, posY, posZ, r, g, b, 0.2F * size,
(float) -getMotion().getX() * 0.01F,
(float) -getMotion().getY() * 0.01F,
(float) -getMotion().getZ() * 0.01F);
posX += diffVecNorm.x * distance;
posY += diffVecNorm.y * distance;
@@ -528,15 +532,20 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
@Override
protected void onImpact(@Nonnull RayTraceResult rtr) {
boolean collided = false;
BlockPos pos = null;
boolean dead = false;
if(rtr.entity == null) {
TileEntity tile = world.getTileEntity(rtr.getBlockPos());
BlockState state = world.getBlockState(rtr.getBlockPos());
if(rtr.getType() == RayTraceResult.Type.BLOCK) {
pos = ((BlockRayTraceResult) rtr).getPos();
TileEntity tile = world.getTileEntity(pos);
BlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if(block instanceof IManaCollisionGhost && ((IManaCollisionGhost) block).isGhost(state, world, rtr.getBlockPos()) && !(block instanceof IManaTrigger) || block instanceof BushBlock || block instanceof LeavesBlock)
if(block instanceof IManaCollisionGhost
&& ((IManaCollisionGhost) block).isGhost(state, world, pos)
&& !(block instanceof IManaTrigger)
|| block instanceof BushBlock
|| block instanceof LeavesBlock)
return;
if(BotaniaAPI.internalHandler.isBuildcraftPipe(tile))
@@ -551,23 +560,22 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
onRecieverImpact((IManaReceiver) tile, tile.getPos());
if(block instanceof IManaTrigger)
((IManaTrigger) block).onBurstCollision(this, world, rtr.getBlockPos());
((IManaTrigger) block).onBurstCollision(this, world, pos);
boolean ghost = block instanceof IManaCollisionGhost;
dead = !ghost;
if(ghost)
return;
}
collided = true;
}
ILensEffect lens = getLensInstance();
if(lens != null)
dead = lens.collideBurst(this, rtr, collidedTile != null && collidedTile instanceof IManaReceiver && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens());
dead = lens.collideBurst(this, rtr, collidedTile instanceof IManaReceiver
&& ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens());
if(collided && !hasAlreadyCollidedAt(rtr.getBlockPos()))
alreadyCollidedAt.add(rtr.getBlockPos());
if(pos != null && !hasAlreadyCollidedAt(pos))
alreadyCollidedAt.add(pos);
if(dead && isAlive()) {
if(!fake && world.isRemote) {
@@ -83,18 +83,16 @@ public class EntityPixie extends FlyingEntity {
protected void updateAITasks() {
LivingEntity target = getAttackTarget();
if(target != null) {
double d0 = target.posX + target.width / 2 - posX;
double d1 = target.posY + target.height / 2 - posY;
double d2 = target.posZ + target.width / 2 - posZ;
double d0 = target.posX + target.getWidth() / 2 - posX;
double d1 = target.posY + target.getHeight() / 2 - posY;
double d2 = target.posZ + target.getWidth() / 2 - posZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
float mod = 0.45F;
if(getPixieType() == 1)
mod = 0.1F;
motionX += d0 / d3 * mod;
motionY += d1 / d3 * mod;
motionZ += d2 / d3 * mod;
setMotion(d0 / d3 * mod, d1 / d3 * mod, d2 / d3 * mod);
if(Math.sqrt(d3) < 1F) {
if(summoner != null) {
@@ -110,7 +108,8 @@ public class EntityPixie extends FlyingEntity {
}
}
renderYawOffset = rotationYaw = -((float)Math.atan2(motionX, motionZ)) * 180.0F / (float)Math.PI;
renderYawOffset = rotationYaw = -((float)Math.atan2(getMotion().getX(), getMotion().getZ()))
* 180.0F / (float)Math.PI;
}
@Override
@@ -143,7 +142,7 @@ public class EntityPixie extends FlyingEntity {
}
@Override
public boolean canDespawn() {
public boolean canDespawn(double dist) {
return false;
}
@@ -13,6 +13,7 @@ package vazkii.botania.common.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.IPacket;
import net.minecraft.util.SoundEvents;
import net.minecraft.item.DyeColor;
import net.minecraft.nbt.CompoundNBT;
@@ -21,6 +22,7 @@ import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.lib.LibMisc;
@@ -89,6 +91,12 @@ public class EntitySignalFlare extends Entity {
nbttagcompound.putInt(FIRED_Y_TAG, getFiredAt());
}
@Nonnull
@Override
public IPacket<?> createSpawnPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
public void setColor(int color) {
dataManager.set(COLOR, color);
}
@@ -26,6 +26,8 @@ import net.minecraft.particles.ItemParticleData;
import net.minecraft.state.BooleanProperty;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -75,13 +77,13 @@ public class EntityVineBall extends ThrowableEntity {
}
@Override
protected void onImpact(@Nonnull RayTraceResult var1) {
protected void onImpact(@Nonnull RayTraceResult rtr) {
if(!world.isRemote) {
if(var1 != null) {
Direction dir = var1.sideHit;
if(rtr.getType() == RayTraceResult.Type.BLOCK) {
Direction dir = ((BlockRayTraceResult) rtr).getFace();
if(dir != null && dir.getAxis() != Direction.Axis.Y) {
BlockPos pos = var1.getBlockPos().offset(dir);
if(dir.getAxis() != Direction.Axis.Y) {
BlockPos pos = ((BlockRayTraceResult) rtr).getPos().offset(dir);
boolean first = true;
while(pos.getY() > 0) {
BlockState state = world.getBlockState(pos);
@@ -61,6 +61,7 @@ public final class ModEntities {
.setRegistryName(LibEntityNames.VINE_BALL));
evt.getRegistry().register(EntityType.Builder.<EntityDoppleganger>create(EntityDoppleganger::new, EntityClassification.MONSTER)
.size(0.6F, 1.8F)
.immuneToFire()
.setTrackingRange(128)
.setUpdateInterval(10)
.setShouldReceiveVelocityUpdates(true)
@@ -43,6 +43,7 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -71,8 +72,8 @@ public class ItemBottledMana extends ItemMod {
public void effect(ItemStack stack, LivingEntity living, int id) {
switch(id) {
case 0 : { // Random motion
living.motionX = (Math.random() - 0.5) * 3;
living.motionZ = (Math.random() - 0.5) * 3;
living.setMotion((Math.random() - 0.5) * 3, living.getMotion().getY(),
(Math.random() - 0.5) * 3);
break;
}
case 1 : { // Water
@@ -87,14 +88,15 @@ public class ItemBottledMana extends ItemMod {
}
case 3 : { // Mini Explosion
if(!living.world.isRemote)
living.world.createExplosion(null, living.posX, living.posY, living.posZ, 0.25F, false);
living.world.createExplosion(null, living.posX, living.posY,
living.posZ, 0.25F, Explosion.Mode.NONE);
break;
}
case 4 : { // Mega Jump
if(!living.world.getDimension().isNether()) {
if(!living.world.isRemote)
living.addPotionEffect(new EffectInstance(Effects.RESISTANCE, 300, 5));
living.motionY = 6;
living.setMotion(living.getMotion().getX(), 6, living.getMotion().getZ());
}
break;
@@ -39,6 +39,7 @@ import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.WorkbenchContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResult;
@@ -57,11 +58,9 @@ import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.IInteractionObject;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.crafting.VanillaRecipeTypes;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
@@ -86,6 +85,7 @@ import vazkii.botania.common.lib.LibGuiIDs;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Optional;
public class ItemCraftingHalo extends ItemMod {
@@ -176,11 +176,14 @@ public class ItemCraftingHalo extends ItemMod {
}
private static ItemStack[] validateRecipe(PlayerEntity player, ItemStack stack, ItemStack[] recipe, int slot) {
CraftingInventory fakeInv = new CraftingInventory(new WorkbenchContainer(player.inventory, player.world, BlockPos.ORIGIN), 3, 3);
CraftingInventory fakeInv = new CraftingInventory(new WorkbenchContainer(-1, player.inventory), 3, 3);
for(int i = 0; i < 9; i++)
fakeInv.setInventorySlotContents(i, recipe[i]);
ItemStack result = player.world.getRecipeManager().getResult(fakeInv, player.world, VanillaRecipeTypes.CRAFTING);
ItemStack result = player.world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, fakeInv, player.world)
.map(r -> r.getCraftingResult(fakeInv))
.orElse(ItemStack.EMPTY);
if(result.isEmpty()) {
assignRecipe(stack, recipe[9], slot);
return null;
@@ -343,24 +346,28 @@ public class ItemCraftingHalo extends ItemMod {
private void saveRecipeToStack(ItemCraftedEvent event, ItemStack stack) {
CompoundNBT cmp = new CompoundNBT();
ItemStack result = event.getPlayer().world.getRecipeManager().getResult(event.getInventory(), event.getPlayer().world, VanillaRecipeTypes.CRAFTING);
if(!result.isEmpty()) {
cmp.put(TAG_ITEM_PREFIX + 9, result.write(new CompoundNBT()));
if(event.getInventory() instanceof CraftingInventory) {
Optional<ItemStack> result = event.getPlayer().world.getRecipeManager().getRecipe(IRecipeType.CRAFTING,
(CraftingInventory) event.getInventory(), event.getPlayer().world)
.map(r -> r.getCraftingResult((CraftingInventory) event.getInventory()));
if(result.isPresent() && !result.get().isEmpty()) {
cmp.put(TAG_ITEM_PREFIX + 9, result.get().write(new CompoundNBT()));
for(int i = 0; i < 9; i++) {
CompoundNBT ingr = new CompoundNBT();
ItemStack stackSlot = event.getInventory().getStackInSlot(i);
for(int i = 0; i < 9; i++) {
CompoundNBT ingr = new CompoundNBT();
ItemStack stackSlot = event.getInventory().getStackInSlot(i);
if(!stackSlot.isEmpty()) {
ItemStack writeStack = stackSlot.copy();
writeStack.setCount(1);
ingr = writeStack.write(new CompoundNBT());
if(!stackSlot.isEmpty()) {
ItemStack writeStack = stackSlot.copy();
writeStack.setCount(1);
ingr = writeStack.write(new CompoundNBT());
}
cmp.put(TAG_ITEM_PREFIX + i, ingr);
}
cmp.put(TAG_ITEM_PREFIX + i, ingr);
}
}
ItemNBTHelper.setCompound(stack, TAG_LAST_CRAFTING, cmp);
ItemNBTHelper.setCompound(stack, TAG_LAST_CRAFTING, cmp);
}
}
private static ItemStack[] getCraftingItems(ItemStack stack, int slot) {
@@ -432,7 +439,7 @@ public class ItemCraftingHalo extends ItemMod {
double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;
GlStateManager.translated(posX - renderPosX, posY - renderPosY + player.getDefaultEyeHeight(), posZ - renderPosZ);
GlStateManager.translated(posX - renderPosX, posY - renderPosY + player.getEyeHeight(), posZ - renderPosZ);
float base = getRotationBase(stack);
@@ -534,8 +541,8 @@ public class ItemCraftingHalo extends ItemMod {
int x = mc.mainWindow.getScaledWidth() / 2 - l / 2;
int y = mc.mainWindow.getScaledHeight() / 2 - 65;
AbstractGui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x22000000);
AbstractGui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x22000000);
AbstractGui.fill(x - 6, y - 6, x + l + 6, y + 37, 0x22000000);
AbstractGui.fill(x - 4, y - 4, x + l + 4, y + 35, 0x22000000);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableRescaleNormal();
mc.getItemRenderer().renderItemAndEffectIntoGUI(craftingTable, mc.mainWindow.getScaledWidth() / 2 - 8, mc.mainWindow.getScaledHeight() / 2 - 52);
@@ -566,11 +573,11 @@ public class ItemCraftingHalo extends ItemMod {
int x = mc.mainWindow.getScaledWidth() / 2 - 45;
int y = mc.mainWindow.getScaledHeight() / 2 - 90;
AbstractGui.drawRect(x - 6, y - 6, x + 90 + 6, y + 60, 0x22000000);
AbstractGui.drawRect(x - 4, y - 4, x + 90 + 4, y + 58, 0x22000000);
AbstractGui.fill(x - 6, y - 6, x + 90 + 6, y + 60, 0x22000000);
AbstractGui.fill(x - 4, y - 4, x + 90 + 4, y + 58, 0x22000000);
AbstractGui.drawRect(x + 66, y + 14, x + 92, y + 40, 0x22000000);
AbstractGui.drawRect(x - 2, y - 2, x + 56, y + 56, 0x22000000);
AbstractGui.fill(x + 66, y + 14, x + 92, y + 40, 0x22000000);
AbstractGui.fill(x - 2, y - 2, x + 56, y + 56, 0x22000000);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableRescaleNormal();
@@ -579,7 +586,7 @@ public class ItemCraftingHalo extends ItemMod {
if(!stack.isEmpty()) {
int xpos = x + i % 3 * 18;
int ypos = y + i / 3 * 18;
AbstractGui.drawRect(xpos, ypos, xpos + 16, ypos + 16, 0x22000000);
AbstractGui.fill(xpos, ypos, xpos + 16, ypos + 16, 0x22000000);
mc.getItemRenderer().renderItemAndEffectIntoGUI(stack, xpos, ypos);
}
@@ -11,9 +11,12 @@
package vazkii.botania.common.item;
import net.minecraft.block.Block;
import net.minecraft.block.EnderChestBlock;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ChestContainer;
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents;
@@ -48,9 +51,12 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) {
ItemStack stack = player.getHeldItem(hand);
if(ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) {
if(!player.world.isRemote)
player.displayGUIChest(player.getInventoryEnderChest());
ManaItemHandler.requestManaExact(stack, player, COST_SELF, true);
if(!player.world.isRemote) {
player.openContainer(new SimpleNamedContainerProvider((windowId, playerInv, p) -> {
return ChestContainer.createGeneric9X3(windowId, playerInv, p.getInventoryEnderChest());
}, EnderChestBlock.field_220115_d));
ManaItemHandler.requestManaExact(stack, player, COST_SELF, true);
}
player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 1F, 1F);
return ActionResult.newResult(ActionResultType.SUCCESS, stack);
}
@@ -60,8 +66,12 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
@Override
public boolean itemInteractionForEntity(ItemStack stack, PlayerEntity player, LivingEntity entity, Hand hand) {
if(ConfigHandler.COMMON.enderPickpocketEnabled.get() && entity instanceof PlayerEntity && ManaItemHandler.requestManaExact(stack, player, COST_OTHER, false)) {
if(!player.world.isRemote)
player.displayGUIChest(((PlayerEntity) entity).getInventoryEnderChest());
if(!player.world.isRemote) {
PlayerEntity other = (PlayerEntity) entity;
player.openContainer(new SimpleNamedContainerProvider((windowId, playerInv, p) -> {
return ChestContainer.createGeneric9X3(windowId, playerInv, other.getInventoryEnderChest());
}, EnderChestBlock.field_220115_d));
}
ManaItemHandler.requestManaExact(stack, player, COST_OTHER, true);
player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 1F, 1F);
return true;
@@ -218,7 +218,8 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
*/
public boolean tick() {
if(++ticksExisted % 20 == 0) {
for(BlockPos pos : BlockPos.getAllInBox(startCoords.add(-RANGE, 0, -RANGE), startCoords.add(RANGE, 0, RANGE))) {
for(BlockPos pos : BlockPos.getAllInBoxMutable(startCoords.add(-RANGE, 0, -RANGE),
startCoords.add(RANGE, 0, RANGE))) {
if(world.getBlockState(pos) == stateToSet)
tickBlock(pos);
}
@@ -99,14 +99,15 @@ public class ItemHorn extends ItemMod {
int rangeY = 3 + type.ordinal() * 4;
List<BlockPos> coords = new ArrayList<>();
for(BlockPos pos : BlockPos.getAllInBox(srcPos.add(-range, -rangeY, -range), srcPos.add(range, rangeY, range))) {
for(BlockPos pos : BlockPos.getAllInBoxMutable(srcPos.add(-range, -rangeY, -range),
srcPos.add(range, rangeY, range))) {
Block block = world.getBlockState(pos).getBlock();
if(block instanceof IHornHarvestable
? ((IHornHarvestable) block).canHornHarvest(world, pos, stack, type)
: type == EnumHornType.WILD && block instanceof BushBlock && !(block instanceof ISpecialFlower)
|| type == EnumHornType.CANOPY && BlockTags.LEAVES.contains(block)
|| type == EnumHornType.COVERING && block == Blocks.SNOW)
coords.add(pos);
coords.add(pos.toImmutable());
}
Collections.shuffle(coords, world.rand);
@@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
@@ -42,7 +42,10 @@ public class ItemKeepIvy extends ItemMod {
}
@SubscribeEvent
public static void onPlayerDrops(PlayerDropsEvent event) {
public static void onPlayerDrops(LivingDropsEvent event) {
if(!(event.getEntityLiving() instanceof PlayerEntity))
return;
List<ItemEntity> keeps = new ArrayList<>();
for(ItemEntity item : event.getDrops()) {
ItemStack stack = item.getItem();
@@ -64,7 +67,7 @@ public class ItemKeepIvy extends ItemMod {
i++;
}
CompoundNBT data = event.getEntityPlayer().getEntityData();
CompoundNBT data = event.getEntityLiving().getEntityData();
if(!data.contains(PlayerEntity.PERSISTED_NBT_TAG))
data.put(PlayerEntity.PERSISTED_NBT_TAG, new CompoundNBT());
@@ -225,9 +225,7 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
int targetDistance = BASE_OFFSET;
ThrowableEntity entity = (ThrowableEntity) burst;
if(!entity.world.isRemote) {
entity.motionX = 0;
entity.motionY = speed;
entity.motionZ = 0;
entity.setMotion(0, speed, 0);
final int spawnTicks = 2;
final int placeTicks = net.minecraft.util.math.MathHelper.floor(targetDistance / speed);
@@ -276,7 +274,8 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
ThrowableEntity entity = (ThrowableEntity) burst;
ItemStack lens = burst.getSourceLens();
BlockState state = NBTUtil.readBlockState(lens.getOrCreateTag().getCompound(TAG_STATE));
entity.world.addParticle(new BlockParticleData(ParticleTypes.BLOCK, state), entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ);
entity.world.addParticle(new BlockParticleData(ParticleTypes.BLOCK, state), entity.posX, entity.posY, entity.posZ,
entity.getMotion().getX(), entity.getMotion().getY(), entity.getMotion().getZ());
return true;
}
@@ -30,6 +30,7 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
@@ -97,7 +98,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
return ActionResultType.SUCCESS;
}
} else if(world.isRemote) {
RayTraceResult mop = new RayTraceResult(new Vec3d(ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()), ctx.getFace(), pos);
BlockRayTraceResult mop = new BlockRayTraceResult(ctx.getHitVec(), ctx.getFace(), pos, ctx.func_221533_k());
return Botania.proxy.openWikiPage(world, block, mop) ? ActionResultType.SUCCESS : ActionResultType.FAIL;
}
}
@@ -121,7 +122,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
if(Screen.isShiftKeyDown()) {
if(Screen.hasShiftDown()) {
ITextComponent edition = new TranslationTextComponent("botaniamisc.edition", getEdition()).applyTextStyle(TextFormatting.GOLD);
if(!edition.getString().isEmpty())
stacks.add(edition);
@@ -91,9 +91,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
UseItemSuccessTrigger.INSTANCE.trigger((ServerPlayerEntity) player, stack, (ServerWorld) world, player.posX, player.posY, player.posZ);
} else {
player.swingArm(hand);
player.motionX -= burst.motionX * 0.1;
player.motionY -= burst.motionY * 0.3;
player.motionZ -= burst.motionZ * 0.1;
player.setMotion(player.getMotion().subtract(burst.getMotion().mul(0.1, 0.3, 0.1)));
}
stack.setDamage(effCd);
} else if(!world.isRemote)
@@ -161,7 +159,9 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
burst.setMinManaLoss(props.ticksBeforeManaLoss);
burst.setManaLossPerTick(props.manaLossPerTick);
burst.setGravity(props.gravity);
burst.setBurstMotion(burst.motionX * props.motionModifier, burst.motionY * props.motionModifier, burst.motionZ * props.motionModifier);
burst.setBurstMotion(burst.getMotion().getX() * props.motionModifier,
burst.getMotion().getY() * props.motionModifier,
burst.getMotion().getZ() * props.motionModifier);
return burst;
}
@@ -172,7 +172,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
@Override
public void addInformation(ItemStack stack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
boolean clip = hasClip(stack);
if(clip && !Screen.isShiftKeyDown()) {
if(clip && !Screen.hasShiftDown()) {
stacks.add(new TranslationTextComponent("botaniamisc.shiftinfo"));
return;
}
@@ -44,7 +44,8 @@ public class ItemObedienceStick extends ItemMod {
BiFunction<TileEntitySpecialFlower, TileEntity, Boolean> act = pool ? functionalActuator : generatingActuator;
int range = pool ? TileEntityFunctionalFlower.LINK_RANGE : TileEntityGeneratingFlower.LINK_RANGE;
for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range))) {
for(BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range),
pos.add(range, range, range))) {
if(pos_.distanceSq(pos) > range * range)
continue;
@@ -12,6 +12,7 @@ package vazkii.botania.common.item;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.entity.player.PlayerEntity;
@@ -61,7 +62,7 @@ public class ItemPinkinator extends ItemMod {
wither.remove();
EntityPinkWither pink = new EntityPinkWither(world);
pink.setLocationAndAngles(wither.posX, wither.posY, wither.posZ, wither.rotationYaw, wither.rotationPitch);
pink.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pink)), null, null);
pink.onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(pink)), SpawnReason.CONVERSION, null, null);
world.addEntity(pink);
pink.spawnExplosionParticle();
pink.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 4F, (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
@@ -22,6 +22,10 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
@@ -105,12 +109,13 @@ public class ItemSextant extends ItemMod {
ItemStack stack = player.getHeldItem(hand);
if(!player.isSneaking()) {
RayTraceResult pos = ToolCommons.raytraceFromEntity(world, player, false, 128);
if(pos != null && pos.entity == null && pos.getBlockPos() != null) {
RayTraceResult rtr = ToolCommons.raytraceFromEntity(world, player, RayTraceContext.FluidMode.NONE, 128);
if(rtr.getType() == RayTraceResult.Type.BLOCK) {
if(!world.isRemote) {
ItemNBTHelper.setInt(stack, TAG_SOURCE_X, pos.getBlockPos().getX());
ItemNBTHelper.setInt(stack, TAG_SOURCE_Y, pos.getBlockPos().getY());
ItemNBTHelper.setInt(stack, TAG_SOURCE_Z, pos.getBlockPos().getZ());
BlockPos pos = ((BlockRayTraceResult) rtr).getPos();
ItemNBTHelper.setInt(stack, TAG_SOURCE_X, pos.getX());
ItemNBTHelper.setInt(stack, TAG_SOURCE_Y, pos.getY());
ItemNBTHelper.setInt(stack, TAG_SOURCE_Z, pos.getZ());
}
} else ItemNBTHelper.setInt(stack, TAG_SOURCE_Y, -1);
@@ -56,9 +56,7 @@ public class ItemSlingshot extends ItemMod {
EntityVineBall ball = new EntityVineBall(living, false);
ball.shoot(living, living.rotationPitch, living.rotationYaw, 0F, 1.5F, 1F);
ball.motionX *= 1.6;
ball.motionY *= 1.6;
ball.motionZ *= 1.6;
ball.setMotion(ball.getMotion().scale(1.6));
world.addEntity(ball);
world.playSound(null, living.posX, living.posY, living.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
}
@@ -135,7 +135,7 @@ public class ItemSpawnerMover extends ItemMod {
}
if(ctx.getPlayer() != null)
ctx.getPlayer().renderBrokenItemStack(mover);
ctx.getPlayer().sendBreakAnimation(ctx.getHand());
mover.shrink(1);
} else {
for(int i = 0; i < 100; i++)
@@ -162,7 +162,7 @@ public class ItemSpawnerMover extends ItemMod {
if(player != null) {
player.getCooldownTracker().setCooldown(this, 20);
UseItemSuccessTrigger.INSTANCE.trigger((ServerPlayerEntity) player, stack, (ServerWorld) world, pos.getX(), pos.getY(), pos.getZ());
player.renderBrokenItemStack(stack);
player.sendBreakAnimation(ctx.getHand());
}
} else {
for(int i = 0; i < 50; i++) {
@@ -34,6 +34,8 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
@@ -311,8 +313,8 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
return bound;
RayTraceResult pos = Minecraft.getInstance().objectMouseOver;
if(pos != null && pos.type == RayTraceResult.Type.BLOCK) {
TileEntity tile = Minecraft.getInstance().world.getTileEntity(pos.getBlockPos());
if(pos != null && pos.getType() == RayTraceResult.Type.BLOCK) {
TileEntity tile = Minecraft.getInstance().world.getTileEntity(((BlockRayTraceResult) pos).getPos());
if(tile instanceof ITileBound) {
return ((ITileBound) tile).getBinding();
}
@@ -13,6 +13,7 @@ package vazkii.botania.common.item;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.ai.attributes.AbstractAttributeMap;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
@@ -81,23 +82,23 @@ public class ItemVirus extends ItemMod {
if(!saddle.isEmpty())
newHorse.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new).insertItem(0, saddle, false);
AbstractAttributeMap oldAttributes = horse.getAttributeMap();
AbstractAttributeMap attributes = newHorse.getAttributeMap();
AbstractAttributeMap oldAttributes = horse.getAttributes();
AbstractAttributeMap attributes = newHorse.getAttributes();
IAttributeInstance movementSpeed = attributes.getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED);
movementSpeed.setBaseValue(oldAttributes.getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED).getBaseValue());
movementSpeed.applyModifier(new AttributeModifier("Ermergerd Virus D:", movementSpeed.getBaseValue(), 0));
movementSpeed.applyModifier(new AttributeModifier("Ermergerd Virus D:", movementSpeed.getBaseValue(), AttributeModifier.Operation.ADDITION));
IAttributeInstance health = attributes.getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH);
health.setBaseValue(oldAttributes.getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).getBaseValue());
health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), 0));
health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), AttributeModifier.Operation.ADDITION));
IAttributeInstance jumpHeight = attributes.getAttributeInstance(AbstractHorseEntity.JUMP_STRENGTH);
jumpHeight.setBaseValue(oldAttributes.getAttributeInstance(AbstractHorseEntity.JUMP_STRENGTH).getBaseValue());
jumpHeight.applyModifier(new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0));
jumpHeight.applyModifier(new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, AttributeModifier.Operation.ADDITION));
newHorse.playSound(SoundEvents.ENTITY_ZOMBIE_VILLAGER_CURE, 1.0F + living.world.rand.nextFloat(), living.world.rand.nextFloat() * 0.7F + 1.3F);
newHorse.onInitialSpawn(player.world.getDifficultyForLocation(new BlockPos(newHorse)), null, null);
newHorse.onInitialSpawn(player.world, player.world.getDifficultyForLocation(new BlockPos(newHorse)), SpawnReason.CONVERSION, null, null);
newHorse.setGrowingAge(horse.getGrowingAge());
player.world.addEntity(newHorse);
newHorse.spawnExplosionParticle();
@@ -51,7 +51,10 @@ public class ItemWorldSeed extends ItemMod {
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1F, 1F);
for(int i = 0; i < 50; i++)
Botania.proxy.sparkleFX(player.posX + Math.random() * player.width, player.posY - 1.6 + Math.random() * player.height, player.posZ + Math.random() * player.width, 0.25F, 1F, 0.25F, 1F, 10);
Botania.proxy.sparkleFX(player.posX + Math.random() * player.getWidth(),
player.posY - 1.6 + Math.random() * player.getHeight(),
player.posZ + Math.random() * player.getWidth(),
0.25F, 1F, 0.25F, 1F, 10);
stack.shrink(1);
return ActionResult.newResult(ActionResultType.SUCCESS, stack);
@@ -45,9 +45,9 @@ public class ItemBalanceCloak extends ItemHolyCloak {
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.holyCloak, SoundCategory.PLAYERS, 1F, 1F);
for(int i = 0; i < 30; i++) {
double x = player.posX + Math.random() * player.width * 2 - player.width;
double y = player.posY + Math.random() * player.height;
double z = player.posZ + Math.random() * player.width * 2 - player.width;
double x = player.posX + Math.random() * player.getWidth() * 2 - player.getWidth();
double y = player.posY + Math.random() * player.getHeight();
double z = player.posZ + Math.random() * player.getWidth() * 2 - player.getWidth();
boolean green = Math.random() > 0.5;
Botania.proxy.sparkleFX(x, y, z, 0.3F, green ? 1F : 0.3F, green ? 0.3F : 1F, 0.8F + (float) Math.random() * 0.4F, 3);
}
@@ -57,7 +57,7 @@ public abstract class ItemBauble extends ItemMod implements ICosmeticAttachable,
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
if(Screen.isShiftKeyDown())
if(Screen.hasShiftDown())
addHiddenTooltip(par1ItemStack, world, stacks, flags);
else stacks.add(new TranslationTextComponent("botaniamisc.shiftinfo"));
}
@@ -138,7 +138,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lightmapX, lightmapY);
}
GlStateManager.color3f(1, 1, 1);
}
@@ -44,8 +44,8 @@ public class ItemCloudPendant extends ItemBauble {
@Override
public void onWornTick(ItemStack stack, LivingEntity player) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
if(player instanceof EntityPlayerSP && player == Minecraft.getInstance().player) {
EntityPlayerSP playerSp = (EntityPlayerSP) player;
if(player == Minecraft.getInstance().player) {
ClientPlayerEntity playerSp = (ClientPlayerEntity) player;
if (playerSp.onGround)
timesJumped = 0;
@@ -29,6 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.concurrent.TickDelayedTask;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -55,9 +56,11 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem {
}
private void onEntityDamaged(LivingHurtEvent event) {
if(event.getSource().getImmediateSource() instanceof PlayerEntity && event.getEntityLiving() instanceof EntityLiving && !event.getEntityLiving().world.isRemote && Math.random() < 0.6F) {
if(event.getSource().getImmediateSource() instanceof PlayerEntity
&& event.getEntityLiving() instanceof MobEntity
&& !event.getEntityLiving().world.isRemote && Math.random() < 0.6F) {
Runnable lambda = () -> {
EntityLiving target = (EntityLiving) event.getEntityLiving();
MobEntity target = (MobEntity) event.getEntityLiving();
PlayerEntity player = (PlayerEntity) event.getSource().getImmediateSource();
ItemStack amulet = EquipmentHandler.findOrEmpty(ModItems.divaCharm, player);
@@ -85,10 +88,9 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem {
// Have to delay a tick because setAttackTarget(player) is called *after* the event fires, and we want to get rid of that
// addScheduledTask runs the lambda immediately if on the main thread, hence this trickery
// todo 1.14 make sure this still works
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
synchronized (server.futureTaskQueue) {
server.futureTaskQueue.add(ListenableFutureTask.create(lambda, null));
}
server.enqueue(new TickDelayedTask(server.getTickCounter(), lambda));
}
}
@@ -37,19 +37,19 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.village.MerchantRecipe;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.InvWrapper;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import java.util.ArrayList;
@@ -162,8 +162,8 @@ public class ItemItemFinder extends ItemBauble {
} else if(e instanceof PlayerEntity) {
PlayerEntity player_ = (PlayerEntity) e;
LazyOptional<IItemHandler> playerInv = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
LazyOptional<Collection<? extends IItemHandler>> binv = CuriosAPI.getCuriosHandler(player_).map(h -> h.getCurioMap().values());
if(scanInventory(playerInv, pstack) || scanInventories(binv, pstack))
LazyOptional<IItemHandlerModifiable> binv = EquipmentHandler.getAllWorn(player);
if(scanInventory(playerInv, pstack) || scanInventory(binv, pstack))
entIdBuilder.add(player_.getEntityId());
} else if(e instanceof VillagerEntity) {
@@ -207,16 +207,7 @@ public class ItemItemFinder extends ItemBauble {
return stack1.isItemEqual(stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2);
}
private boolean scanInventories(LazyOptional<Collection<? extends IItemHandler>> invs, ItemStack pstack) {
return invs.map(coll -> {
for(IItemHandler inv : coll)
if(scanInventory(inv, pstack))
return true;
return false;
}).orElse(false);
}
private boolean scanInventory(LazyOptional<IItemHandler> optInv, ItemStack pstack) {
private boolean scanInventory(LazyOptional<? extends IItemHandler> optInv, ItemStack pstack) {
return optInv.map(inv -> scanInventory(inv, pstack)).orElse(false);
}
@@ -22,25 +22,32 @@ import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.fml.common.Mod;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.core.handler.EquipmentHandler;
public class ItemSuperLavaPendant extends ItemBauble {
public ItemSuperLavaPendant(Properties props) {
super(props);
MinecraftForge.EVENT_BUS.addListener(this::onDamage);
}
private void onDamage(LivingHurtEvent evt) {
if(evt.getSource().isFireDamage()
&& !EquipmentHandler.findOrEmpty(this, evt.getEntityLiving()).isEmpty()) {
evt.setCanceled(true);
}
}
@Override
public void onWornTick(ItemStack stack, LivingEntity living) {
living.isImmuneToFire = true;
}
@Override
public void onUnequipped(ItemStack stack, LivingEntity living) {
living.isImmuneToFire = false;
if (living.isBurning())
living.extinguish();
}
@Override
@@ -18,6 +18,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.item.ISortableTool;
import vazkii.botania.api.item.ISortableTool.ToolType;
@@ -41,7 +42,8 @@ public class ItemSwapRing extends ItemBauble {
ISortableTool tool = (ISortableTool) currentStack.getItem();
RayTraceResult pos = ToolCommons.raytraceFromEntity(entity.world, entity, true, 4.5F);
RayTraceResult pos = ToolCommons.raytraceFromEntity(player.world, player,
RayTraceContext.FluidMode.SOURCE_ONLY, 4.5F);
ToolType typeToFind = null;
if(player.isSwingInProgress && pos.getType() == RayTraceResult.Type.BLOCK) {
@@ -11,7 +11,6 @@
package vazkii.botania.common.item.equipment.bauble;
import com.google.common.base.Predicates;
import com.sun.prism.AtlasTexture;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.texture.AtlasTexture;
@@ -23,6 +23,7 @@ import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelSword;
@@ -44,7 +45,7 @@ public class ItemEnderDagger extends ItemManasteelSword {
target.attackEntityFrom(DamageSource.causePlayerDamage((PlayerEntity) attacker), 20);
}
stack.damageItem(1, attacker);
stack.damageItem(1, attacker, e -> e.sendBreakAnimation(Hand.MAIN_HAND));
return true;
}
@@ -62,7 +63,8 @@ public class ItemEnderDagger extends ItemManasteelSword {
Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(equipmentSlot);
if (equipmentSlot == EquipmentSlotType.MAINHAND) {
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -1.25, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -1.25, AttributeModifier.Operation.ADDITION));
}
return multimap;
@@ -16,6 +16,9 @@ import net.minecraft.potion.Effects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPI;
@@ -41,18 +44,16 @@ public class ItemStarSword extends ItemManasteelSword {
float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F;
if(player.getHeldItemMainhand() == par1ItemStack && player.swingProgress == check && !world.isRemote) {
RayTraceResult pos = ToolCommons.raytraceFromEntity(world, par3Entity, true, 48);
if(pos != null && pos.type == RayTraceResult.Type.BLOCK) {
Vector3 posVec = Vector3.fromBlockPos(pos.getBlockPos());
RayTraceResult pos = ToolCommons.raytraceFromEntity(world, player, RayTraceContext.FluidMode.NONE, 48);
if(pos.getType() == RayTraceResult.Type.BLOCK) {
Vector3 posVec = Vector3.fromBlockPos(((BlockRayTraceResult) pos).getPos());
Vector3 motVec = new Vector3((0.5 * Math.random() - 0.25) * 18, 24, (0.5 * Math.random() - 0.25) * 18);
posVec = posVec.add(motVec);
motVec = motVec.normalize().negate().multiply(1.5);
EntityFallingStar star = new EntityFallingStar(player, world);
star.setPosition(posVec.x, posVec.y, posVec.z);
star.motionX = motVec.x;
star.motionY = motVec.y;
star.motionZ = motVec.z;
star.setMotion(motVec.toVec3D());
world.addEntity(star);
if (!world.isRaining()
@@ -60,9 +61,8 @@ public class ItemStarSword extends ItemManasteelSword {
&& Math.random() < 0.125) {
EntityFallingStar bonusStar = new EntityFallingStar(player, world);
bonusStar.setPosition(posVec.x, posVec.y, posVec.z);
bonusStar.motionX = motVec.x + Math.random() - 0.5;
bonusStar.motionY = motVec.y + Math.random() - 0.5;
bonusStar.motionZ = motVec.z + Math.random() - 0.5;
bonusStar.setMotion(motVec.x + Math.random() - 0.5,
motVec.y + Math.random() - 0.5, motVec.z + Math.random() - 0.5);
world.addEntity(bonusStar);
}
@@ -90,7 +90,8 @@ public class ItemThunderSword extends ItemManasteelSword {
if (equipmentSlot == EquipmentSlotType.MAINHAND) {
multimap.removeAll(SharedMonsterAttributes.ATTACK_SPEED.getName());
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -1.5, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -1.5, AttributeModifier.Operation.ADDITION));
}
return multimap;
@@ -6,6 +6,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
@@ -26,13 +27,10 @@ public class ItemElementiumShovel extends ItemManasteelShovel {
if (!ToolCommons.materialsShovel.contains(mat))
return false;
RayTraceResult block = ToolCommons.raytraceFromEntity(world, player, true, 10);
if (block == null)
return false;
Block blk = world.getBlockState(pos).getBlock();
if(blk instanceof FallingBlock)
ToolCommons.removeBlocksInIteration(player, stack, world, pos, new Vec3i(0, -12, 0), new Vec3i(1, 12, 1),
ToolCommons.removeBlocksInIteration(player, stack, world, pos, new Vec3i(0, -12, 0),
new Vec3i(1, 12, 1),
state -> state.getBlock() == blk,
false);
@@ -28,6 +28,7 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.api.distmarker.Dist;
@@ -87,7 +88,14 @@ public class ItemManasteelAxe extends AxeItem implements IManaUsingItem, ISortab
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(!stackAt.isEmpty() && SAPLING_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) {
ActionResultType did = stackAt.getItem().onItemUse(new ItemUseContext(player, stackAt, ctx.getPos(), ctx.getFace(), ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()));
ItemStack save = player.getHeldItem(ctx.getHand());
player.setHeldItem(ctx.getHand(), stackAt);
BlockRayTraceResult hit = new BlockRayTraceResult(ctx.getHitVec(), ctx.getFace(),
ctx.getPos(), ctx.func_221533_k());
ActionResultType did = stackAt.getItem().onItemUse(new ItemUseContext(player, ctx.getHand(), hit));
player.setHeldItem(ctx.getHand(), save);
ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.OAK_SAPLING), SAPLING_PATTERN);
return did;
}
@@ -24,6 +24,7 @@ import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.ISortableTool;
@@ -72,7 +73,14 @@ public class ItemManasteelPick extends PickaxeItem implements IManaUsingItem, IS
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(!stackAt.isEmpty() && TORCH_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) {
ActionResultType did = stackAt.getItem().onItemUse(new ItemUseContext(player, stackAt, ctx.getPos(), ctx.getFace(), ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()));
ItemStack save = player.getHeldItem(ctx.getHand());
player.setHeldItem(ctx.getHand(), stackAt);
BlockRayTraceResult hit = new BlockRayTraceResult(ctx.getHitVec(), ctx.getFace(),
ctx.getPos(), ctx.func_221533_k());
ActionResultType did = stackAt.getItem().onItemUse(new ItemUseContext(player, ctx.getHand(), hit));
player.setHeldItem(ctx.getHand(), save);
ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.TORCH), TORCH_PATTERN);
return did;
}
@@ -104,7 +104,10 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I
if(block == block1)
block1 = Blocks.FARMLAND;
world.playSound(null, pos, block1.getSoundType().getStepSound(), SoundCategory.BLOCKS, (block1.getSoundType().getVolume() + 1.0F) / 2.0F, block1.getSoundType().getPitch() * 0.8F);
world.playSound(null, pos, block1.getDefaultState().getSoundType().getStepSound(),
SoundCategory.BLOCKS,
(block1.getDefaultState().getSoundType().getVolume() + 1.0F) / 2.0F,
block1.getDefaultState().getSoundType().getPitch() * 0.8F);
if (world.isRemote)
return ActionResultType.SUCCESS;
@@ -17,6 +17,9 @@ import net.minecraft.tags.BlockTags;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
@@ -90,10 +93,11 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
@Override
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, PlayerEntity player) {
RayTraceResult raycast = ToolCommons.raytraceFromEntity(player.world, player, true, 10);
if(raycast != null) {
breakOtherBlock(player, stack, pos, pos, raycast.sideHit);
ItemLokiRing.breakOnAllCursors(player, this, stack, pos, raycast.sideHit);
RayTraceResult raycast = ToolCommons.raytraceFromEntity(player.world, player, RayTraceContext.FluidMode.NONE, 10);
if(raycast.getType() == RayTraceResult.Type.BLOCK) {
Direction face = ((BlockRayTraceResult) raycast).getFace();
breakOtherBlock(player, stack, pos, pos, face);
ItemLokiRing.breakOnAllCursors(player, this, stack, pos, face);
}
return false;
@@ -29,6 +29,9 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.text.ITextComponent;
@@ -64,7 +67,9 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
private static final int MAX_MANA = Integer.MAX_VALUE;
private static final int MANA_PER_DAMAGE = 100;
private static final List<Material> MATERIALS = Arrays.asList(Material.ROCK, Material.IRON, Material.ICE, Material.GLASS, Material.PISTON, Material.ANVIL, Material.GRASS, Material.GROUND, Material.SAND, Material.SNOW, Material.CRAFTED_SNOW, Material.CLAY);
private static final List<Material> MATERIALS = Arrays.asList(Material.ROCK, Material.IRON, Material.ICE,
Material.GLASS, Material.PISTON, Material.ANVIL, Material.ORGANIC, Material.EARTH, Material.SAND,
Material.SNOW, Material.SNOW_BLOCK, Material.CLAY);
public static final int[] LEVELS = new int[] {
0, 10000, 1000000, 10000000, 100000000, 1000000000
@@ -140,10 +145,11 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
@Override
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, PlayerEntity player) {
RayTraceResult raycast = ToolCommons.raytraceFromEntity(player.world, player, true, 10);
if(!player.world.isRemote && raycast != null) {
breakOtherBlock(player, stack, pos, pos, raycast.sideHit);
ItemLokiRing.breakOnAllCursors(player, this, stack, pos, raycast.sideHit);
RayTraceResult raycast = ToolCommons.raytraceFromEntity(player.world, player, RayTraceContext.FluidMode.NONE, 10);
if(!player.world.isRemote && raycast.getType() == RayTraceResult.Type.BLOCK) {
Direction face = ((BlockRayTraceResult) raycast).getFace();
breakOtherBlock(player, stack, pos, pos, face);
ItemLokiRing.breakOnAllCursors(player, this, stack, pos, face);
// ^ Doable with API access through the IInternalMethodHandler.
}
@@ -36,10 +36,11 @@ import vazkii.botania.common.network.PacketHandler;
import vazkii.botania.common.network.PacketLeftClick;
import java.util.List;
import java.util.UUID;
public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
private static final String TAG_ATTACKER_USERNAME = "attackerUsername";
private static final String TAG_ATTACKER_UUID = "attackerUuid";
private static final int MANA_PER_DAMAGE = 100;
@@ -89,10 +90,11 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
burst.setMinManaLoss(40);
burst.setManaLossPerTick(4F);
burst.setGravity(0F);
burst.setBurstMotion(burst.motionX * motionModifier, burst.motionY * motionModifier, burst.motionZ * motionModifier);
burst.setBurstMotion(burst.getMotion().getX() * motionModifier,
burst.getMotion().getY() * motionModifier, burst.getMotion().getZ() * motionModifier);
ItemStack lens = stack.copy();
ItemNBTHelper.setString(lens, TAG_ATTACKER_USERNAME, player.getGameProfile().getName());
ItemNBTHelper.setUuid(lens, TAG_ATTACKER_UUID, player.getUniqueID());
burst.setSourceLens(lens);
return burst;
}
@@ -110,7 +112,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
ThrowableEntity entity = (ThrowableEntity) burst;
AxisAlignedBB axis = new AxisAlignedBB(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).grow(1);
List<LivingEntity> entities = entity.world.getEntitiesWithinAABB(LivingEntity.class, axis);
String attacker = ItemNBTHelper.getString(burst.getSourceLens(), TAG_ATTACKER_USERNAME, "");
UUID attacker = ItemNBTHelper.getUuid(burst.getSourceLens(), TAG_ATTACKER_UUID);
for(LivingEntity living : entities) {
if(living instanceof PlayerEntity && (living.getName().getString().equals(attacker) || ServerLifecycleHooks.getCurrentServer() != null && !ServerLifecycleHooks.getCurrentServer().isPVPEnabled()))
@@ -123,8 +125,10 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
burst.setMana(mana - cost);
float damage = 4F + BotaniaAPI.TERRASTEEL_ITEM_TIER.getAttackDamage();
if(!burst.isFake() && !entity.world.isRemote) {
PlayerEntity player = living.world.getPlayerEntityByName(attacker);
living.attackEntityFrom(player == null ? DamageSource.MAGIC : DamageSource.causePlayerDamage(player), damage);
PlayerEntity player = attacker != null ? living.world.getPlayerByUuid(attacker) : null;
living.attackEntityFrom(player == null
? DamageSource.MAGIC
: DamageSource.causePlayerDamage(player), damage);
entity.remove();
break;
}
@@ -39,8 +39,7 @@ public class LensWeight extends Lens {
if(entity.world.isAirBlock(bPos.down())
&& state.getBlockHardness(entity.world, bPos) != -1
&& neededHarvestLevel <= harvestLevel
&& entity.world.getTileEntity(bPos) == null
&& state.canSilkHarvest(entity.world, bPos, null)) {
&& entity.world.getTileEntity(bPos) == null) {
FallingBlockEntity falling = new FallingBlockEntity(entity.world, bPos.getX() + 0.5, bPos.getY(), bPos.getZ() + 0.5, state);
falling.fallTime = 1;
entity.world.removeBlock(bPos, false);
@@ -24,6 +24,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
@@ -367,8 +369,8 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
BlockState state = getState(stack);
RayTraceResult pos = Minecraft.getInstance().objectMouseOver;
if(pos != null && pos.getBlockPos() != null) {
BlockPos bPos = pos.getBlockPos();
if(pos != null && pos.getType() == RayTraceResult.Type.BLOCK) {
BlockPos bPos = ((BlockRayTraceResult) pos).getPos();
BlockState target = null;
if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) {
bPos = new BlockPos(
@@ -381,11 +383,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
if(!player.world.isAirBlock(bPos)) {
List<BlockPos> coordsList = getBlocksToSwap(player.world, stack, state, bPos, target);
for(BlockPos coords : coordsList)
if(coords.equals(bPos)) {
coordsList.remove(coords);
break;
}
coordsList.removeIf(bPos::equals);
return coordsList;
}
@@ -90,7 +90,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
dummyInv.setInventorySlotContents(0, new ItemStack(state.getBlock()));
Optional<ItemStack> maybeResult= p.world.getRecipeManager()
.getRecipe(IRecipeType.SMELTING, dummyInv, p.world)
.map(IRecipe::getRecipeOutput);
.map(r -> r.getCraftingResult(dummyInv));
if(maybeResult.isPresent()
&& !maybeResult.get().isEmpty()