-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smithing templates + Table and Armour Trims #861
Merged
Merged
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ed35a72
implement smithing templates and working smithing tables
xNatsuri 580c65d
implement fully functional armour trims
xNatsuri b3718f7
Merge branch 'df-mc:master' into armor-trims
xNatsuri 993722c
not sure how this happened
xNatsuri 69ee288
item/recipe: Support smithing trims
TwistedAsylumMC 29f42b5
requested changes
xNatsuri 36fa025
update gophertunnel to 1.36.1
xNatsuri e526d73
fix build errors
xNatsuri f90879d
oops
xNatsuri f7d3636
changes
xNatsuri 6e14eb4
fixes crash (still does not make smithing recipes work)
xNatsuri 13932df
requested changes
xNatsuri 7c52121
Merge remote-tracking branch 'origin/master' into armor-trims
xNatsuri 1432933
merge conflict
xNatsuri 0383f85
Merge branch 'df-mc:master' into armor-trims
xNatsuri c3e9e96
dragonfly/server: Fix smithing trims and recipes
TwistedAsylumMC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package item | ||
|
||
import "github.com/df-mc/dragonfly/server/world" | ||
|
||
type ArmourTrim struct { | ||
Template ArmourTrimTemplate | ||
Material TrimMaterial | ||
} | ||
|
||
type TrimMaterial interface { | ||
DaPigGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// TrimMaterial returns the material name used for reading and writing trim data. | ||
TrimMaterial() string | ||
// MaterialColor returns the color code used for internal text formatting. Use text.Colourf for proper formatting. | ||
DaPigGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MaterialColor() string | ||
DaPigGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// MaterialFromString returns a TrimMaterial from a string. | ||
func MaterialFromString(name string) TrimMaterial { | ||
DaPigGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
switch name { | ||
case "amethyst": | ||
return AmethystShard{} | ||
case "copper": | ||
return CopperIngot{} | ||
case "diamond": | ||
return Diamond{} | ||
case "emerald": | ||
return Emerald{} | ||
case "gold": | ||
return GoldIngot{} | ||
case "iron": | ||
return IronIngot{} | ||
case "lapis": | ||
return LapisLazuli{} | ||
case "netherite": | ||
return NetheriteIngot{} | ||
case "quartz": | ||
return NetherQuartz{} | ||
} | ||
|
||
//TODO: add redstone material once pr is merged | ||
|
||
panic("should not happen") | ||
} | ||
|
||
// TrimMaterials returns all the items that can be trim materials. | ||
func TrimMaterials() []world.Item { | ||
DaPigGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return []world.Item{AmethystShard{}, CopperIngot{}, Diamond{}, Emerald{}, GoldIngot{}, IronIngot{}, LapisLazuli{}, NetheriteIngot{}, NetherQuartz{}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ type Stack struct { | |
data map[string]any | ||
|
||
enchantments map[EnchantmentType]Enchantment | ||
|
||
armorTrim *ArmourTrim | ||
DaPigGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// NewStack returns a new stack using the item type and the count passed. NewStack panics if the count passed | ||
|
@@ -42,6 +44,23 @@ func NewStack(t world.Item, count int) Stack { | |
return Stack{item: t, count: count, id: newID()} | ||
} | ||
|
||
// WithArmourTrim returns a new stack with the ArmorTrim passed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "ArmourTrim" instead of "ArmorTrim" |
||
// This only applies if the stack is type Armour. | ||
func (s Stack) WithArmourTrim(trim ArmourTrim) Stack { | ||
if _, ok := s.item.(Armour); !ok { | ||
return s | ||
} | ||
|
||
s.armorTrim = &trim | ||
return s | ||
} | ||
|
||
// ArmourTrim returns the ArmourTrim. | ||
// if this returns nil it does not have an armor trim, or it is not an armour | ||
func (s Stack) ArmourTrim() *ArmourTrim { | ||
return s.armorTrim | ||
} | ||
DaPigGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Count returns the amount of items that is present on the stack. The count is guaranteed never to be | ||
// negative. | ||
func (s Stack) Count() int { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package item | ||
|
||
// Template is an item used in smithing tables to alter tools and armor. | ||
// They are consumed when used, but can be duplicated using an existing template, its material and diamonds. | ||
type Template struct { | ||
DaPigGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Template the upgrade item used in smithing tables. | ||
Template ArmourTrimTemplate | ||
} | ||
|
||
// EncodeItem ... | ||
func (t Template) EncodeItem() (name string, meta int16) { | ||
if t.Template == TemplateNetheriteUpgrade() { | ||
return "minecraft:netherite_upgrade_smithing_template", 0 | ||
} | ||
return "minecraft:" + t.Template.Name + "_armor_trim_smithing_template", 0 | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writes the ...?