fix display in nether and claim saving
This commit is contained in:
parent
9a45382c6e
commit
835aa5ba21
@ -72,7 +72,7 @@ public class ClaimStorage {
|
|||||||
}
|
}
|
||||||
claim.setClaimID(this.generateUUID());
|
claim.setClaimID(this.generateUUID());
|
||||||
this.addClaim(claim);
|
this.addClaim(claim);
|
||||||
data.addDisplayClaim(claim, EnumDisplayType.MAIN);
|
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimCreateSuccess, Formatting.GOLD), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimCreateSuccess, Formatting.GOLD), false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ public class ClaimStorage {
|
|||||||
Claim newClaim = new Claim(opposite, to, player.getUuid(), player.getServerWorld());
|
Claim newClaim = new Claim(opposite, to, player.getUuid(), player.getServerWorld());
|
||||||
Set<Claim> conflicts = conflicts(newClaim, claim);
|
Set<Claim> conflicts = conflicts(newClaim, claim);
|
||||||
if(!conflicts.isEmpty()) {
|
if(!conflicts.isEmpty()) {
|
||||||
conflicts.forEach(conf->PlayerClaimData.get(player).addDisplayClaim(conf, EnumDisplayType.CONFLICT));
|
conflicts.forEach(conf->PlayerClaimData.get(player).addDisplayClaim(conf, EnumDisplayType.CONFLICT, player.getBlockPos().getY()));
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ public class ClaimStorage {
|
|||||||
this.deleteClaim(claim, false, EnumEditMode.DEFAULT, player.getServerWorld());
|
this.deleteClaim(claim, false, EnumEditMode.DEFAULT, player.getServerWorld());
|
||||||
claim.copySizes(newClaim);
|
claim.copySizes(newClaim);
|
||||||
this.addClaim(claim);
|
this.addClaim(claim);
|
||||||
data.addDisplayClaim(claim, EnumDisplayType.MAIN);
|
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeSuccess, Formatting.GOLD), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeSuccess, Formatting.GOLD), false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -231,12 +231,13 @@ public class ClaimStorage {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FileWriter writer = new FileWriter(file);
|
if(dirty){
|
||||||
JsonArray arr = new JsonArray();
|
FileWriter writer = new FileWriter(file);
|
||||||
if(dirty)
|
JsonArray arr = new JsonArray();
|
||||||
e.getValue().forEach(claim -> arr.add(claim.toJson(new JsonObject())));
|
e.getValue().forEach(claim -> arr.add(claim.toJson(new JsonObject())));
|
||||||
ConfigHandler.GSON.toJson(arr, writer);
|
ConfigHandler.GSON.toJson(arr, writer);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public class CommandClaim {
|
|||||||
if (claim == null)
|
if (claim == null)
|
||||||
return 0;
|
return 0;
|
||||||
ClaimMenuScreenHandler.openClaimMenu(player, claim);
|
ClaimMenuScreenHandler.openClaimMenu(player, claim);
|
||||||
data.addDisplayClaim(claim, EnumDisplayType.MAIN);
|
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(player.getBlockPos());
|
Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(player.getBlockPos());
|
||||||
|
@ -88,12 +88,12 @@ public class ItemInteractEvents {
|
|||||||
Claim subClaim = claim.getSubClaim(target);
|
Claim subClaim = claim.getSubClaim(target);
|
||||||
if (subClaim != null && data.currentEdit()==null) {
|
if (subClaim != null && data.currentEdit()==null) {
|
||||||
if (subClaim.isCorner(target)) {
|
if (subClaim.isCorner(target)) {
|
||||||
data.setEditClaim(subClaim);
|
data.setEditClaim(subClaim, player.getBlockPos().getY());
|
||||||
data.setEditingCorner(target);
|
data.setEditingCorner(target);
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeClaim, Formatting.GOLD), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeClaim, Formatting.GOLD), false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data.addDisplayClaim(claim, EnumDisplayType.MAIN);
|
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -101,7 +101,7 @@ public class ItemInteractEvents {
|
|||||||
boolean fl = claim.resizeSubclaim(data.currentEdit(), data.editingCorner(), target);
|
boolean fl = claim.resizeSubclaim(data.currentEdit(), data.editingCorner(), target);
|
||||||
if(!fl)
|
if(!fl)
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false);
|
||||||
data.setEditClaim(null);
|
data.setEditClaim(null, 0);
|
||||||
data.setEditingCorner(null);
|
data.setEditingCorner(null);
|
||||||
}
|
}
|
||||||
else if (data.editingCorner() != null) {
|
else if (data.editingCorner() != null) {
|
||||||
@ -109,7 +109,7 @@ public class ItemInteractEvents {
|
|||||||
if(!fl)
|
if(!fl)
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false);
|
||||||
else{
|
else{
|
||||||
data.addDisplayClaim(claim, EnumDisplayType.MAIN);
|
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.subClaimCreateSuccess, Formatting.GOLD), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.subClaimCreateSuccess, Formatting.GOLD), false);
|
||||||
}
|
}
|
||||||
data.setEditingCorner(null);
|
data.setEditingCorner(null);
|
||||||
@ -118,22 +118,22 @@ public class ItemInteractEvents {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (claim.isCorner(target)) {
|
if (claim.isCorner(target)) {
|
||||||
data.setEditClaim(claim);
|
data.setEditClaim(claim, player.getBlockPos().getY());
|
||||||
data.setEditingCorner(target);
|
data.setEditingCorner(target);
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeClaim, Formatting.GOLD), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeClaim, Formatting.GOLD), false);
|
||||||
}
|
}
|
||||||
else if(data.currentEdit()!=null){
|
else if(data.currentEdit()!=null){
|
||||||
storage.resizeClaim(data.currentEdit(), data.editingCorner(), target, player);
|
storage.resizeClaim(data.currentEdit(), data.editingCorner(), target, player);
|
||||||
data.setEditClaim(null);
|
data.setEditClaim(null, 0);
|
||||||
data.setEditingCorner(null);
|
data.setEditingCorner(null);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data.addDisplayClaim(claim, EnumDisplayType.MAIN);
|
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data.addDisplayClaim(claim, EnumDisplayType.MAIN);
|
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ public class ItemInteractEvents {
|
|||||||
else {
|
else {
|
||||||
if(data.currentEdit()!=null){
|
if(data.currentEdit()!=null){
|
||||||
storage.resizeClaim(data.currentEdit(), data.editingCorner(), target, player);
|
storage.resizeClaim(data.currentEdit(), data.editingCorner(), target, player);
|
||||||
data.setEditClaim(null);
|
data.setEditClaim(null, 0);
|
||||||
data.setEditingCorner(null);
|
data.setEditingCorner(null);
|
||||||
}
|
}
|
||||||
else if (data.editingCorner() != null) {
|
else if (data.editingCorner() != null) {
|
||||||
@ -168,7 +168,7 @@ public class ItemInteractEvents {
|
|||||||
owner,
|
owner,
|
||||||
target.getX(), target.getY(), target.getZ()), Formatting.GREEN);
|
target.getX(), target.getY(), target.getZ()), Formatting.GREEN);
|
||||||
player.sendMessage(text, false);
|
player.sendMessage(text, false);
|
||||||
PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN);
|
PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
} else
|
} else
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.inspectNoClaim, Formatting.RED), false);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.inspectNoClaim, Formatting.RED), false);
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,20 @@ import com.flemmli97.flan.claim.ParticleIndicators;
|
|||||||
import com.flemmli97.flan.config.ConfigHandler;
|
import com.flemmli97.flan.config.ConfigHandler;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
|
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
|
||||||
import net.minecraft.particle.DustParticleEffect;
|
import net.minecraft.particle.DustParticleEffect;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.Heightmap;
|
import net.minecraft.world.Heightmap;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ClaimDisplay {
|
public class ClaimDisplay {
|
||||||
|
|
||||||
private int displayTime;
|
private int displayTime, height;
|
||||||
private final Claim toDisplay;
|
private final Claim toDisplay;
|
||||||
public final EnumDisplayType type;
|
public final EnumDisplayType type;
|
||||||
private int[][] poss;
|
private int[][] poss;
|
||||||
@ -26,11 +28,12 @@ public class ClaimDisplay {
|
|||||||
private int[] prevDims;
|
private int[] prevDims;
|
||||||
|
|
||||||
private final DustParticleEffect corner, middle;
|
private final DustParticleEffect corner, middle;
|
||||||
public ClaimDisplay(Claim claim, EnumDisplayType type) {
|
public ClaimDisplay(Claim claim, EnumDisplayType type, int y) {
|
||||||
this.toDisplay = claim;
|
this.toDisplay = claim;
|
||||||
this.displayTime = ConfigHandler.config.claimDisplayTime;
|
this.displayTime = ConfigHandler.config.claimDisplayTime;
|
||||||
this.prevDims = claim.getDimensions();
|
this.prevDims = claim.getDimensions();
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.height = y;
|
||||||
switch (type){
|
switch (type){
|
||||||
case SUB:
|
case SUB:
|
||||||
this.corner = ParticleIndicators.SUBCLAIMCORNER;
|
this.corner = ParticleIndicators.SUBCLAIMCORNER;
|
||||||
@ -55,12 +58,12 @@ public class ClaimDisplay {
|
|||||||
this.displayTime--;
|
this.displayTime--;
|
||||||
int[] dims = this.toDisplay.getDimensions();
|
int[] dims = this.toDisplay.getDimensions();
|
||||||
if (this.poss == null || this.changed(dims)) {
|
if (this.poss == null || this.changed(dims)) {
|
||||||
this.middlePoss = calculateDisplayPos(player.world, dims);
|
this.middlePoss = calculateDisplayPos(player.getServerWorld(), dims, this.height);
|
||||||
this.poss = new int[][]{
|
this.poss = new int[][]{
|
||||||
this.getPosFrom(player.world, dims[0], dims[2], dims[4]),
|
this.getPosFrom(player.getServerWorld(), dims[0], dims[2], this.height),
|
||||||
this.getPosFrom(player.world, dims[1], dims[2], dims[4]),
|
this.getPosFrom(player.getServerWorld(), dims[1], dims[2], this.height),
|
||||||
this.getPosFrom(player.world, dims[0], dims[3], dims[4]),
|
this.getPosFrom(player.getServerWorld(), dims[0], dims[3], this.height),
|
||||||
this.getPosFrom(player.world, dims[1], dims[3], dims[4]),
|
this.getPosFrom(player.getServerWorld(), dims[1], dims[3], this.height),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
for (int[] pos : this.poss) {
|
for (int[] pos : this.poss) {
|
||||||
@ -81,7 +84,7 @@ public class ClaimDisplay {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[][] calculateDisplayPos(World world, int[] from) {
|
public static int[][] calculateDisplayPos(ServerWorld world, int[] from, int height) {
|
||||||
List<int[]> l = Lists.newArrayList();
|
List<int[]> l = Lists.newArrayList();
|
||||||
Set<Integer> xs = Sets.newHashSet();
|
Set<Integer> xs = Sets.newHashSet();
|
||||||
addEvenly(from[0], from[1], 10, xs);
|
addEvenly(from[0], from[1], 10, xs);
|
||||||
@ -92,13 +95,13 @@ public class ClaimDisplay {
|
|||||||
zs.add(from[2]+1);
|
zs.add(from[2]+1);
|
||||||
zs.add(from[3]-1);
|
zs.add(from[3]-1);
|
||||||
for (int x : xs) {
|
for (int x : xs) {
|
||||||
l.add(getPosFrom(world, x, from[2], from[4]));
|
l.add(getPosFrom(world, x, from[2], height));
|
||||||
l.add(getPosFrom(world, x, from[3], from[4]));
|
l.add(getPosFrom(world, x, from[3], height));
|
||||||
|
|
||||||
}
|
}
|
||||||
for (int z : zs) {
|
for (int z : zs) {
|
||||||
l.add(getPosFrom(world, from[0], z, from[4]));
|
l.add(getPosFrom(world, from[0], z, height));
|
||||||
l.add(getPosFrom(world, from[1], z, from[4]));
|
l.add(getPosFrom(world, from[1], z, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
return l.toArray(new int[0][]);
|
return l.toArray(new int[0][]);
|
||||||
@ -117,8 +120,28 @@ public class ClaimDisplay {
|
|||||||
addEvenly(min + step, max - step, step, l);
|
addEvenly(min + step, max - step, step, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] getPosFrom(World world, int x, int z, int maxY) {
|
private static int[] getPosFrom(ServerWorld world, int x, int z, int maxY) {
|
||||||
return new int[]{x, Math.max(maxY, world.getChunk(x >> 4, z >> 4).sampleHeightmap(Heightmap.Type.WORLD_SURFACE, x & 15, z & 15) + 1), z};
|
int y = nextAirBlockFrom(world, x, maxY, z);
|
||||||
|
return new int[]{x, y, z};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int nextAirBlockFrom(ServerWorld world, int x, int y, int z){
|
||||||
|
BlockPos pos = new BlockPos(x,y,z);
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
if(state.getMaterial().isReplaceable()){
|
||||||
|
pos = pos.down();
|
||||||
|
while(world.getBlockState(pos).getMaterial().isReplaceable()){
|
||||||
|
pos = pos.down();
|
||||||
|
}
|
||||||
|
pos = pos.up();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pos = pos.up();
|
||||||
|
while(!world.getBlockState(pos).getMaterial().isReplaceable()){
|
||||||
|
pos = pos.up();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pos.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,19 +96,19 @@ public class PlayerClaimData {
|
|||||||
return this.editingClaim;
|
return this.editingClaim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEditClaim(Claim claim) {
|
public void setEditClaim(Claim claim, int height) {
|
||||||
if(claim!=null)
|
if(claim!=null)
|
||||||
this.displayEditing = new ClaimDisplay(claim, EnumDisplayType.EDIT);
|
this.displayEditing = new ClaimDisplay(claim, EnumDisplayType.EDIT, height);
|
||||||
else
|
else
|
||||||
this.displayEditing = null;
|
this.displayEditing = null;
|
||||||
this.editingClaim = claim;
|
this.editingClaim = claim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDisplayClaim(Claim claim, EnumDisplayType type) {
|
public void addDisplayClaim(Claim claim, EnumDisplayType type, int height) {
|
||||||
this.displayToAdd.add(new ClaimDisplay(claim, type));
|
this.displayToAdd.add(new ClaimDisplay(claim, type, height));
|
||||||
if(type==EnumDisplayType.MAIN)
|
if(type==EnumDisplayType.MAIN)
|
||||||
for(Claim sub : claim.getAllSubclaims())
|
for(Claim sub : claim.getAllSubclaims())
|
||||||
this.displayToAdd.add(new ClaimDisplay(sub, EnumDisplayType.SUB));
|
this.displayToAdd.add(new ClaimDisplay(sub, EnumDisplayType.SUB, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumEditMode getEditMode() {
|
public EnumEditMode getEditMode() {
|
||||||
|
Loading…
Reference in New Issue
Block a user