1.0.0 commit

This commit is contained in:
mikx
2025-02-16 17:56:41 -05:00
commit b6df623f02
20 changed files with 799 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace tTP.Content.Items.Placeable
{
public class PersonalTeleporter : ModItem
{
public override void SetDefaults()
{
Item.CloneDefaults(ItemID.ArmorStatue);
Item.createTile = ModContent.TileType<Tiles.PersonalTeleporter>();
Item.placeStyle = 0;
}
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
if (ModLoader.TryGetMod("tMx", out Mod tMxft) && tMxft.TryFind<ModItem>("FrozenTablet", out ModItem FrozenTablet))
{
recipe.AddIngredient(FrozenTablet.Type, 1);
}
if (ModLoader.TryGetMod("tMx", out Mod tMxst) && tMxst.TryFind<ModItem>("SandTablet", out ModItem SandTablet))
{
recipe.AddIngredient(SandTablet.Type, 1);
}
if (ModLoader.TryGetMod("tMx", out Mod tMxtt) && tMxtt.TryFind<ModItem>("ToxicTablet", out ModItem ToxicTablet))
{
recipe.AddIngredient(ToxicTablet.Type, 1);
}
if (ModLoader.TryGetMod("tMx", out Mod tMxmt) && tMxmt.TryFind<ModItem>("MoltenTablet", out ModItem MoltenTablet))
{
recipe.AddIngredient(MoltenTablet.Type, 1);
}
recipe.AddTile(TileID.WorkBenches);
recipe.Register();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

View File

@@ -0,0 +1,125 @@
using Microsoft.Xna.Framework;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Data;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ObjectData;
using System.IO;
using static System.Net.Mime.MediaTypeNames;
using System;
using Terraria.DataStructures;
using Terraria.UI;
namespace tTP.Content.Tiles
{
public class PersonalTeleporter : ModTile
{
public override void SetStaticDefaults()
{
Main.tileFrameImportant[Type] = true;
Main.tileObsidianKill[Type] = true;
Main.tileLighted[Type] = true;
TileID.Sets.DisableSmartCursor[Type] = true;
TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
TileObjectData.addTile(Type);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
{
Tile tile = Main.tile[i, j];
// If the torch is on
if (tile.TileFrameX < 66)
{
int style = TileObjectData.GetTileStyle(Main.tile[i, j]);
// Make it emit the following light.
if (style == 0)
{
r = 0.9f;
g = 0.9f;
b = 0.9f;
}
else if (style == 1)
{
r = 0.5f;
g = 1.5f;
b = 0.5f;
}
}
}
public override void MouseOver(int i, int j)
{
Player player = Main.LocalPlayer;
player.noThrow = 2;
player.cursorItemIconEnabled = true;
int style = TileObjectData.GetTileStyle(Main.tile[i, j]);
player.cursorItemIconID = TileLoader.GetItemDropFromTypeAndStyle(Type, style);
}
public override bool RightClick(int i, int j)
{
return true;
}
public override void PlaceInWorld(int i, int j, Item item)
{
Player p = Main.LocalPlayer;
tTP.table.Rows.Add(Biomes.GetBiome(p), i, j);
Main.NewText($"[tTP] Added new TP: {Biomes.GetBiome(p)} x{i} y{j} ", Color.Aqua);
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (DataRow dr in tTP.table.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in tTP.table.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
string output = JsonConvert.SerializeObject(rows, Formatting.Indented);
string prepjson = @"{ ""tp"":" + output + "}";
File.WriteAllText($"tTP/{tTP.worldName}.json", prepjson);
}
public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
{
Player p = Main.LocalPlayer;
Main.NewText($"[tTP] Removed a TP: {Biomes.GetBiome(p)} x{i} y{j} ", Color.Aqua);
tTP.table.AcceptChanges();
foreach (DataRow tprow in tTP.table.Rows)
{
if (Convert.ToInt64(tprow["x"]) == i && Convert.ToInt64(tprow["y"]) == j)
{
tprow.Delete();
}
}
tTP.table.AcceptChanges();
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (DataRow dr in tTP.table.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in tTP.table.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
string output = JsonConvert.SerializeObject(rows, Formatting.Indented);
string prepjson = @"{ ""tp"":" + output + "}";
File.WriteAllText($"tTP/{tTP.worldName}.json", prepjson);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB