Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Commit 510bdab

Browse files
committed
Fix JRE, add creative tab
1 parent ff92b6d commit 510bdab

File tree

76 files changed

+2810
-2353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2810
-2353
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/bin
33
/obj
44
/mods
5-
/releases
5+
/releases
6+
/.history

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"vsversion": "1.14.0"
2+
"vsversion": "1.14.5"
33
}
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
using Vintagestory.API;
2+
using Vintagestory.API.Common;
3+
using Vintagestory.API.Common.Entities;
4+
using Vintagestory.API.Datastructures;
5+
using Vintagestory.API.MathTools;
6+
using Vintagestory.GameContent;
7+
8+
namespace MoreVariantsFixes
9+
{
10+
public class FixTypedContainer : EntityBehavior
11+
{
12+
ICoreAPI Api { get => player?.Api; }
13+
IWorldAccessor World { get => player?.World; }
14+
EntityPlayer player;
15+
public FixTypedContainer(Entity entity) : base(entity)
16+
{
17+
player = entity as EntityPlayer;
18+
}
19+
public override string PropertyName()
20+
{
21+
return "fixtypedcontainer";
22+
}
23+
public override void OnGameTick(float deltaTime)
24+
{
25+
base.OnGameTick(deltaTime);
26+
27+
if (player.BlockSelection != null && false)
28+
{
29+
BlockPos pos = player.BlockSelection.Position;
30+
BlockEntityGenericTypedContainer be = World.BlockAccessor.GetBlockEntity(pos) as BlockEntityGenericTypedContainer;
31+
32+
if (be?.Block?.Code?.Domain == "morevariants")
33+
{
34+
if (be.Block.FirstCodePart() == "chest")
35+
{
36+
if (be.type != "normal" && be.type != "normal-generic")
37+
{
38+
BlockGenericTypedContainer newBlock = World.BlockAccessor.GetBlock(new AssetLocation("morevariants",
39+
be.Block.FirstCodePart() + "-" + be.type + "-" + be.Block.LastCodePart()
40+
)) as BlockGenericTypedContainer;
41+
42+
if (newBlock != null)
43+
{
44+
be.Block = newBlock;
45+
be.type = "normal-generic";
46+
World.BlockAccessor.SetBlock(newBlock.BlockId, pos);
47+
}
48+
}
49+
else
50+
{
51+
be.type = "normal-generic";
52+
}
53+
}
54+
else if (be.Block.FirstCodePart() == "labeledchest")
55+
{
56+
if (be.type != "normal" && be.type != "normal-labeled" && be.type != "normal-generic")
57+
{
58+
BlockLabeledChest newBlock = World.BlockAccessor.GetBlock(new AssetLocation("morevariants",
59+
be.Block.FirstCodePart() + "-" + be.type.Split('-')[0] + "-" + be.Block.LastCodePart()
60+
)) as BlockLabeledChest;
61+
62+
if (newBlock != null)
63+
{
64+
be.Block = newBlock;
65+
World.BlockAccessor.SetBlock(newBlock.BlockId, pos);
66+
be.type = "normal-labeled";
67+
}
68+
}
69+
else
70+
{
71+
72+
be.type = "normal-labeled";
73+
}
74+
}
75+
}
76+
77+
78+
79+
/*World.Api.Logger.Warning("{0}: Obsolete {1} on {2} will be removed", Constants.MOD_ID, block.Code, pos);
80+
//try
81+
{
82+
TreeAttribute tree = new TreeAttribute();
83+
be.Inventory.ToTreeAttributes(tree);
84+
85+
AssetLocation code = new AssetLocation("morevariants",
86+
block.FirstCodePart() + "-" + be.type.Split('-')[0] + "-" + block.LastCodePart()
87+
);
88+
Block newBlock = World.BlockAccessor.GetBlock(code);
89+
90+
World.BlockAccessor.SetBlock(newBlock.BlockId, pos);
91+
be = World.BlockAccessor.GetBlockEntity(pos) as BlockEntityGenericTypedContainer;
92+
93+
be.Inventory.FromTreeAttributes(tree);
94+
World.Api.Logger.Warning("{0}: Success", Constants.MOD_ID);
95+
}
96+
/*catch (Exception e)
97+
{
98+
World.Api.Logger.Warning("{0}: Fail", Constants.MOD_ID);
99+
World.Api.Logger.Error(e.Message);
100+
}*/
101+
}
102+
}
103+
}
104+
public class BEFixTypedChest : BlockEntityBehavior
105+
{
106+
public BEFixTypedChest(BlockEntity blockentity) : base(blockentity) { }
107+
public override void Initialize(ICoreAPI api, JsonObject properties)
108+
{
109+
base.Initialize(api, properties);
110+
Blockentity.RegisterGameTickListener(OnGameTick, 10000);
111+
}
112+
private void OnGameTick(float dt)
113+
{
114+
BlockEntityGenericTypedContainer be = Blockentity as BlockEntityGenericTypedContainer;
115+
116+
if (be?.Block?.Code?.Domain == "morevariants" && be.type != "normal-labeled" && be.type != "normal-generic")
117+
{
118+
IBlockAccessor blockAccessor = Blockentity.Api.World.BlockAccessor;
119+
120+
string newBEType;
121+
if (be.Block.FirstCodePart() == "chest")
122+
{
123+
newBEType = "normal-generic";
124+
}
125+
else if (be.Block.FirstCodePart() == "labeledchest")
126+
{
127+
newBEType = "normal-labeled";
128+
}
129+
else return;
130+
131+
BlockGenericTypedContainer newBlock;
132+
if (be.type == "normal")
133+
{
134+
newBlock = blockAccessor.GetBlock(be.Block.BlockId) as BlockGenericTypedContainer;
135+
}
136+
else
137+
{
138+
newBlock = blockAccessor.GetBlock(new AssetLocation("morevariants",
139+
be.Block.FirstCodePart() + "-" + be.type.Split('-')[0] + "-" + be.Block.LastCodePart()
140+
)) as BlockGenericTypedContainer;
141+
}
142+
143+
if (newBlock != null)
144+
{
145+
TreeAttribute tree = new TreeAttribute();
146+
be.Inventory.ToTreeAttributes(tree);
147+
float angle = be.MeshAngle;
148+
149+
be.Block = newBlock;
150+
blockAccessor.SetBlock(newBlock.BlockId, be.Pos);
151+
152+
be = blockAccessor.GetBlockEntity(be.Pos.Copy()) as BlockEntityGenericTypedContainer;
153+
be.Inventory.FromTreeAttributes(tree);
154+
be.type = newBEType;
155+
be.MeshAngle = angle;
156+
}
157+
}
158+
}
159+
}
160+
}
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
using Vintagestory.API;
2+
using Vintagestory.API.Common;
3+
using Vintagestory.API.Common.Entities;
4+
using Vintagestory.API.Datastructures;
5+
using Vintagestory.API.MathTools;
6+
using Vintagestory.GameContent;
7+
8+
namespace MoreVariantsFixes
9+
{
10+
public class FixTypedContainer : EntityBehavior
11+
{
12+
13+
BlockEntityLabeledChest
14+
ICoreAPI Api { get => player?.Api; }
15+
IWorldAccessor World { get => player?.World; }
16+
EntityPlayer player;
17+
public FixTypedContainer(Entity entity) : base(entity)
18+
{
19+
player = entity as EntityPlayer;
20+
}
21+
public override string PropertyName()
22+
{
23+
return "fixtypedcontainer";
24+
}
25+
public override void OnGameTick(float deltaTime)
26+
{
27+
base.OnGameTick(deltaTime);
28+
29+
if (player.BlockSelection != null && false)
30+
{
31+
BlockPos pos = player.BlockSelection.Position;
32+
BlockEntityGenericTypedContainer be = World.BlockAccessor.GetBlockEntity(pos) as BlockEntityGenericTypedContainer;
33+
34+
if (be?.Block?.Code?.Domain == "morevariants")
35+
{
36+
if (be.Block.FirstCodePart() == "chest")
37+
{
38+
if (be.type != "normal" && be.type != "normal-generic")
39+
{
40+
BlockGenericTypedContainer newBlock = World.BlockAccessor.GetBlock(new AssetLocation("morevariants",
41+
be.Block.FirstCodePart() + "-" + be.type + "-" + be.Block.LastCodePart()
42+
)) as BlockGenericTypedContainer;
43+
44+
if (newBlock != null)
45+
{
46+
be.Block = newBlock;
47+
be.type = "normal-generic";
48+
World.BlockAccessor.SetBlock(newBlock.BlockId, pos);
49+
}
50+
}
51+
else
52+
{
53+
be.type = "normal-generic";
54+
}
55+
}
56+
else if (be.Block.FirstCodePart() == "labeledchest")
57+
{
58+
if (be.type != "normal" && be.type != "normal-labeled" && be.type != "normal-generic")
59+
{
60+
BlockLabeledChest newBlock = World.BlockAccessor.GetBlock(new AssetLocation("morevariants",
61+
be.Block.FirstCodePart() + "-" + be.type.Split('-')[0] + "-" + be.Block.LastCodePart()
62+
)) as BlockLabeledChest;
63+
64+
if (newBlock != null)
65+
{
66+
be.Block = newBlock;
67+
World.BlockAccessor.SetBlock(newBlock.BlockId, pos);
68+
be.type = "normal-labeled";
69+
}
70+
}
71+
else
72+
{
73+
74+
be.type = "normal-labeled";
75+
}
76+
}
77+
}
78+
79+
80+
81+
/*World.Api.Logger.Warning("{0}: Obsolete {1} on {2} will be removed", Constants.MOD_ID, block.Code, pos);
82+
//try
83+
{
84+
TreeAttribute tree = new TreeAttribute();
85+
be.Inventory.ToTreeAttributes(tree);
86+
87+
AssetLocation code = new AssetLocation("morevariants",
88+
block.FirstCodePart() + "-" + be.type.Split('-')[0] + "-" + block.LastCodePart()
89+
);
90+
Block newBlock = World.BlockAccessor.GetBlock(code);
91+
92+
World.BlockAccessor.SetBlock(newBlock.BlockId, pos);
93+
be = World.BlockAccessor.GetBlockEntity(pos) as BlockEntityGenericTypedContainer;
94+
95+
be.Inventory.FromTreeAttributes(tree);
96+
World.Api.Logger.Warning("{0}: Success", Constants.MOD_ID);
97+
}
98+
/*catch (Exception e)
99+
{
100+
World.Api.Logger.Warning("{0}: Fail", Constants.MOD_ID);
101+
World.Api.Logger.Error(e.Message);
102+
}*/
103+
}
104+
}
105+
}
106+
public class BEFixTypedChest : BlockEntityBehavior
107+
{
108+
public BEFixTypedChest(BlockEntity blockentity) : base(blockentity) { }
109+
public override void Initialize(ICoreAPI api, JsonObject properties)
110+
{
111+
base.Initialize(api, properties);
112+
Blockentity.RegisterGameTickListener(OnGameTick, 10000);
113+
}
114+
private void OnGameTick(float dt)
115+
{
116+
BlockEntityGenericTypedContainer be = Blockentity as BlockEntityGenericTypedContainer;
117+
118+
if (be?.Block?.Code?.Domain == "morevariants" && be.type != "normal-labeled" && be.type != "normal-generic")
119+
{
120+
IBlockAccessor blockAccessor = Blockentity.Api.World.BlockAccessor;
121+
122+
string newBEType;
123+
if (be.Block.FirstCodePart() == "chest")
124+
{
125+
newBEType = "normal-generic";
126+
}
127+
else if (be.Block.FirstCodePart() == "labeledchest")
128+
{
129+
newBEType = "normal-labeled";
130+
}
131+
else return;
132+
133+
BlockGenericTypedContainer newBlock;
134+
if (be.type == "normal")
135+
{
136+
newBlock = blockAccessor.GetBlock(be.Block.BlockId) as BlockGenericTypedContainer;
137+
}
138+
else
139+
{
140+
newBlock = blockAccessor.GetBlock(new AssetLocation("morevariants",
141+
be.Block.FirstCodePart() + "-" + be.type.Split('-')[0] + "-" + be.Block.LastCodePart()
142+
)) as BlockGenericTypedContainer;
143+
}
144+
145+
if (newBlock != null)
146+
{
147+
TreeAttribute tree = new TreeAttribute();
148+
be.Inventory.ToTreeAttributes(tree);
149+
float angle = be.MeshAngle;
150+
151+
be.Block = newBlock;
152+
blockAccessor.SetBlock(newBlock.BlockId, be.Pos);
153+
154+
be = blockAccessor.GetBlockEntity(be.Pos.Copy()) as BlockEntityGenericTypedContainer;
155+
be.Inventory.FromTreeAttributes(tree);
156+
be.type = newBEType;
157+
be.MeshAngle = angle;
158+
}
159+
}
160+
}
161+
}
162+
}

MoreVariantsFixes/.vscode/launch.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"internalConsoleOptions": "openOnSessionStart",
2222
"env": {
2323
"TEXTURE_DEBUG_DISPOSE": "0"
24-
}
24+
},
25+
"justMyCode": false
2526
},
2627
{
2728
"name": "Launch Client (Mono)",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"vsversion": "1.14.0"
2+
"vsversion": "1.14.2"
33
}

MoreVariantsFixes/MoreVariantsFixes.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net452</TargetFramework>
4-
<VSVersion>1.14.0</VSVersion>
4+
<VSVersion>1.14.2</VSVersion>
55
</PropertyGroup>
66

77
<ItemGroup>

MoreVariantsFixes/resources/assets/morevariantsfixes/patches/add-behavior.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

MoreVariantsFixes/src/EntityBehavior/FixTypedContainer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
using System.Text;
31
using Vintagestory.API;
42
using Vintagestory.API.Common;
53
using Vintagestory.API.Common.Entities;
@@ -9,7 +7,7 @@
97

108
namespace MoreVariantsFixes
119
{
12-
public class FixTypedContainer : EntityBehaviorPlaceBlock
10+
public class FixTypedContainer : EntityBehavior
1311
{
1412
ICoreAPI Api { get => player?.Api; }
1513
IWorldAccessor World { get => player?.World; }

0 commit comments

Comments
 (0)