Merge 1.12

This commit is contained in:
Vincent Lee committed 2019-09-13 18:12:46 -05:00
commit 7d318bb3bf
17 files changed
+1655 -1489

No files matched your search

@@ -10,6 +10,7 @@
*/
package vazkii.botania.api.lexicon;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull;
@@ -74,4 +75,14 @@ public class LexiconCategory implements Comparable<LexiconCategory> {
public int compareTo(@Nonnull LexiconCategory category) {
return priority == category.priority ? sortingId - category.sortingId : category.priority - priority;
}
/**
* Determines if the category shows up in the lexicon category index.
* Contained entries will still appear in the lexicon index
* and must be hidden separately if desired.
* @param stack The lexicon stack used by the player
*/
public boolean isVisible(ItemStack stack) {
return true;
}
}
@@ -13,11 +13,9 @@ package vazkii.botania.api.recipe;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.items.IItemHandler;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import java.util.ArrayList;
import java.util.List;
@@ -69,6 +69,9 @@ public final class ContributorFancinessHandler extends LayerRenderer<AbstractCli
@Override
public void render(@Nonnull AbstractClientPlayerEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
if(player.isInvisible())
return;
String name = player.getDisplayName().getString();
float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks;
@@ -165,9 +165,6 @@ public class GuiLexicon extends Screen {
// mc.updateWindowSize();
}
List<LexiconCategory> allCategories = new ArrayList<>(BotaniaAPI.getAllCategories());
Collections.sort(allCategories);
lastTime = ClientTickHandler.ticksInGame;
currentOpenLexicon = this;
@@ -184,6 +181,10 @@ public class GuiLexicon extends Screen {
}
populateIndex();
} else if(isCategoryIndex()) {
List<LexiconCategory> allCategories = new ArrayList<>(BotaniaAPI.getAllCategories());
allCategories.removeIf(cat -> !cat.isVisible(stackUsed));
Collections.sort(allCategories);
int categories = allCategories.size();
for(int i = 0; i < categories + 1; i++) {
LexiconCategory category;
@@ -82,6 +82,8 @@ public class TileCorporeaRetainer extends TileMod {
ICorporeaRequestor requestor = (ICorporeaRequestor) inv.world.getTileEntity(inv.pos);
requestor.doCorporeaRequest(request, requestCount, spark);
pendingRequest = false;
compValue = 0;
world.updateComparatorOutputLevel(getPos(), world.getBlockState(getPos()).getBlock());
}
}
@@ -140,35 +140,39 @@ public final class ItemNBTHelper {
}
/**
* Checks that one tag is a subset of another - that is, it's ok if the superset has more NBT keys than the subset, but the subset has to have at least all the same keys as the superset, and the values of the keys that *are* shared between the two must match.
*
* This is useful when, e.g. matching NBT tags in recipes.
* Returns true if the `target` tag contains all of the tags and values present in the `template` tag. Recurses into
* compound tags and matches all template keys and values; recurses into list tags and matches the template against
* the first elements of target. Empty lists and compounds in the template will match target lists and compounds of
* any size.
*/
public static boolean isTagSubset(@Nullable CompoundNBT subset, @Nullable CompoundNBT superset) {
//an empty set is a subset of everything
if(subset == null || subset.isEmpty()) return true;
//an empty set is a superset of only another empty set (which was already checked above)
if(superset == null || superset.isEmpty()) return false;
//a subset can't be bigger than its superset
if(subset.keySet().size() > superset.keySet().size()) return false;
public static boolean matchTag(@Nullable INBT template, @Nullable INBT target) {
if(template instanceof CompoundNBT && target instanceof CompoundNBT) {
return matchTagCompound((CompoundNBT) template, (CompoundNBT) target);
} else if(template instanceof ListNBT && target instanceof ListNBT) {
return matchTagList((ListNBT) template, (ListNBT) target);
} else {
return template == null || (target != null && target.equals(template));
}
}
private static boolean matchTagCompound(CompoundNBT template, CompoundNBT target) {
if(template.size() > target.size()) return false;
//it's not an easy case, so we actually have to check the contents of each tag
for(String key : superset.keySet()) {
//it's ok if the subset is missing a key from the superset
if(!subset.contains(key)) continue;
INBT supersetEntry = superset.get(key);
INBT subsetEntry = subset.get(key);
//if a value is present on both tags, but they do not match, fail
if(supersetEntry instanceof CompoundNBT && subsetEntry instanceof CompoundNBT) {
//recurse into tag compounds (this properly compares nested tag compounds)
if(!isTagSubset((CompoundNBT) subsetEntry, (CompoundNBT) supersetEntry)) return false;
} else {
if(!supersetEntry.equals(subsetEntry)) return false;
}
for(String key : template.keySet()) {
if (!matchTag(template.get(key), target.get(key))) return false;
}
return true;
}
private static boolean matchTagList(ListNBT template, ListNBT target) {
if (template.size() > target.size()) return false;
for (int i = 0; i < template.size(); i++) {
if (!matchTag(template.get(i), target.get(i))) return false;
}
return true;
}
}
@@ -21,7 +21,7 @@ public final class StringObfuscator {
return getHash(str).equals(hash);
}
public static String getHash(String str) {
private static String getHash(String str) {
if(str != null)
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
@@ -32,9 +32,10 @@ public final class StringObfuscator {
return "";
}
private static String dontRainbowTableMeOrMySonEverAgain(String str) {
private static String dontRainbowTableMeOrMySonEverAgain(String str) throws NoSuchAlgorithmException {
str += reverseString(str);
SecureRandom rand = new SecureRandom(str.getBytes());
SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
rand.setSeed(str.getBytes());
int l = str.length();
int steps = rand.nextInt(l);
char[] chrs = str.toCharArray();
@@ -52,10 +53,7 @@ public final class StringObfuscator {
}
private static String reverseString(String str) {
char[] chars = new char[str.length()];
for(int i = 0; i < chars.length; i++)
chars[i] = str.charAt(str.length() - 1 - i);
return String.copyValueOf(chars);
return new StringBuilder(str).reverse().toString();
}
}
@@ -1,51 +0,0 @@
package vazkii.botania.common.crafting;
import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.IIngredientSerializer;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import javax.annotation.Nullable;
import java.util.stream.Stream;
// Like Forge IngredientNBT but does subset checking instead of exact match for NBT tags
public class IngredientNBTSubset extends Ingredient {
private final ItemStack stack;
public IngredientNBTSubset(ItemStack stack) {
super(Stream.of(new Ingredient.SingleItemList(stack)));
this.stack = stack;
}
@Override
public boolean test(@Nullable ItemStack input) {
if(input == null)
return false;
return stack.getItem() == input.getItem() && ItemNBTHelper.isTagSubset(stack.getTag(), input.getTag());
}
@Override
public boolean isSimple() {
return false;
}
public static class Serializer implements IIngredientSerializer<IngredientNBTSubset> {
@Override
public IngredientNBTSubset parse(PacketBuffer buffer) {
return new IngredientNBTSubset(buffer.readItemStack());
}
@Override
public IngredientNBTSubset parse(JsonObject json) {
return new IngredientNBTSubset(CraftingHelper.getItemStack(json, true));
}
@Override
public void write(PacketBuffer buffer, IngredientNBTSubset ingredient) {
buffer.writeItemStack(ingredient.stack);
}
}
}
@@ -10,6 +10,7 @@
*/
package vazkii.botania.common.entity;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@@ -124,12 +125,12 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
private static final DataParameter<Integer> INVUL_TIME = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.VARINT);
private static final BlockPos[] PYLON_LOCATIONS = {
private static final List<BlockPos> PYLON_LOCATIONS = ImmutableList.of(
new BlockPos(4, 1, 4),
new BlockPos(4, 1, -4),
new BlockPos(-4, 1, 4),
new BlockPos(-4, 1, -4)
};
);
private static final List<ResourceLocation> CHEATY_BLOCKS = Arrays.asList(
new ResourceLocation("openblocks", "beartrap"),
@@ -195,25 +196,22 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
}
//check pylons
for(BlockPos coords : PYLON_LOCATIONS) {
BlockPos pos_ = pos.add(coords);
BlockState state = world.getBlockState(pos_);
if(state.getBlock() != ModBlocks.gaiaPylon) {
if(!world.isRemote)
player.sendMessage(new TranslationTextComponent("botaniamisc.needsCatalysts").setStyle(new Style().setColor(TextFormatting.RED)));
return false;
List<BlockPos> invalidPylonBlocks = checkPylons(world, pos);
if(!invalidPylonBlocks.isEmpty()) {
if(world.isRemote) {
warnInvalidBlocks(invalidPylonBlocks);
} else {
player.sendMessage(new TranslationTextComponent("botaniamisc.needsCatalysts").setStyle(new Style().setColor(TextFormatting.RED)));
}
return false;
}
//check arena shape
List<BlockPos> invalidArenaBlocks = checkArena(world, pos);
if(!invalidArenaBlocks.isEmpty()) {
if(world.isRemote) {
Botania.proxy.setWispFXDepthTest(false);
for(BlockPos pos_ : invalidArenaBlocks)
Botania.proxy.wispFX(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5, 1F, 0.2F, 0.2F, 0.5F, 0F, 8);
Botania.proxy.setWispFXDepthTest(true);
warnInvalidBlocks(invalidArenaBlocks);
} else {
PacketHandler.sendTo((ServerPlayerEntity) player,
new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ARENA_INDICATOR, pos.getX(), pos.getY(), pos.getZ()));
@@ -250,6 +248,21 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
return true;
}
private static List<BlockPos> checkPylons(World world, BlockPos beaconPos) {
List<BlockPos> invalidPylonBlocks = new ArrayList<>();
for(BlockPos coords : PYLON_LOCATIONS) {
BlockPos pos_ = beaconPos.add(coords);
BlockState state = world.getBlockState(pos_);
if(state.getBlock() != ModBlocks.gaiaPylon) {
invalidPylonBlocks.add(pos_);
}
}
return invalidPylonBlocks;
}
private static List<BlockPos> checkArena(World world, BlockPos beaconPos) {
List<BlockPos> trippedPositions = new ArrayList<>();
int range = (int) Math.ceil(ARENA_RANGE);
@@ -260,24 +273,41 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
if(Math.abs(x) == 4 && Math.abs(z) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(x, z, 0, 0) > ARENA_RANGE)
continue; // Ignore pylons and out of circle
for(int y = -1; y <= ARENA_HEIGHT; y++) {
boolean hasFloor = false;
for(int y = -2; y <= ARENA_HEIGHT; y++) {
if(x == 0 && y == 0 && z == 0)
continue; //this is the beacon
continue; //the beacon
pos = beaconPos.add(x, y, z);
boolean expectedBlockHere = y == -1; //the floor
boolean isBlockHere = !world.getBlockState(pos).getCollisionShape(world, pos).isEmpty();
BlockState state = world.getBlockState(pos);
if(expectedBlockHere != isBlockHere) {
boolean allowBlockHere = y < 0;
boolean isBlockHere = !state.getCollisionShape(world, pos).isEmpty();
if(allowBlockHere && isBlockHere) //floor is here! good
hasFloor = true;
if(y == 0 && !hasFloor) //column is entirely missing floor
trippedPositions.add(pos.down());
if(!allowBlockHere && isBlockHere && !BLACKLIST.contains(state.getBlock())) //ceiling is obstructed in this column
trippedPositions.add(pos);
}
}
}
return trippedPositions;
}
private static void warnInvalidBlocks(Iterable<BlockPos> invalidPositions) {
Botania.proxy.setWispFXDepthTest(false);
for(BlockPos pos_ : invalidPositions) {
Botania.proxy.wispFX(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5, 1F, 0.2F, 0.2F, 0.5F, 0F, 8);
}
Botania.proxy.setWispFXDepthTest(true);
}
@Override
protected void registerGoals() {
goalSelector.addGoal(0, new SwimGoal(this));
@@ -552,7 +582,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
//don't break blacklisted blocks
if(BLACKLIST.contains(block)) continue;
//don't break the floor
if(y == source.getY() - 1) continue;
if(y < source.getY()) continue;
//don't break blocks in pylon columns
if(Math.abs(source.getX() - x) == 4 && Math.abs(source.getZ() - z) == 4) continue;
@@ -812,12 +842,11 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
private void teleportRandomly() {
//choose a location to teleport to
double oldX = posX, oldY = posY, oldZ = posZ;
double newX, newY, newZ;
double newX, newY = source.getY(), newZ;
int tries = 0;
do {
newX = source.getX() + (rand.nextDouble() - .5) * ARENA_RANGE;
newY = source.getY();
newZ = source.getZ() + (rand.nextDouble() - .5) * ARENA_RANGE;
tries++;
//ensure it's inside the arena ring, and not just its bounding square
@@ -830,6 +859,12 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
newY = source.getY() + 1.6;
newZ = source.getZ() + .5;
}
//for low-floor arenas, ensure landing on the ground
BlockPos tentativeFloorPos = new BlockPos(newX, newY - 1, newZ);
if(world.getBlockState(tentativeFloorPos).getCollisionShape(world, tentativeFloorPos).isEmpty()) {
newY--;
}
//teleport there
setPositionAndUpdate(newX, newY, newZ);
@@ -10,7 +10,6 @@
*/
package vazkii.botania.common.item.equipment.armor.manasteel;
import com.google.common.collect.Multimap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.Screen;
@@ -15,6 +15,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags;
@@ -66,23 +67,28 @@ public class ItemMagnetRing extends ItemBauble {
}
@Override
public void onWornTick(ItemStack stack, LivingEntity player) {
public void onWornTick(ItemStack stack, LivingEntity living) {
super.onWornTick(stack, living);
if(living.isSpectator())
return;
int cooldown = getCooldown(stack);
if(SubTileSolegnolia.hasSolegnoliaAround(player)) {
if(SubTileSolegnolia.hasSolegnoliaAround(living)) {
if(cooldown < 0)
setCooldown(stack, 2);
return;
}
if(cooldown <= 0) {
if(player.isSneaking() == ConfigHandler.COMMON.invertMagnetRing.get()) {
double x = player.posX;
double y = player.posY + 0.75;
double z = player.posZ;
if(living.isSneaking() == ConfigHandler.COMMON.invertMagnetRing.get()) {
double x = living.posX;
double y = living.posY + 0.75;
double z = living.posZ;
int range = ((ItemMagnetRing) stack.getItem()).range;
List<ItemEntity> items = player.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
List<ItemEntity> items = living.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
int pulled = 0;
for(ItemEntity item : items)
if(((ItemMagnetRing) stack.getItem()).canPullItem(item)) {
@@ -90,8 +96,8 @@ public class ItemMagnetRing extends ItemBauble {
break;
MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F);
if(player.world.isRemote) {
boolean red = player.world.rand.nextBoolean();
if(living.world.isRemote) {
boolean red = living.world.rand.nextBoolean();
Botania.proxy.sparkleFX(item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3);
}
pulled++;
@@ -101,7 +107,7 @@ public class ItemMagnetRing extends ItemBauble {
}
private boolean canPullItem(ItemEntity item) {
if(!item.isAlive() || item.pickupDelay >= 40 || SubTileSolegnolia.hasSolegnoliaAround(item))
if(!item.isAlive() || item.pickupDelay >= 40 || SubTileSolegnolia.hasSolegnoliaAround(item) || item.getPersistentData().getBoolean("PreventRemoteMovement"))
return false;
ItemStack stack = item.getItem();