Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
1.3.1 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyyTV committed Apr 9, 2019
1 parent f41b93b commit d43bc76
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 27 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
org.gradle.jvmargs=-Xmx4G
mc_version=1.11.2
forge_version=1.11.2-13.20.1.2530
mod_version=1.3
mod_version=1.3.1
mappings_version=stable_32
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Mod(modid = DimensionalEdibles.MODID, name = DimensionalEdibles.MODNAME, version = DimensionalEdibles.VERSION, acceptedMinecraftVersions = DimensionalEdibles.MCVERSION, dependencies = DimensionalEdibles.DEPENDS, certificateFingerprint = "@FINGERPRINT@", useMetadata = true)
public class DimensionalEdibles {

public static final String VERSION = "1.3";
public static final String VERSION = "1.3.1";
public static final String MCVERSION = "[1.11,1.12)";
public static final String MODID = "dimensionaledibles";
public static final String MODNAME = "Dimensional Edibles";
Expand Down
29 changes: 27 additions & 2 deletions src/main/java/jackyy/dimensionaledibles/block/BlockCustomCake.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

public class BlockCustomCake extends BlockCakeBase implements ITileEntityProvider {

private int customX = 0;
private int customY = 0;
private int customZ = 0;

public BlockCustomCake() {
super();
setRegistryName(DimensionalEdibles.MODID + ":custom_cake");
Expand Down Expand Up @@ -59,6 +63,22 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
DimensionalEdibles.logger.log(Level.ERROR, s + " is not a valid line input! The dimension ID needs to be a number!");
}
}
for (String s : ModConfig.tweaks.customEdible.customCoords) {
try {
String[] parts = s.split(",");
if (parts.length < 4) {
DimensionalEdibles.logger.log(Level.ERROR, s + " is not a valid input line! Format needs to be: <dimID>, <x>, <y>, <z>");
continue;
}
if (Integer.parseInt(parts[0].trim()) == dimension) {
customX = Integer.parseInt(parts[1].trim());
customY = Integer.parseInt(parts[2].trim());
customZ = Integer.parseInt(parts[3].trim());
}
} catch (NumberFormatException e) {
DimensionalEdibles.logger.log(Level.ERROR, s + " is not a valid line input! The dimension ID needs to be a number!");
}
}
if (!stack.isEmpty() && stack.getItem() == Item.REGISTRY.getObject(new ResourceLocation(fuel))) {
if (meta >= 0) {
world.setBlockState(pos, state.withProperty(BITES, meta), 2);
Expand All @@ -70,7 +90,7 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
} else {
if (world.provider.getDimension() != dimension) {
if (!world.isRemote) {
if (player.capabilities.isCreativeMode) {
if (player.capabilities.isCreativeMode || !ModConfig.tweaks.customEdible.customCake.consumeFuel) {
teleportPlayer(world, player, dimension);
} else {
consumeCake(world, pos, player, dimension);
Expand All @@ -84,7 +104,12 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En

private void teleportPlayer(World world, EntityPlayer player, int dimension) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
BlockPos coords = TeleporterHandler.getDimPos(playerMP, dimension, player.getPosition());
BlockPos coords;
if (customX != 0 && customY != 0 && customZ != 0) {
coords = new BlockPos(customX, customY, customZ);
} else {
coords = TeleporterHandler.getDimPos(playerMP, dimension, player.getPosition());
}
TeleporterHandler.updateDimPos(playerMP, world.provider.getDimension(), player.getPosition());
TeleporterHandler.teleport(playerMP, dimension, coords.getX(), coords.getY(), coords.getZ(), playerMP.mcServer.getPlayerList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
} else {
if (world.provider.getDimension() != 1) {
if (!world.isRemote) {
if (player.capabilities.isCreativeMode) {
if (player.capabilities.isCreativeMode || !ModConfig.tweaks.endCake.consumeFuel) {
teleportPlayer(world, player);
} else {
consumeCake(world, pos, player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
} else {
if (world.provider.getDimension() != -1) {
if (!world.isRemote) {
if (player.capabilities.isCreativeMode) {
if (player.capabilities.isCreativeMode || !ModConfig.tweaks.netherCake.consumeFuel) {
teleportPlayer(world, player);
} else {
consumeCake(world, pos, player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand Down Expand Up @@ -47,7 +48,7 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
} else {
if (world.provider.getDimension() != 0) {
if (!world.isRemote) {
if (player.capabilities.isCreativeMode) {
if (player.capabilities.isCreativeMode || !ModConfig.tweaks.overworldCake.consumeFuel) {
teleportPlayer(world, player);
} else {
consumeCake(world, pos, player);
Expand All @@ -65,7 +66,12 @@ private void teleportPlayer(World world, EntityPlayer player) {
if (ModConfig.tweaks.overworldCake.useCustomCoords) {
coords = new BlockPos(ModConfig.tweaks.overworldCake.customCoords.x, ModConfig.tweaks.overworldCake.customCoords.y, ModConfig.tweaks.overworldCake.customCoords.z);
} else {
coords = TeleporterHandler.getDimPos(playerMP, 0, player.getPosition());
WorldServer overworld = playerMP.mcServer.getPlayerList().getServerInstance().getWorld(0);
if (ModConfig.tweaks.overworldCake.useWorldSpawn) {
coords = overworld.getTopSolidOrLiquidBlock(overworld.getSpawnPoint());
} else {
coords = TeleporterHandler.getDimPos(playerMP, 0, player.getPosition());
}
}
TeleporterHandler.updateDimPos(playerMP, world.provider.getDimension(), player.getPosition());
TeleporterHandler.teleport(playerMP, 0, coords.getX(), coords.getY(), coords.getZ(), playerMP.mcServer.getPlayerList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ public void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
return;
}
dimension = nbt.getInteger("dimID");
int customX = nbt.getInteger("x");
int customY = nbt.getInteger("y");
int customZ = nbt.getInteger("z");
if (world.provider.getDimension() != dimension) {
if (!world.isRemote) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
BlockPos coords = TeleporterHandler.getDimPos(playerMP, dimension, player.getPosition());
BlockPos coords;
if (customX != 0 && customY != 0 && customZ != 0) {
coords = new BlockPos(customX, customY, customZ);
} else {
coords = TeleporterHandler.getDimPos(playerMP, dimension, player.getPosition());
}
TeleporterHandler.updateDimPos(playerMP, world.provider.getDimension(), player.getPosition());
TeleporterHandler.teleport(playerMP, dimension, coords.getX(), coords.getY(), coords.getZ(), playerMP.mcServer.getPlayerList());
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 200, 200, false, false));
Expand Down Expand Up @@ -74,6 +82,25 @@ public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemSt
}
nbt.setInteger("dimID", dimension);
nbt.setString("appleName", parts[1].trim());
nbt.setInteger("x", 0);
nbt.setInteger("y", 0);
nbt.setInteger("z", 0);
for (String c : ModConfig.tweaks.customEdible.customCoords) {
try {
String[] coords = c.split(",");
if (coords.length < 4) {
DimensionalEdibles.logger.log(Level.ERROR, c + " is not a valid input line! Format needs to be: <dimID>, <x>, <y>, <z>");
continue;
}
if (Integer.parseInt(coords[0].trim()) == dimension) {
nbt.setInteger("x", Integer.parseInt(coords[1].trim()));
nbt.setInteger("y", Integer.parseInt(coords[2].trim()));
nbt.setInteger("z", Integer.parseInt(coords[3].trim()));
}
} catch (NumberFormatException e) {
DimensionalEdibles.logger.log(Level.ERROR, c + " is not a valid line input! The dimension ID needs to be a number!");
}
}
list.add(stack);
} else {
DimensionalEdibles.logger.log(Level.ERROR, parts[0] + " is not a valid dimension ID! (Needs to be a number)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand All @@ -39,7 +40,12 @@ public void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
if (ModConfig.tweaks.overworldApple.useCustomCoords) {
coords = new BlockPos(ModConfig.tweaks.overworldApple.customCoords.x, ModConfig.tweaks.overworldApple.customCoords.y, ModConfig.tweaks.overworldApple.customCoords.z);
} else {
coords = TeleporterHandler.getDimPos(playerMP, 0, player.getPosition());
WorldServer overworld = playerMP.mcServer.getPlayerList().getServerInstance().getWorld(0);
if (ModConfig.tweaks.overworldApple.useWorldSpawn) {
coords = overworld.getTopSolidOrLiquidBlock(overworld.getSpawnPoint());
} else {
coords = TeleporterHandler.getDimPos(playerMP, 0, player.getPosition());
}
}
TeleporterHandler.updateDimPos(playerMP, world.provider.getDimension(), player.getPosition());
TeleporterHandler.teleport(playerMP, 0, coords.getX(), coords.getY(), coords.getZ(), playerMP.mcServer.getPlayerList());
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/jackyy/dimensionaledibles/registry/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static class EndCake {
public String fuel = "minecraft:ender_eye";
@Config.Comment("Set to true to make the End Cake pre-fueled upon placed.")
public boolean preFueled = false;
@Config.Comment("Set to true to make the End Cake consume fuel.")
public boolean consumeFuel = true;
@Config.Comment("Set to true to use custom coordinates for the teleportation.")
public boolean useCustomCoords = false;
public CustomCoords customCoords = new CustomCoords();
Expand Down Expand Up @@ -68,6 +70,8 @@ public static class NetherCake {
public String fuel = "minecraft:obsidian";
@Config.Comment("Set to true to make the Nether Cake pre-fueled upon placed.")
public boolean preFueled = false;
@Config.Comment("Set to true to make the Nether Cake consume fuel.")
public boolean consumeFuel = true;
@Config.Comment("Set to true to use custom coordinates for the teleportation.")
public boolean useCustomCoords = false;
public CustomCoords customCoords = new CustomCoords();
Expand Down Expand Up @@ -96,6 +100,13 @@ public static class OverworldCake {
public String fuel = "minecraft:sapling";
@Config.Comment("Set to true to make the Overworld Cake pre-fueled upon placed.")
public boolean preFueled = false;
@Config.Comment("Set to true to make the Overworld Cake consume fuel.")
public boolean consumeFuel = true;
@Config.Comment({
"Set to true to make the Overworld Apple teleport players to world spawn.",
"Otherwise, it will use the cached position."
})
public boolean useWorldSpawn = true;
@Config.Comment("Set to true to use custom coordinates for the teleportation.")
public boolean useCustomCoords = false;
public CustomCoords customCoords = new CustomCoords();
Expand All @@ -108,6 +119,11 @@ public static class CustomCoords {

public OverworldApple overworldApple = new OverworldApple();
public static class OverworldApple {
@Config.Comment({
"Set to true to make the Overworld Apple teleport players to world spawn.",
"Otherwise, it will use the cached position)."
})
public boolean useWorldSpawn = true;
@Config.Comment("Set to true to use custom coordinates for the teleportation.")
public boolean useCustomCoords = false;
public CustomCoords customCoords = new CustomCoords();
Expand All @@ -127,10 +143,18 @@ public static class CustomEdible {
"Note: \"Cake\" is automatically appended onto the end of the name for cakes."
})
public String[] dimensions = new String[0];
@Config.Comment({
"Set a list of custom coordinates used by Custom Cakes / Apples, this is optional.",
"Format: <Dimension ID>, <X>, <Y>, <Z>",
"Example: 0, 420, 123, -420"
})
public String[] customCoords = new String[0];
public CustomCake customCake = new CustomCake();
public static class CustomCake {
@Config.Comment("Set to true to make all Custom Cakes pre-fueled upon placed.")
public boolean preFueled = false;
@Config.Comment("Set to true to make all Custom Cakes consume fuel.")
public boolean consumeFuel = true;
@Config.Comment({
"Set the fuel used by Custom Cakes.",
"Format: <Dimension ID>, <Fuel Registry Name>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void teleport(EntityPlayerMP player, int dim, double x, double y,
if (!player.capabilities.isCreativeMode) {
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 200, 200, false, false));
}
if (worldServer1.provider.getDimension() == -1) {
if (worldServer1.provider.getDimension() != 0) {
for (int xx = -1; xx <= 1; xx++) {
for (int zz = -1; zz <= 1; zz++) {
if (!worldServer1.getBlockState(pos.add(xx, 0, zz)).isFullBlock()) {
Expand Down Expand Up @@ -155,16 +155,6 @@ public static BlockPos getValidYSpawnPos(World world, BlockPos basePos) {
pos.move(EnumFacing.DOWN);
}
}
if (!foundSpawnPos) {
pos.setPos(basePos);
for (int x = -1; x < 2; x++) {
for (int z = -1; z < 2; z++) {
world.setBlockState(pos.add(x, -1, z), Blocks.OBSIDIAN.getDefaultState());
world.setBlockToAir(pos.add(x, 0, z));
world.setBlockToAir(pos.add(x, 1, z));
}
}
}
return pos;
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modid": "dimensionaledibles",
"name": "Dimensional Edibles",
"description": "Travel through dimensions with food!",
"version": "1.3",
"version": "1.3.1",
"mcversion": "1.11.2",
"url": "https://github.com/JackyyTV/DimensionalEdibles",
"updateUrl": "",
Expand Down

0 comments on commit d43bc76

Please sign in to comment.