Merge changes correctly and fix most warnings

This commit is contained in:
Runemoro 2018-01-17 01:12:22 -05:00
parent 3968d9f527
commit efd787ef46
24 changed files with 34 additions and 55 deletions

View file

@ -16,7 +16,6 @@ import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import org.dimdev.dimdoors.DimDoors;
import org.lwjgl.Sys;
import java.util.*;
import java.util.Map.Entry;

View file

@ -71,7 +71,7 @@ public class DimDoors {
}
public static void sendMessage(Entity entity, String text) {
if(true) {
if (/* TODO: config option && */ entity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) entity;
player.sendStatusMessage(new TextComponentString(text), true);
} else

View file

@ -83,7 +83,6 @@ public class RenderMonolith extends RenderLiving<EntityMonolith> {
try {
float interpolatedYaw = interpolateRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par9);
float interpolatedYawHead = interpolateRotation(par1EntityLivingBase.prevRotationYawHead, par1EntityLivingBase.rotationYawHead, par9);
float rotation;
float pitch = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9;
renderLivingAt(par1EntityLivingBase, x, y, z);
@ -99,7 +98,6 @@ public class RenderMonolith extends RenderLiving<EntityMonolith> {
GlStateManager.rotate(par1EntityLivingBase.pitchLevel, 1.0F, 0.0F, 0.0F);
GlStateManager.translate(0.0F, 24.0F * f6 - 0.0078125F, 0.0F);
renderModel(par1EntityLivingBase, 0, 0, rotation, interpolatedYaw, pitch, f6);
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);

View file

@ -31,6 +31,7 @@ public final class EventHandler {
EntityPlayerMP player = (EntityPlayerMP) entity;
World world = entity.world;
int dim = world.provider.getDimension();
//noinspection StatementWithEmptyBody
if (!world.isRemote
&& !player.isDead
&& ModDimensions.isDimDoorsPocketDimension(world)

View file

@ -1,8 +1,6 @@
package org.dimdev.dimdoors.shared.blocks;
import org.dimdev.dimdoors.shared.VirtualLocation;
import org.dimdev.dimdoors.shared.rifts.TileEntityRift;
import org.dimdev.ddutils.Location;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;

View file

@ -73,21 +73,21 @@ public class CommandPocket extends CommandBase {
EntityPlayerMP player = getCommandSenderAsPlayer(sender);
// Make sure the player is in a pocket world
if (!ModDimensions.isDimDoorsPocketDimension(player.world)) {
DimDoors.chat(player, "You must be in a pocket dimension to use this command!");
DimDoors.sendMessage(player, "You must be in a pocket dimension to use this command!");
return;
}
// Check if the schematic exists
if (!SchematicHandler.INSTANCE.getTemplateGroups().contains(group)) {
DimDoors.chat(player, "Group " + group + " not found");
DimDoors.sendMessage(player, "Group " + group + " not found");
return;
} else if (!SchematicHandler.INSTANCE.getTemplateNames(group).contains(name)) {
DimDoors.chat(player, "Schematic " + name + " not found in group " + group);
DimDoors.sendMessage(player, "Schematic " + name + " not found in group " + group);
return;
}
// Generate the schematic
DimDoors.chat(player, "Generating schematic " + name);
DimDoors.sendMessage(player, "Generating schematic " + name);
PocketTemplate template = SchematicHandler.INSTANCE.getTemplate(group, name);
Pocket pocket = PocketGenerator.generatePocketFromTemplate(WorldUtils.getDim(player.world), template, null);
if (setup) pocket.setup();

View file

@ -138,7 +138,7 @@ public class EntityMonolith extends EntityFlying implements IMob {
// Also, since it's a large open area with many Monoliths, some
// of the sounds that would usually play for a moment would
// keep playing constantly and would get very annoying.
playSounds(player);
playSounds(player.getPosition());
}
if (visibility) {
@ -206,20 +206,20 @@ public class EntityMonolith extends EntityFlying implements IMob {
/**
* Plays sounds at different levels of aggro, using soundTime to prevent too many sounds at once.
*
* @param player
* @param pos The position to play the sounds at
*/
private void playSounds(EntityPlayer player) {
private void playSounds(BlockPos pos) {
float aggroPercent = getAggroProgress();
if (soundTime <= 0) {
playSound(ModSounds.MONK, 1F, 1F);
soundTime = 100;
}
if (aggroPercent > 0.70 && soundTime < 100) { // TODO: null rather than player?
world.playSound(null, player.getPosition(), ModSounds.TEARING, SoundCategory.HOSTILE, 1F, (float) (1 + rand.nextGaussian()));
world.playSound(null, pos, ModSounds.TEARING, SoundCategory.HOSTILE, 1F, (float) (1 + rand.nextGaussian()));
soundTime = 100 + rand.nextInt(75);
}
if (aggroPercent > 0.80 && soundTime < MAX_SOUND_COOLDOWN) {
world.playSound(null, player.getPosition(), ModSounds.TEARING, SoundCategory.HOSTILE, 7, 1F);
world.playSound(null, pos, ModSounds.TEARING, SoundCategory.HOSTILE, 7, 1F);
soundTime = 250;
}
soundTime--;

View file

@ -6,7 +6,6 @@ import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.ddutils.I18nUtils;

View file

@ -1,5 +1,6 @@
package org.dimdev.dimdoors.shared.items;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@ -8,7 +9,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -116,7 +116,7 @@ public class ItemStabilizedRiftSignature extends Item { // TODO: common supercla
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) {
RotatedLocation transform = getTarget(stack);
if (transform != null) {
tooltip.add(I18n.translateToLocalFormatted("info.stabilized_rift_signature.bound", transform.getLocation().getX(), transform.getLocation().getY(), transform.getLocation().getZ(), transform.getLocation().getDim()));
tooltip.add(I18n.format("info.stabilized_rift_signature.bound", transform.getLocation().getX(), transform.getLocation().getY(), transform.getLocation().getZ(), transform.getLocation().getDim()));
} else {
tooltip.addAll(I18nUtils.translateMultiline("info.stabilized_rift_signature.unbound"));
}

View file

@ -26,7 +26,6 @@ import org.dimdev.dimdoors.shared.tools.SchematicConverter;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompressedStreamTools;
import org.apache.commons.io.IOUtils;
import org.dimdev.dimdoors.shared.pockets.PocketRegistry;
import org.dimdev.dimdoors.shared.world.ModDimensions;
/**
@ -262,10 +261,6 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
/**
* Gets a random template matching certain criteria.
*
* @param groupWeights
* @param depth
* @param maxSize
* @param getLargest
* @return A random template matching those criteria, or null if none were found
*/
public PocketTemplate getRandomTemplate(Map<String, Float> groupWeights, int depth, int maxSize, boolean getLargest) { // TODO: useful?
@ -276,8 +271,6 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
/**
* Gets a random template matching certain criteria.
*
* @param group
* @param depth
* @param maxSize Maximum size the template can be.
* @param getLargest Setting this to true will always get the largest template size in that group,
* but still randomly out of the templates with that size (ex. for private and public pockets)
@ -307,11 +300,11 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
}
public PocketTemplate getPersonalPocketTemplate() {
return getRandomTemplate("private", -1, Math.min(Config.getPrivatePocketSize(), PocketRegistry.getForDim(ModDimensions.getPrivateDim()).getPrivatePocketSize()), true);
return getRandomTemplate("private", -1, Math.min(Config.getPrivatePocketSize(), PocketRegistry.instance(ModDimensions.getPrivateDim()).getPrivatePocketSize()), true);
}
public PocketTemplate getPublicPocketTemplate() {
return getRandomTemplate("public", -1, Math.min(Config.getPublicPocketSize(), PocketRegistry.getForDim(ModDimensions.getPublicDim()).getPublicPocketSize()), true);
return getRandomTemplate("public", -1, Math.min(Config.getPublicPocketSize(), PocketRegistry.instance(ModDimensions.getPublicDim()).getPublicPocketSize()), true);
}
public void saveSchematic(Schematic schematic, String name) {

View file

@ -61,8 +61,8 @@ public abstract class RiftDestination implements INBTStorable {
RiftRegistry.instance().removeLink(location, getFixedTarget(location));
}
public boolean keepAfterTargetGone(Location location) {
return true;
public boolean keepAfterTargetGone(Location location, Location target) {
return !target.equals(getFixedTarget(location));
}
public RGBA getColor(Location location) {

View file

@ -167,7 +167,7 @@ import javax.annotation.Nonnull;
}
public void targetGone(Location loc) {
if (!destination.keepAfterTargetGone(loc)) setDestination(null);
if (!destination.keepAfterTargetGone(new Location(world, pos), loc)) setDestination(null);
updateColor();
}
@ -181,7 +181,7 @@ import javax.annotation.Nonnull;
// Check that the rift has as destination
if (destination == null) {
DimDoors.chat(entity, "This rift has no destination!");
DimDoors.sendMessage(entity, "This rift has no destination!");
return false;
}
@ -196,7 +196,7 @@ import javax.annotation.Nonnull;
return true;
}
} catch (Exception e) {
DimDoors.chat(entity, "There was an exception while teleporting!");
DimDoors.sendMessage(entity, "There was an exception while teleporting!");
DimDoors.log.error("Teleporting failed with the following exception: ", e);
}
return false;

View file

@ -36,7 +36,7 @@ public class EscapeDestination extends RiftDestination {
@Override
public boolean teleport(RotatedLocation loc, Entity entity) {
if (!ModDimensions.isDimDoorsPocketDimension(entity.world)) {
DimDoors.chat(entity, "Can't escape from a non-pocket dimension!");
DimDoors.sendMessage(entity, "Can't escape from a non-pocket dimension!");
return false;
}
UUID uuid = entity.getUniqueID();
@ -48,9 +48,9 @@ public class EscapeDestination extends RiftDestination {
return true;
} else {
if (destLoc == null) {
DimDoors.chat(entity, "You didn't use a rift to enter so you ended up in Limbo!"); // TODO: better messages, localization
DimDoors.sendMessage(entity, "You didn't use a rift to enter so you ended up in Limbo!"); // TODO: better messages, localization
} else {
DimDoors.chat(entity, "The rift you used to enter has closed so you ended up in Limbo!");
DimDoors.sendMessage(entity, "The rift you used to enter has closed so you ended up in Limbo!");
}
TeleportUtils.teleport(entity, WorldProviderLimbo.getLimboSkySpawn(entity)); // TODO: do we really want to spam limbo with items?
return true;

View file

@ -31,8 +31,8 @@ public abstract class LinkingDestination extends RiftDestination {
}
@Override
public boolean keepAfterTargetGone(Location location) {
if (!wrappedDestination.keepAfterTargetGone(location)) {
public boolean keepAfterTargetGone(Location location, Location target) {
if (!wrappedDestination.keepAfterTargetGone(location, target)) {
wrappedDestination.unregister(location);
}
return true;

View file

@ -28,7 +28,7 @@ import org.dimdev.dimdoors.shared.rifts.RiftDestination;
@Override
public boolean teleport(RotatedLocation loc, Entity entity) {
if (entity instanceof EntityPlayer) DimDoors.chat(entity, "The entrances of this dungeon has not been linked. Either this is a bug or you are in dungeon-building mode.");
if (entity instanceof EntityPlayer) DimDoors.sendMessage(entity, "The entrances of this dungeon has not been linked. Either this is a bug or you are in dungeon-building mode.");
return false;
}
}

View file

@ -28,7 +28,7 @@ public class PocketExitDestination extends RiftDestination { // TODO: not exactl
@Override
public boolean teleport(RotatedLocation loc, Entity entity) {
if (entity instanceof EntityPlayer) DimDoors.chat(entity, "The exit of this dungeon has not been linked. Either this is a bug or you are in dungeon-building mode.");
if (entity instanceof EntityPlayer) DimDoors.sendMessage(entity, "The exit of this dungeon has not been linked. Either this is a bug or you are in dungeon-building mode.");
return false;
}
}

View file

@ -46,9 +46,9 @@ public class PrivatePocketExitDestination extends RiftDestination {
}
if (destLoc == null || !(destLoc.getTileEntity() instanceof TileEntityRift)) {
if (destLoc == null) {
DimDoors.chat(entity, "You did not use a rift to enter this pocket so you ended up in limbo!");
DimDoors.sendMessage(entity, "You did not use a rift to enter this pocket so you ended up in limbo!");
} else {
DimDoors.chat(entity, "The rift you entered through no longer exists so you ended up in limbo!");
DimDoors.sendMessage(entity, "The rift you entered through no longer exists so you ended up in limbo!");
}
TeleportUtils.teleport(entity, WorldProviderLimbo.getLimboSkySpawn(entity));
return false;

View file

@ -14,7 +14,7 @@ public abstract class BaseGateway {
* @param y - the y-coordinate of the block on which the gateway may be built
* @param z - the z-coordinate at which to center the gateway; usually where the door is placed
*/
public abstract boolean generate(World world, int x, int y, int z);
public abstract void generate(World world, int x, int y, int z);
/**
* Determines whether the specified biome is a valid biome in which to generate this gateway

View file

@ -50,12 +50,9 @@ public abstract class BaseSchematicGateway extends BaseGateway {
}
@Override
public boolean generate(World world, int x, int y, int z) {
public void generate(World world, int x, int y, int z) {
Schematic.place(schematic, world, x, y, z);
generateRandomBits(world, x, y, z);
return true;
}
/**

View file

@ -26,7 +26,6 @@ public class DimensionFilter {
int end;
String startPart;
String endPart;
String[] intervals;
RangeSet<Integer> ranges = TreeRangeSet.create();
// Iterate over all the interval strings

View file

@ -23,9 +23,8 @@ public class GatewayGenerator implements IWorldGenerator
private static final int MIN_RIFT_Y = 4;
private static final int MAX_RIFT_Y = 240;
private static final int CHUNK_LENGTH = 16;
private static final int GATEWAY_RADIUS = 4;
// private static final int GATEWAY_RADIUS = 4; // TODO: what did this do in the old mod?
private static final int MAX_GATEWAY_GENERATION_ATTEMPTS = 10;
private static final int OVERWORLD_DIMENSION_ID = 0;
private static final int NETHER_DIMENSION_ID = -1;
private static final int END_DIMENSION_ID = 1;

View file

@ -11,7 +11,7 @@ import net.minecraft.world.World;
public class GatewayLimbo extends BaseGateway {
@Override
public boolean generate(World world, int x, int y, int z)
public void generate(World world, int x, int y, int z)
{
IBlockState limbo = ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.UNRAVELED);
// Build the gateway out of Unraveled Fabric. Since nearly all the blocks in Limbo are of
@ -26,7 +26,6 @@ public class GatewayLimbo extends BaseGateway {
world.setBlockState(new BlockPos(x, y + 1, z + 1), limbo);
ItemDoor.placeDoor(world, new BlockPos(x, y + 1, z), EnumFacing.getHorizontal(0), ModBlocks.TRANSIENT_DIMENSIONAL_DOOR, false);
return true;
}
@Override

View file

@ -89,13 +89,11 @@ public final class LimboDecay {
* This decay method is designed to stop players from avoiding Limbo decay by building floating structures.
*/
public static void applyRandomFastDecay() {
int x, y, z;
int sectionY;
int limboHeight;
int[] limbo = DimensionManager.getDimensions(ModDimensions.LIMBO);
for (Integer i : limbo) {
for (int i : limbo) {
World world = DimensionManager.getWorld(i);
limboHeight = world.getHeight();

View file

@ -16,7 +16,6 @@ import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.NoiseGeneratorOctaves;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;