mirror of
https://github.com/chylex/Hardcore-Ender-Expansion.git
synced 2025-04-10 20:15:42 +02:00
Work on addressing bugs and concerns reported by FindBugs
This commit is contained in:
parent
7c3c221e55
commit
34839620d0
src/main/java/chylex/hee
entity/item
game
render/model
system
@ -104,7 +104,7 @@ public class EntityItemInstabilityOrb extends EntityItem{
|
||||
item = new WeightedItem(is.getItem(),is.getItemDamage(),1);
|
||||
}
|
||||
|
||||
int meta = RandUtil.anyOf(rand,item.getDamageValues());
|
||||
int meta = RandUtil.anyOf(rand,item.getDamageValues(),0);
|
||||
if (meta == 32767)meta = 0;
|
||||
|
||||
EntityItem entityitem = new EntityItem(worldObj,posX,posY,posZ,new ItemStack(item.getItem(),1,meta));
|
||||
|
@ -3,7 +3,11 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.minecraft.client.AnvilConverterException;
|
||||
@ -20,7 +24,6 @@ import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import chylex.hee.gui.GuiModTransition;
|
||||
import chylex.hee.system.abstractions.Pos;
|
||||
import chylex.hee.system.logging.Log;
|
||||
@ -66,7 +69,7 @@ public final class ModTransition{
|
||||
return !new File(root,"hee2").isDirectory() && new File(root,"DIM1").isDirectory(); // DIM1 should always be there, but convert vanilla worlds too
|
||||
}
|
||||
|
||||
public static void doConvertWorld(File root) throws IOException{
|
||||
public static void doConvertWorld(File root) throws IOException{ // TODO re-test player data
|
||||
Pos worldSpawnPoint = new Pos(0,255,0);
|
||||
|
||||
File levelDat = new File(root,"level.dat");
|
||||
@ -82,10 +85,15 @@ public final class ModTransition{
|
||||
FileUtils.deleteDirectory(new File(root,"DIM1"));
|
||||
FileUtils.deleteDirectory(new File(root,"hee"));
|
||||
|
||||
for(File file:new File(root,"playerdata").listFiles((file, name) -> FilenameUtils.getExtension(name).equals("dat"))){
|
||||
try(FileInputStream fileStreamIn = new FileInputStream(file)){
|
||||
NBTTagCompound nbt = CompressedStreamTools.readCompressed(fileStreamIn);
|
||||
convertPlayerTag(nbt,worldSpawnPoint);
|
||||
try(DirectoryStream<Path> stream = Files.newDirectoryStream(new File(root,"playerdata").toPath(),"*.dat")){
|
||||
for(Iterator<Path> iter = stream.iterator(); iter.hasNext();){
|
||||
File file = iter.next().toFile();
|
||||
NBTTagCompound nbt;
|
||||
|
||||
try(FileInputStream fileStreamIn = new FileInputStream(file)){
|
||||
nbt = CompressedStreamTools.readCompressed(fileStreamIn);
|
||||
convertPlayerTag(nbt,worldSpawnPoint);
|
||||
}
|
||||
|
||||
try(FileOutputStream fileStreamOut = new FileOutputStream(file)){
|
||||
CompressedStreamTools.writeCompressed(nbt,fileStreamOut);
|
||||
@ -101,7 +109,6 @@ public final class ModTransition{
|
||||
dataTag.setTag("Player",playerNBT);
|
||||
}
|
||||
|
||||
|
||||
try(FileOutputStream fileStreamOut = new FileOutputStream(levelDat)){
|
||||
CompressedStreamTools.writeCompressed(levelDatNBT,fileStreamOut);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class LoreFile extends PlayerFile{
|
||||
|
||||
if (read.length < category.getTextCount()){
|
||||
int[] unread = IntStream.range(0,category.getTextCount()).filter(ind -> !ArrayUtils.contains(read,(byte)ind)).toArray();
|
||||
int selected = RandUtil.anyOf(rand,unread);
|
||||
int selected = RandUtil.anyOf(rand,unread,0); // never returns default
|
||||
|
||||
readTexts.put(category,ArrayUtils.add(read,(byte)selected));
|
||||
setModified();
|
||||
|
@ -30,14 +30,14 @@ public class ModelEnderEye extends ModelBase{
|
||||
rightArm.setRotationPoint(0F,0F,0F);
|
||||
rightArm.setTextureSize(128,64);
|
||||
rightArm.mirror = true;
|
||||
setRotation(rightArm,MathUtil.PI*0.5F,0F,0F);
|
||||
setRotation(rightArm,MathUtil.HALF_PI,0F,0F);
|
||||
|
||||
leftArm = new ModelRenderer(this,116,0);
|
||||
leftArm.addBox(9F,-27F,-3F,3,30,3);
|
||||
leftArm.setRotationPoint(0F,0F,0F);
|
||||
leftArm.setTextureSize(128,64);
|
||||
leftArm.mirror = true;
|
||||
setRotation(leftArm,MathUtil.PI*0.5F,0F,0F);
|
||||
setRotation(leftArm,MathUtil.HALF_PI,0F,0F);
|
||||
leftArm.mirror = false;
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ public class ModelEnderEye extends ModelBase{
|
||||
EntityMiniBossEnderEye eye = (EntityMiniBossEnderEye)entity;
|
||||
byte anim = eye.getAttackAnimationTime();
|
||||
if (anim == 0 && animationAngle > 0F)animationAngle = Math.max(0F,animationAngle-0.10472F);
|
||||
else if (anim > 0)animationAngle = Math.min(MathUtil.PI*0.5F,animationAngle+0.071399F);
|
||||
else if (anim > 0)animationAngle = Math.min(MathUtil.HALF_PI,animationAngle+0.071399F);
|
||||
|
||||
if (eye.isAsleep())wakeupAngle = Math.min(-pitchRad+1.570796F,wakeupAngle+0.098175F);
|
||||
else if (wakeupAngle != 0F)wakeupAngle = Math.max(0F,wakeupAngle-0.098175F);
|
||||
|
@ -56,8 +56,7 @@ public final class EntityAttributes{
|
||||
|
||||
public AttributeModifierBuilder setValue(Operation operation, double value){
|
||||
this.operation = operation;
|
||||
this.value = value;
|
||||
if (this.operation == Operation.MULTIPLY)value -= 1D;
|
||||
this.value = operation == Operation.MULTIPLY ? value-1D : value;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.system.util;
|
||||
|
||||
public final class MathUtil{
|
||||
public static final float PI = (float)Math.PI;
|
||||
public static final float HALF_PI = (float)Math.PI*0.5F;
|
||||
|
||||
private static final float F_D2R = 0.01745329251994327F;
|
||||
private static final float F_R2D = 57.2957795130823208F;
|
||||
|
@ -10,12 +10,12 @@ public final class RandUtil{
|
||||
return array.length == 0 ? null : array[rand.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static int anyOf(Random rand, int[] array){
|
||||
return array.length == 0 ? null : array[rand.nextInt(array.length)];
|
||||
public static int anyOf(Random rand, int[] array, int defaultValue){
|
||||
return array.length == 0 ? defaultValue : array[rand.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static short anyOf(Random rand, short[] array){
|
||||
return array.length == 0 ? null : array[rand.nextInt(array.length)];
|
||||
public static short anyOf(Random rand, short[] array, int defaultValue){
|
||||
return array.length == 0 ? (short)defaultValue : array[rand.nextInt(array.length)];
|
||||
}
|
||||
|
||||
private RandUtil(){}
|
||||
|
Loading…
Reference in New Issue
Block a user